/* ============================================
   style.css — Sistema de Boletos
   Diseño: Profesional Claro / Navy & Gold
   ============================================ */

:root {
  --primary:       #1a3a5c;
  --primary-light: #2a5080;
  --accent:        #c9a84c;
  --accent-light:  #f0e6c8;
  --bg-main:       #f2f5f9;
  --bg-sidebar:    #1a3a5c;
  --surface:       #ffffff;
  --border:        #dde3ea;
  --border-strong: #b0bac7;
  --text:          #1e2d3d;
  --text-muted:    #6b7a8d;
  --text-light:    #9aa5b1;
  --success:       #1e7e4f;
  --success-bg:    #edfaf3;
  --danger:        #c0392b;
  --danger-bg:     #fef2f2;
  --warning:       #b45309;
  --warning-bg:    #fffbeb;
  --info:          #1d4ed8;
  --info-bg:       #eff6ff;
  --radius:        10px;
  --shadow-sm:     0 1px 4px rgba(0,0,0,.06);
  --shadow:        0 2px 16px rgba(26,58,92,.08);
  --shadow-lg:     0 4px 32px rgba(26,58,92,.13);
  --sidebar-w:     260px;
  --header-h:      60px;
  --font-heading:  'Outfit', sans-serif;
  --font-body:     'Source Sans 3', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LAYOUT
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .6rem;
}

.sidebar-brand .brand-icon svg { width: 22px; height: 22px; fill: #fff; }
.sidebar-brand h2 { font-family: var(--font-heading); font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-brand p { font-size: .75rem; color: rgba(255,255,255,.45); margin-top: .15rem; }

.sidebar-user {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .75rem;
}

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 700; font-size: .9rem; color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: .74rem; color: rgba(255,255,255,.5); text-transform: capitalize; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section { padding: .5rem 1.5rem .25rem; font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: .08em; }

.nav-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 1.5rem; font-size: .88rem; font-weight: 500; color: rgba(255,255,255,.65); text-decoration: none; transition: all .2s; border-left: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.10); border-left-color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer a { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: rgba(255,255,255,.5); text-decoration: none; transition: color .2s; }
.sidebar-footer a:hover { color: #fff; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}

.page-header h1 { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.page-header .subtitle { font-size: .83rem; color: var(--text-muted); margin-top: .1rem; }

.page-body { padding: 1.75rem 2rem; flex: 1; }

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-header h3 { font-family: var(--font-heading); font-size: 1rem; font-weight: 600; color: var(--primary); }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg-main); }

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.2rem; margin-bottom: 1.75rem; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.3rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm); transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue  { background: #dbeafe; } .stat-icon.blue svg  { fill: #1d4ed8; }
.stat-icon.gold  { background: #fef3c7; } .stat-icon.gold svg  { fill: #b45309; }
.stat-icon.green { background: #d1fae5; } .stat-icon.green svg { fill: #065f46; }
.stat-icon.red   { background: #fee2e2; } .stat-icon.red svg   { fill: #991b1b; }

.stat-data { flex: 1; min-width: 0; }
.stat-data .num { font-family: var(--font-heading); font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-data .label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ============================================
   FORMS
   ============================================ */
.form-grid { display: grid; gap: 1.1rem; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .83rem; font-weight: 600; color: var(--text); }
.form-label span { color: var(--danger); }

.form-control, .form-select {
  padding: .65rem .9rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .93rem; font-family: var(--font-body);
  color: var(--text); background: #fff; transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,58,92,.08);
}
.form-control::placeholder { color: var(--text-light); }
.form-hint { font-size: .78rem; color: var(--text-muted); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1.2rem; border: 1.5px solid transparent;
  border-radius: 8px; font-family: var(--font-heading); font-size: .9rem;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: all .2s; white-space: nowrap;
}
.btn:active { transform: scale(.99); }
.btn svg { width: 16px; height: 16px; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b8963e; }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #165e3a; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }

.btn-outline   { background: #fff; color: var(--primary); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--bg-main); border-color: var(--primary); }

.btn-sm { padding: .38rem .85rem; font-size: .82rem; }
.btn-lg { padding: .8rem 1.8rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================
   TABLE
   ============================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { background: var(--bg-main); padding: .75rem 1rem; text-align: left; font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafd; }

.code-badge { font-family: 'Courier New', monospace; font-weight: 700; font-size: .9rem; background: var(--accent-light); color: var(--primary); padding: .2rem .5rem; border-radius: 5px; }

/* ============================================
   BADGES / PILLS
   ============================================ */
.badge { display: inline-flex; align-items: center; padding: .22rem .65rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-accent  { background: var(--accent-light); color: #7a5c1e; }

/* ============================================
   ALERTS
   ============================================ */
.alert { padding: .9rem 1.1rem; border-radius: 8px; font-size: .88rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .6rem; }
.alert-success { background: var(--success-bg); border: 1px solid #a7f3d0; color: var(--success); }
.alert-danger  { background: var(--danger-bg);  border: 1px solid #fecaca; color: var(--danger); }
.alert-warning { background: var(--warning-bg); border: 1px solid #fde68a; color: var(--warning); }
.alert-info    { background: var(--info-bg);    border: 1px solid #bfdbfe; color: var(--info); }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .25s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; transform: translateY(10px); transition: transform .25s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 1.3rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; padding: .2rem; line-height: 1; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

/* ============================================
   TABS
   ============================================ */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab { padding: .65rem 1.2rem; font-family: var(--font-heading); font-size: .9rem; font-weight: 600; color: var(--text-muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================
   SEARCH / FILTER BAR
   ============================================ */
.filter-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 2.4rem; }
.search-box svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: var(--text-muted); pointer-events: none; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination { display: flex; align-items: center; gap: .35rem; justify-content: center; padding-top: 1rem; }
.page-btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 7px; border: 1px solid var(--border); font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); background: #fff; transition: all .2s; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================
   BREADCRUMB
   ============================================ */
.breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .83rem; color: var(--text-muted); margin-bottom: 1.3rem; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--text); font-weight: 600; }

/* ============================================
   LOADING
   ============================================ */
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   RESPONSIVE — Tablet (≤ 1024px)
   ============================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   RESPONSIVE — Mobile/Tablet (≤ 768px)
   ============================================ */
@media (max-width: 768px) {
  /* Sidebar overlay */
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 300;
    width: 260px;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay oscuro detrás del sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 299;
  }
  .sidebar-backdrop.open { display: block; }

  .main-content { margin-left: 0; }

  /* Header */
  .page-header {
    padding: .85rem 1rem;
    gap: .6rem;
    flex-wrap: wrap;
  }
  .page-header h1 { font-size: 1.05rem; }
  .page-header .subtitle { display: none; }

  /* Botón hamburguesa — visible en mobile */
  #menuBtn { display: flex !important; }

  /* Contenido */
  .page-body { padding: 1rem; }

  /* Grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .form-grid-2,
  .form-grid-3 { grid-template-columns: 1fr; }

  /* Tablas — scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Cards */
  .card-body { padding: 1rem; }
  .card-header { padding: .85rem 1rem; flex-wrap: wrap; gap: .5rem; }

  /* Filter bar */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; width: 100%; }
  .filter-bar .btn { width: 100%; justify-content: center; }

  /* Tabs — scroll horizontal si hay muchos */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tab { white-space: nowrap; font-size: .83rem; padding: .55rem .9rem; }

  /* Modales */
  .modal { max-width: 96vw; margin: auto; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Botones en grupos */
  .btn-group-row { flex-direction: column; }
  .btn-group-row .btn { width: 100%; justify-content: center; }

  /* Tickets grid */
  #tickets-print { grid-template-columns: 1fr !important; }

  /* Paginación */
  .pagination { flex-wrap: wrap; }

  /* Seq layout */
  .seq-layout { grid-template-columns: 1fr !important; }

  /* Stat cards */
  .stat-card { padding: 1rem; }
  .stat-data .num { font-size: 1.4rem; }
}

/* ============================================
   RESPONSIVE — Mobile pequeño (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }

  .page-header { padding: .7rem .85rem; }

  /* Ocultar columnas secundarias en tablas */
  .table-wrap table td:nth-child(n+5),
  .table-wrap table th:nth-child(n+5) {
    display: none;
  }

  /* Ticket impreso */
  .ticket { max-width: 100%; }

  .card-body { padding: .85rem; }

  /* Btn acciones de tabla — solo iconos */
  .btn-accion-texto { display: none; }
}

/* ============================================
   Utilidades touch
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Áreas táctiles mínimas 44px */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; padding: .5rem 1rem; }
  .nav-item { padding: .85rem 1.5rem; }
  .form-control, .form-select { padding: .75rem .9rem; font-size: 16px; } /* 16px evita zoom en iOS */
  .page-btn { width: 40px; height: 40px; }
}

/* ============================================
   PRINT STYLES (para boletos)
   ============================================ */
@media print {
  body { background: #fff; }
  .sidebar, .page-header, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .ticket { page-break-inside: avoid; margin-bottom: 0; }
  @page { margin: .5cm; }
}

/* ============================================
   TICKET PREVIEW
   ============================================ */
.ticket {
  border: 2px solid var(--primary); border-radius: 12px;
  overflow: hidden; width: 100%; max-width: 420px;
  font-family: var(--font-body);
  box-shadow: var(--shadow);
  page-break-inside: avoid;
}
.ticket-header { background: var(--primary); color: #fff; padding: .9rem 1.2rem; display: flex; align-items: center; justify-content: space-between; }
.ticket-header h3 { font-family: var(--font-heading); font-size: .95rem; font-weight: 700; }
.ticket-header .num { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.ticket-body { padding: 1rem 1.2rem; background: #fff; }
.ticket-field { display: flex; justify-content: space-between; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .84rem; }
.ticket-field:last-child { border-bottom: none; }
.ticket-field .lbl { color: var(--text-muted); font-weight: 500; }
.ticket-field .val { font-weight: 600; color: var(--text); text-align: right; max-width: 55%; word-break: break-word; }
.ticket-footer { background: var(--accent); padding: .5rem 1.2rem; text-align: center; font-size: .75rem; font-weight: 700; color: #fff; letter-spacing: .05em; }
