@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:wght@300;400;500&display=swap');

/* ─── VARIABLES ─── */
:root {
  --bg-base:       #0a0a0f;
  --bg-card:       #111118;
  --bg-card-2:     #16161f;
  --bg-input:      #1a1a25;
  --border:        rgba(255,255,255,0.07);
  --border-focus:  rgba(99,179,237,0.5);

  --cyan:          #63b3ed;
  --cyan-dim:      rgba(99,179,237,0.15);
  --cyan-glow:     rgba(99,179,237,0.3);
  --gold:          #f6c90e;
  --gold-dim:      rgba(246,201,14,0.12);
  --red:           #fc8181;
  --red-dim:       rgba(252,129,129,0.12);
  --green:         #68d391;
  --green-dim:     rgba(104,211,145,0.12);

  --text-primary:  #f0f0f8;
  --text-secondary:#8888aa;
  --text-muted:    #55556a;

  --font-display:  'Syne', sans-serif;
  --font-body:     'DM Sans', sans-serif;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     18px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 48px rgba(0,0,0,0.6);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── FONDO ANIMADO ─── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(99,179,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,179,237,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  border-radius: 50%; filter: blur(100px); opacity: 0.12;
}
.bg-glow-1 {
  width: 600px; height: 600px;
  background: var(--cyan);
  top: -200px; right: -200px;
}
.bg-glow-2 {
  width: 400px; height: 400px;
  background: var(--gold);
  bottom: -150px; left: -100px;
}

/* ─── TIPOGRAFÍA ─── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

/* ─── LAYOUT ─── */
.app-wrapper { position: relative; z-index: 1; }

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px; border-radius: var(--radius); }

/* ─── INPUTS ─── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-secondary);
}
.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}
.form-select option { background: var(--bg-card-2); }

/* ─── BOTONES ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; white-space: nowrap;
  letter-spacing: 0.02em;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--cyan); color: #0a0a0f;
}
.btn-primary:hover:not(:disabled) {
  background: #90cdf4; box-shadow: 0 0 20px var(--cyan-glow);
}

.btn-gold {
  background: var(--gold); color: #0a0a0f;
}
.btn-gold:hover:not(:disabled) {
  background: #fad643; box-shadow: 0 0 20px rgba(246,201,14,0.4);
}

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--cyan); color: var(--cyan);
}

.btn-danger {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(252,129,129,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(252,129,129,0.25);
}

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: var(--radius); }
.btn-full { width: 100%; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-pending  { background: var(--gold-dim);  color: var(--gold); }
.badge-partial  { background: var(--cyan-dim);  color: var(--cyan); }
.badge-paid     { background: var(--green-dim); color: var(--green); }
.badge-canceled { background: rgba(136,136,170,0.1); color: var(--text-muted); }
.badge-danger   { background: var(--red-dim);   color: var(--red); }

/* ─── TABLAS ─── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr {
  border-bottom: 1px solid var(--border);
}
thead th {
  padding: 10px 14px; text-align: left;
  font-family: var(--font-display); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}
tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 12px 14px; color: var(--text-secondary); }
tbody td:first-child { color: var(--text-primary); font-weight: 500; }

/* ─── STAT CARDS ─── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.cyan::before  { background: var(--cyan); }
.stat-card.gold::before  { background: var(--gold); }
.stat-card.green::before { background: var(--green); }
.stat-card.red::before   { background: var(--red); }

.stat-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
}
.stat-value {
  font-family: var(--font-display); font-size: 2rem; font-weight: 800;
  color: var(--text-primary); line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--text-muted); }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0; position: fixed; left: 0; top: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo .logo-text {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
  color: var(--text-primary);
}
.sidebar-logo .logo-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.sidebar-logo .logo-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--cyan);
  margin-right: 6px; box-shadow: 0 0 8px var(--cyan);
}

.nav-section {
  padding: 0 12px; margin-bottom: 8px;
}
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 12px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-input); color: var(--text-primary); }
.nav-item.active {
  background: var(--cyan-dim); color: var(--cyan);
  border: 1px solid rgba(99,179,237,0.15);
}
.nav-item .icon { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto; padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--cyan-dim); border: 1px solid var(--cyan-glow);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  color: var(--cyan); flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.user-role  { font-size: 11px; color: var(--text-muted); }

/* ─── MAIN CONTENT ─── */
.main-content {
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-title { font-size: 1.6rem; }
.page-title span { color: var(--cyan); }

/* ─── GRID ─── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 28px;
}
.content-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

/* ─── BOTÓN HAMBURGUESA (oculto en desktop) ─── */
.menu-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 150;
  width: 44px; height: 44px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-primary);
  font-size: 20px; cursor: pointer;
  align-items: center; justify-content: center;
}
/* Capa oscura detrás del menú cuando está abierto en móvil */
.sidebar-backdrop {
  display: none;
  position: fixed; top: 0; right: 0; bottom: 0; left: 260px; z-index: 100;
  background: rgba(0,0,0,0.55);
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 860px) {
  /* Mostrar hamburguesa */
  .menu-toggle { display: flex; }

  /* Sidebar se vuelve panel deslizable */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
    overflow-y: auto;
    pointer-events: auto;
  }
  .sidebar.open { transform: translateX(0); }
  /* Los ítems del menú deben ser clickeables por encima de todo */
  .sidebar .nav-item, .sidebar .btn { position: relative; z-index: 1; }

  .main-content {
    margin-left: 0;
    padding: 72px 14px 24px;   /* espacio arriba para el botón */
  }
  /* El primer título no se pega al botón hamburguesa */
  .main-content .page-header { margin-top: 4px; }

  /* Tarjetas de stats en una sola columna en móvil pequeño */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Tablas: scroll horizontal para que no se aplasten */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper table { min-width: 560px; }

  /* Encabezados de página apilados */
  .page-header {
    flex-direction: column; align-items: flex-start; gap: 12px;
  }
  .page-header .btn,
  .page-header > div { width: 100%; }
  .page-header > div { display: flex; gap: 8px; }
  .page-header > div .btn { flex: 1; }

  /* Modales ocupan casi toda la pantalla */
  .modal { max-width: 100%; padding: 20px; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  /* Botones más cómodos para el dedo */
  .btn { padding: 11px 16px; }
  .btn-sm { padding: 7px 12px; }

  /* Título un poco más pequeño */
  .page-title { font-size: 1.3rem; }
}

@media (max-width: 460px) {
  .stats-grid { grid-template-columns: 1fr; }
}


/* ─── Prevención de desbordamiento horizontal ─── */
html, body { max-width: 100%; overflow-x: hidden; }
.main-content { max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
.card { max-width: 100%; box-sizing: border-box; }

/* ─── Barra de Total a Pagar (portal) ─── */
.barra-pago {
  position: fixed; bottom: 0; left: 240px; right: 0;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center;
  justify-content: space-between; z-index: 50;
  box-sizing: border-box;
}
@media (max-width: 860px) {
  .barra-pago {
    left: 0;                 /* ocupa todo el ancho en móvil */
    padding: 14px 16px;
    flex-direction: column; gap: 12px; align-items: stretch;
  }
  .barra-pago .btn { width: 100%; }
}

/* ─── MODALES ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px;
}

/* ─── ALERTS ─── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.alert-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(252,129,129,0.2); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(104,211,145,0.2); }
.alert-info    { background: var(--cyan-dim);  color: var(--cyan);  border: 1px solid rgba(99,179,237,0.2); }

/* ─── LOADING ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; flex-direction: column; gap: 12px;
}
.loading-text { color: var(--text-muted); font-size: 13px; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── SEARCH ─── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px;
  transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--border-focus); }
.search-bar input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px;
  font-family: var(--font-body); width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 16px; }

/* ─── DIVIDER ─── */
.divider {
  height: 1px; background: var(--border); margin: 16px 0;
}

/* ─── TOOLTIPS ─── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-2); color: var(--text-primary);
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  border: 1px solid var(--border);
}

/* ─── ANIMACIONES DE ENTRADA ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.35s ease forwards; }
.fade-up-1 { animation-delay: 0.05s; opacity: 0; }
.fade-up-2 { animation-delay: 0.10s; opacity: 0; }
.fade-up-3 { animation-delay: 0.15s; opacity: 0; }
.fade-up-4 { animation-delay: 0.20s; opacity: 0; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── BUSCADOR PERSONALIZADO ─── */
.buscador-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-card-2, #16161f);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.buscador-item {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.buscador-item:last-child { border-bottom: none; }
.buscador-item:hover { background: var(--cyan-dim, rgba(99,179,237,0.15)); color: var(--cyan, #63b3ed); }
.buscador-vacio { color: var(--text-muted); cursor: default; font-style: italic; }
.buscador-vacio:hover { background: transparent; color: var(--text-muted); }
