/* ═══════════════════════════════════════════════════════════
   Soporte TI — Estilos globales (responsive)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg0:      #0d1117;
  --bg1:      #161b27;
  --bg2:      #1e2535;
  --bg3:      #252d3d;
  --accent:   #3b82f6;
  --accent-h: #2563eb;
  --green:    #22c55e;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --purple:   #a855f7;
  --text1:    #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --border:   rgba(255,255,255,0.07);
  --sidebar-w: 240px;
  --bottomnav-h: 64px;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg0);
  color: var(--text1);
  min-height: 100vh;
  line-height: 1.5;
}

/* ════════════════════════════════
   LAYOUT
════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-width: 0;
  width: calc(100% - var(--sidebar-w));
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
  width: 100%;
}

/* Overlay oscuro cuando sidebar abierto en móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ════════════════════════════════
   SIDEBAR (escritorio)
════════════════════════════════ */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text3);
  padding: 8px 8px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: all .15s;
}
.nav-item:hover  { background: var(--bg3); color: var(--text1); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }

.logout-btn {
  color: var(--text3);
  display: flex; align-items: center;
  padding: 6px; border-radius: 6px;
  transition: all .15s; cursor: pointer;
  text-decoration: none;
}
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ════════════════════════════════
   BOTTOM NAV (solo móvil)
════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--bg1);
  border-top: 1px solid var(--border);
  z-index: 200;
  align-items: stretch;
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text3);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  padding: 8px 4px;
  transition: color .15s;
  border: none;
  background: none;
  cursor: pointer;
}
.bnav-item svg { flex-shrink: 0; }
.bnav-item.active { color: var(--accent); }
.bnav-item:hover  { color: var(--text1); }

/* ════════════════════════════════
   TOPBAR
════════════════════════════════ */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--bg0);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background .15s;
}
.menu-toggle:hover { background: var(--bg3); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ════════════════════════════════
   PAGE HEADER
════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p  { font-size: 14px; color: var(--text2); margin-top: 2px; }

/* ════════════════════════════════
   CARDS
════════════════════════════════ */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; }

/* ════════════════════════════════
   STATS
════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-blue   { background: rgba(59,130,246,.15); color: var(--accent); }
.icon-green  { background: rgba(34,197,94,.15);  color: var(--green);  }
.icon-amber  { background: rgba(245,158,11,.15); color: var(--amber);  }
.icon-purple { background: rgba(168,85,247,.15); color: var(--purple); }
.icon-red    { background: rgba(239,68,68,.15);  color: var(--red);    }

.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 700; }

/* ════════════════════════════════
   TABLES
════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg2); }
.td-bold    { font-weight: 500; }
.td-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.text-muted { color: var(--text3); }
.empty-state { text-align: center; padding: 40px !important; color: var(--text3); font-size: 14px; }

/* ════════════════════════════════
   TICKET CARDS (móvil)
════════════════════════════════ */
.ticket-cards { display: none; flex-direction: column; gap: 12px; }

.ticket-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color .15s;
}
.ticket-card:hover { border-color: rgba(255,255,255,.14); }

.ticket-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.ticket-card-id    { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.ticket-card-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.ticket-card-meta  { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ticket-card-user  { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }

.ticket-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.ticket-card-actions .btn {
  justify-content: center;
  padding: 10px 8px;
  font-size: 13px;
}
.ticket-card-actions .btn-full {
  grid-column: 1 / -1;
}

/* ════════════════════════════════
   BADGES
════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-blue   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-green  { background: rgba(34,197,94,.15);   color: #4ade80; }
.badge-amber  { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-red    { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-purple { background: rgba(168,85,247,.15);  color: #c084fc; }
.badge-cat    { background: var(--bg3); color: var(--text2); }

.role-badge    { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 20px; }
.badge-admin   { background: rgba(168,85,247,.15); color: #c084fc; }
.badge-tecnico { background: rgba(59,130,246,.15); color: #60a5fa; }

/* ════════════════════════════════
   BUTTONS
════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); }
.btn-outline { background: transparent; color: var(--text1); border-color: var(--border); }
.btn-outline:hover { background: var(--bg3); }
.btn-danger  { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.2); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-block   { width: 100%; justify-content: center; }
.btn-sm      { padding: 6px 12px; font-size: 13px; }

/* Colores de acción ticket */
.btn-atender    { background:rgba(245,158,11,.15); color:#fbbf24; border-color:rgba(245,158,11,.3); }
.btn-atender:hover { background:rgba(245,158,11,.28); }
.btn-solucionar { background:rgba(34,197,94,.15);  color:#4ade80; border-color:rgba(34,197,94,.3); }
.btn-solucionar:hover { background:rgba(34,197,94,.28); }
.btn-soltar     { background:rgba(239,68,68,.12);  color:#f87171; border-color:rgba(239,68,68,.25); }
.btn-soltar:hover { background:rgba(239,68,68,.22); }
.btn-rapido     { background:rgba(168,85,247,.15); color:#c084fc; border-color:rgba(168,85,247,.25); }
.btn-rapido:hover { background:rgba(168,85,247,.28); }

/* ════════════════════════════════
   FORMS
════════════════════════════════ */
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--text2); font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="password"],
select, textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text1);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 15px;   /* 16px mínimo en iOS evita zoom, aquí 15 está bien con meta viewport */
  width: 100%;
  outline: none;
  transition: border .2s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
select option { background: var(--bg2); }
textarea { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.form-check input { width: auto; }
.form-check label { font-size: 14px; color: var(--text2); cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ════════════════════════════════
   FILTERS
════════════════════════════════ */
.filter-bar { padding: 14px 16px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form input  { flex: 1; min-width: 160px; }
.filter-form select { min-width: 130px; width: auto; }

/* ════════════════════════════════
   ALERTS
════════════════════════════════ */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
}
.alert-success { background: rgba(34,197,94,.12);  color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.alert-danger  { background: rgba(239,68,68,.12);  color: #f87171; border: 1px solid rgba(239,68,68,.2); }

/* ════════════════════════════════
   MODALS
════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 16px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow);
  animation: slideUp .2s;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 680px; }

@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg1);
  z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 18px; padding: 4px 8px;
  border-radius: 6px; transition: .15s; flex-shrink: 0;
}
.modal-close:hover { background: var(--bg3); color: var(--text1); }

.modal-body   { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════
   DETAIL GRID (modal ver ticket)
════════════════════════════════ */
.detail-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 3px; }
.solucion-box { background:rgba(34,197,94,.07); border:1px solid rgba(34,197,94,.2); border-radius:8px; padding:14px; margin-top:14px; }
.solucion-box .detail-label { color:#4ade80; }
.cerrado-info { font-size:12px; color:var(--text3); margin-top:6px; }
.info-box     { background:rgba(168,85,247,.08); border:1px solid rgba(168,85,247,.2); border-radius:8px; padding:10px 14px; font-size:13px; color:#c084fc; margin-bottom:16px; }

/* ════════════════════════════════
   LOGIN
════════════════════════════════ */
.login-body  { background: var(--bg0); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-wrap  { width: 100%; max-width: 400px; }
.login-card  { background: var(--bg1); border: 1px solid var(--border); border-radius: 16px; padding: 40px 36px; box-shadow: var(--shadow); }
.login-logo  { display: flex; justify-content: center; margin-bottom: 16px; }
.login-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-sub   { text-align: center; color: var(--text3); font-size: 14px; margin-bottom: 28px; }
.login-hint  { text-align: center; color: var(--text3); font-size: 12px; margin-top: 20px; }

.input-eye         { position: relative; }
.input-eye input   { padding-right: 42px; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text3); cursor: pointer;
  display: flex; align-items: center; padding: 4px;
}

/* ════════════════════════════════
   RESPONSIVE — TABLET 768-1024px
════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ════════════════════════════════
   RESPONSIVE — MÓVIL ≤ 768px
════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar se oculta, se abre como drawer */
  .sidebar {
    transform: translateX(-100%);
    width: min(280px, 85vw);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }

  /* El main ocupa todo el ancho */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding-bottom: var(--bottomnav-h); /* espacio para bottom nav */
  }

  /* Topbar más compacta */
  .topbar { padding: 0 16px; height: 52px; }
  .menu-toggle { display: flex; }

  /* Bottom nav visible */
  .bottom-nav { display: flex; }

  /* Sidebar user oculto en móvil (logout en bottom nav) */
  .sidebar-user { display: none; }

  /* Page body más estrecho */
  .page-body { padding: 16px; }

  /* Stats: 2 columnas en móvil */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-card  { padding: 14px 12px; gap: 10px; }
  .stat-value { font-size: 22px; }
  .stat-icon  { width: 36px; height: 36px; border-radius: 8px; }

  /* Tabla → oculta, cards → visibles */
  .ticket-table-wrap { display: none !important; }
  .ticket-cards      { display: flex !important; }

  /* Tabla normal en páginas como tickets.php: mostrar pero scrolleable */
  .card .table-wrap { overflow-x: auto; }

  /* Formularios: una columna */
  .form-row { grid-template-columns: 1fr; gap: 0; }

  /* Filtros: columna */
  .filter-form { flex-direction: column; }
  .filter-form input,
  .filter-form select { min-width: auto; width: 100%; }

  /* Modal ocupa más pantalla */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal {
    border-radius: 18px 18px 0 0;
    max-width: 100%;
    max-height: 92vh;
    animation: slideUpMobile .25s;
  }
  @keyframes slideUpMobile { from { transform: translateY(100%) } to { transform: none } }

  /* Detail grid 1 columna */
  .detail-grid { grid-template-columns: 1fr; }

  /* Modal footer: columna en muy pequeño */
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Page header vertical */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Botones de la tabla de tickets */
  .td-actions { flex-wrap: wrap; gap: 4px; }
  .td-actions .btn { font-size: 12px; padding: 5px 10px; }

  /* Login más compacto */
  .login-card { padding: 28px 20px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 20px; }
  .ticket-card-actions { grid-template-columns: 1fr; }
}

/* ════════════════════════════════
   MODO CLARO
════════════════════════════════ */
body.light {
  --bg0:    #f1f5f9;
  --bg1:    #ffffff;
  --bg2:    #f8fafc;
  --bg3:    #e2e8f0;
  --text1:  #0f172a;
  --text2:  #475569;
  --text3:  #94a3b8;
  --border: rgba(0,0,0,0.09);
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}
body.light .sidebar          { background: #ffffff; }
body.light .topbar           { background: #f1f5f9; }
body.light .bottom-nav       { background: #ffffff; }
body.light .modal            { background: #ffffff; }
body.light .modal-header     { background: #ffffff; }
body.light input[type="text"],
body.light input[type="email"],
body.light input[type="password"],
body.light select,
body.light textarea           { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }
body.light .nav-item:hover    { background: #f1f5f9; }
body.light .nav-item.active   { background: rgba(59,130,246,.1); }
body.light .data-table tbody tr:hover { background: #f8fafc; }
body.light .badge-cat         { background: #e2e8f0; color: #475569; }
body.light .sidebar-overlay.active { background: rgba(0,0,0,.3); }

/* Botón toggle tema */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg3); color: var(--text1); }
