/* ======================== */
/* VARIABLES Y RESET GLOBAL */
/* ======================== */
:root {
  --bg-page: #0f0f0f;
  --bg-card: #1e1e2a;
  --border-card: linear-gradient(135deg, #00e5ff, #ff4081);
  --text-main: #f0f0f0;
  --text-secondary: #b0b0b0;
  --accent: #00e5ff;
  --accent-hover: #33eeff;
  --accent-2: #ff4081;
  --accent-2-hover: #ff5c9c;
  --success: #4caf50;
  --error: #ff5252;
  --radius: 12px;
  --transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --glow: 0 0 15px rgba(0, 229, 255, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: 
    radial-gradient(circle at 10% 20%, rgba(30, 30, 42, 0.3) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 64, 129, 0.2) 0%, transparent 40%),
    var(--bg-page);
  color: var(--text-main);
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 2rem;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 30%, rgba(0, 229, 255, 0.05) 0%, transparent 20%),
    radial-gradient(circle at 80% 70%, rgba(255, 64, 129, 0.05) 0%, transparent 20%);
  z-index: -1;
  pointer-events: none;
}

.hidden {
  display: none;
}

/* =================== */
/* HEADER OPTIMIZADO */
/* =================== */
header {
  background: var(--border-card);
  color: white;
  padding: 1.1rem 1.5rem; /* Padding más equilibrado */
  font-weight: 700;
  letter-spacing: 0.5px; /* Menos espaciado para mejor legibilidad */
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition);
}

.header-content {
  flex: 1;
  text-align: center;
  padding: 0 2rem; /* Espacio para el botón de logout */
}

header h1 {
  font-size: 1.7rem; /* Tamaño más adecuado */
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  margin: 0;
  line-height: 1.3; /* Mejor interlineado */
  font-weight: 600;
  transition: all var(--transition);
}

/* Efecto de brillo sutil */
header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shine 6s infinite;
  z-index: 0;
  opacity: 0.7;
}

@keyframes shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Botón de logout mejor integrado */
.logout {
  width: 38px;
  height: 38px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: var(--accent);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  flex-shrink: 0; /* Evita que se encoja */
  position: relative;
}

.logout:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 15px rgba(0, 229, 255, 0.4);
}

/* ================= */
/* PANEL AUTENTICACIÓN */
/* ================= */
#authPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.8rem 2.5rem 2.5rem;
  max-width: 450px;
  width: 100%;
  margin-top: 2rem;
  transition: transform var(--transition), box-shadow var(--transition);
  font-size: 1.1rem;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border-card);
}

.auth-form:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.auth-form h2 {
  margin-bottom: 1.8rem;
  color: var(--accent);
  text-align: center;
  font-size: 1.8rem;
  font-weight: 600;
}

.auth-form input,
.auth-form button {
  font-size: 1.05rem;
  padding: 1rem 1.4rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
}

.form-switch {
  text-align: center;
  margin-top: 1rem;
}

.form-switch button {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: none;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: 20px;
  position: relative;
}

.form-switch button::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: all var(--transition);
  transform: translateX(-50%);
}

.form-switch button:hover {
  color: var(--accent-hover);
}

.form-switch button:hover::after {
  width: 100%;
}

/* ================= */
/* TARJETAS DE CONTENIDO */
/* ================= */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border-card);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.card h2 {
  margin-bottom: 1.5rem;
  color: var(--accent);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card h2::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin-left: 10px;
}

/* ================= */
/* FORMULARIOS Y CONTROLES */
/* ================= */
input,
button {
  width: 100%;
  padding: 0.9rem 1.3rem;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all var(--transition);
  outline: none;
}

input {
  background: #252538;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 600;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-hover), var(--accent-2-hover));
  opacity: 0;
  transition: opacity var(--transition);
  z-index: -1;
}

button:hover::before {
  opacity: 1;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 7px 15px rgba(0, 229, 255, 0.3);
}

/* ================= */
/* FILTROS Y LISTAS */
/* ================= */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.filtros button {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  width: auto;
}

.filtros button:hover,
.filtros button.active {
  background: var(--accent);
  color: white;
}

#compras {
  max-height: 350px;
  overflow-y: auto;
  padding-right: 0.8rem;
}

#compras::-webkit-scrollbar {
  width: 8px;
}

#compras::-webkit-scrollbar-track {
  background: rgba(30, 30, 42, 0.5);
  border-radius: 4px;
}

#compras::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.compra-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1c1c2c;
  padding: 1.2rem;
  margin-bottom: 0.9rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  border-left: 4px solid var(--accent);
}

.compra-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.05), transparent);
  z-index: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.compra-item:hover::before {
  opacity: 1;
}

.compra-item:hover {
  transform: translateX(5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.compra-item div:first-child {
  flex: 1;
  color: var(--text-main);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.compra-item div:last-child {
  display: flex;
  gap: 0.7rem;
  position: relative;
  z-index: 1;
}

.compra-item div:last-child button {
  margin-left: 0;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  min-width: 40px;
}

.compra-item div:last-child button:hover {
  background: var(--accent);
}

/* ================= */
/* TABLAS Y FORMULARIOS */
/* ================= */
#addTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.8rem;
  border-radius: var(--radius);
  overflow: hidden;
}

#addTable th,
#addTable td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.8rem;
  text-align: left;
}

#addTable thead {
  background: rgba(0, 229, 255, 0.1);
}

#addTable th {
  font-weight: 600;
  color: var(--accent);
}

#addTable input {
  width: 100%;
  padding: 0.5rem;
  background: #2d2d40;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

#addTable button {
  width: auto;
  padding: 0.4rem 0.8rem;
  background: var(--error);
  font-size: 0.9rem;
}

#addTable button:hover {
  background: #ff1a1a;
}

#compras form {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  background: #1c1c2c;
  padding: 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

#compras form input {
  flex: 1;
  min-width: 150px;
  padding: 0.7rem;
  background: #2a2a3d;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
}

#compras form button {
  padding: 0.7rem 1.2rem;
  background: var(--accent);
  min-width: 100px;
}

#compras form button:hover {
  background: var(--accent-hover);
}

/* ================= */
/* GRUPOS DE BOTONES */
/* ================= */
.button-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 1.2rem 2rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  z-index: 1;
  border: none;
  min-width: 220px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  flex: 1;
  max-width: calc(50% - 0.75rem);
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.15);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: -1;
}

.btn:hover::before {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.btn:active {
  transform: translateY(-2px);
  transition: transform 0.1s ease;
}

.btn-add-row {
  background: linear-gradient(135deg, var(--accent), #008c9e);
  color: white;
}

.btn-add-row:hover {
  box-shadow: 0 10px 20px rgba(0, 229, 255, 0.4);
}

.btn-save {
  background: linear-gradient(135deg, var(--accent-2), #d81b60);
  color: white;
}

.btn-save:hover {
  box-shadow: 0 10px 20px rgba(255, 64, 129, 0.4);
}

.btn-icon {
  font-size: 1.3rem;
  transition: transform 0.3s ease;
}

.btn:hover .btn-icon {
  transform: scale(1.2);
}

.btn-pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(0, 229, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0); }
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #388e3c);
}

.btn-success:hover {
  box-shadow: 0 10px 20px rgba(76, 175, 80, 0.4);
}

/* ================= */
/* MENSAJES Y ALERTAS */
/* ================= */
.confirmation {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 1.2rem 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  font-size: 1.1rem;
}

.confirmation.show {
  opacity: 1;
  pointer-events: auto;
}

/* Efecto de ondas al hacer clic */
.btn:after {
  content: "";
  display: block;
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.3);
  width: 100px;
  height: 100px;
  margin-top: -50px;
  margin-left: -50px;
  opacity: 0;
  transition: all 0.8s;
}

.btn:active:after {
  opacity: 1;
  transform: scale(0);
  transition: 0s;
}

.btn-text {
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ================= */
/* RESPONSIVE DESIGN */
/* ================= */
@media (max-width: 768px) {
  /* Header responsive */
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.8rem;
  }
  
  .header-content {
    padding: 0;
    order: 1;
  }
  
  .logout {
    position: relative;
    order: 2;
    top: 0;
    right: 0;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  /* Resto de elementos responsive */
  main {
    gap: 1.8rem;
    padding: 0 1rem;
  }
  
  .auth-form {
    padding: 2rem 1.5rem;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  #compras form {
    flex-direction: column;
  }
  
  #compras form input,
  #compras form button {
    width: 100%;
  }
  
  .button-group {
    flex-direction: column;
    gap: 1.2rem;
  }
  
  .btn {
    min-width: 100%;
    max-width: 100%;
    padding: 1.1rem 1.5rem;
  }
  
  .confirmation {
    width: 90%;
    text-align: center;
    padding: 1rem;
    font-size: 1rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  header h1 {
    font-size: 1.6rem;
  }
  
  .btn {
    min-width: 200px;
  }
}

/* Efecto de transición para elementos principales */
main {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  gap: 2.5rem;
  transition: all 0.4s ease;
}
