/* ============================================================================
   IBO 4K ULTRA Panel — Sistema de diseño iOS Glass (identidad ROJA)
   Variables, tarjetas glass, sidebar, topbar, botones, inputs, tablas,
   badges, toasts, modales y responsive. Coherente en TODAS las páginas.
   ============================================================================ */

:root {
  /* Marca (rojo IBO 4K ULTRA) */
  --brand:        #f44336;
  --brand-dark:   #b71c1c;
  --brand-light:  #ff7961;

  /* Fondo */
  --bg:           #0b0b0d;
  --bg-radial:    #1a0a0a;

  /* Glass */
  --glass:        rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur:   18px;

  /* Texto */
  --text:         #ECECEC;
  --text-dim:     #9aa0a6;

  /* Estado */
  --ok:           #34c759;
  --ok-bg:        rgba(52, 199, 89, 0.16);
  --danger:       #ff453a;
  --danger-bg:    rgba(255, 69, 58, 0.16);
  --warn:         #ffd60a;
  --warn-bg:      rgba(255, 214, 10, 0.16);

  /* Geometría */
  --radius:       18px;
  --radius-sm:    12px;
  --shadow:       0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-soft:  0 6px 18px rgba(0, 0, 0, 0.30);
  --speed:        150ms;

  --sidebar-w:    250px;
}

/* ───────────── Reset / base ───────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 700px at 15% -10%, var(--bg-radial) 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 10%, rgba(183, 28, 28, 0.18) 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand-light); text-decoration: none; }
a:hover { color: var(--brand); }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 600; letter-spacing: -0.01em; }

/* Scrollbar coherente */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(244,67,54,.45); }

/* ───────────── Tarjeta glass (base reutilizable) ───────────── */
.glass,
.card {
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card { padding: 22px; }
.card h2, .card h3 { margin-top: 0; }
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
.muted { color: var(--text-dim); }
.text-center { text-align: center; }

/* ============================================================================
   LAYOUT: sidebar + topbar + main
   ============================================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ───────────── Sidebar glass ───────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-right: 1px solid var(--glass-border);
  transition: transform var(--speed) ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--glass-border);
}
.sidebar-brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 4px 14px rgba(244, 67, 54, 0.45);
}
.sidebar-brand .name { font-weight: 700; font-size: .98rem; }
.sidebar-brand .name small { display: block; color: var(--text-dim); font-weight: 400; font-size: .72rem; }

.nav-section {
  color: var(--text-dim);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 12px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  transition: background var(--speed), color var(--speed);
}
.nav-item .ico { width: 20px; text-align: center; font-size: 1rem; opacity: .9; }
.nav-item:hover { background: var(--glass-strong); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(244, 67, 54, 0.26), rgba(183, 28, 28, 0.12));
  border: 1px solid rgba(244, 67, 54, 0.40);
  color: #fff;
}
.nav-item.active .ico { color: var(--brand-light); }

/* Iconos SVG profesionales (Lucide). Heredan color via currentColor. */
.ic { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.18em; flex: 0 0 auto; }
.nav-item .ico { display: grid; place-items: center; }
.nav-item .ico .ic { width: 19px; height: 19px; }
.sidebar-brand .logo .ic { width: 19px; height: 19px; color: #fff; }
.topbar-user { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; }
.topbar-user .ic { width: 16px; height: 16px; }
.menu-toggle .ic { width: 22px; height: 22px; }
.btn .ic { width: 16px; height: 16px; vertical-align: -0.18em; margin-right: 2px; }
.stat .stat-ico .ic, .qa-btn .ic, .card-ico .ic { width: 22px; height: 22px; }

.sidebar-foot { margin-top: auto; padding-top: 12px; }

/* Overlay para móvil */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 35;
  display: none;
}
.sidebar-overlay.show { display: block; }

/* ───────────── Contenedor principal ───────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ───────────── Topbar glass ───────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(11, 11, 13, 0.55);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--glass-border);
}
.topbar .page-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.topbar .spacer { flex: 1; }

.menu-toggle {
  display: none;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
}

.content {
  padding: 24px;
  flex: 1;
}

/* ───────────── Grilla de stats ───────────── */
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.stat {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat .stat-ico {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, rgba(244,67,54,.28), rgba(183,28,28,.18));
  border: 1px solid rgba(244,67,54,.32);
}
.stat .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat .stat-label { color: var(--text-dim); font-size: .82rem; margin-top: 4px; }

/* ============================================================================
   BOTONES
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--speed), box-shadow var(--speed), background var(--speed), border-color var(--speed);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 6px 18px rgba(244, 67, 54, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 8px 26px rgba(244, 67, 54, 0.55);
  color: #fff;
}

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  backdrop-filter: blur(10px);
}
.btn-secondary:hover { background: var(--glass-strong); color: var(--text); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c1271e);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 69, 58, 0.30);
}
.btn-danger:hover { box-shadow: 0 8px 24px rgba(255, 69, 58, 0.5); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ============================================================================
   INPUTS / FORMULARIOS
   ============================================================================ */
.field { margin-bottom: 16px; }
.field label,
.form-label {
  display: block;
  font-size: .82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

.input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: .92rem;
  font-family: inherit;
  transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
  backdrop-filter: blur(8px);
}
.input::placeholder,
input::placeholder,
textarea::placeholder { color: var(--text-dim); }

.input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.22);
}

select option { background: #16161a; color: var(--text); }

.input-group { display: flex; gap: 10px; flex-wrap: wrap; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 180px; }

/* ============================================================================
   TABLAS GLASS
   ============================================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}
table.glass-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table.glass-table thead th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
table.glass-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}
table.glass-table tbody tr { transition: background var(--speed); }
table.glass-table tbody tr:hover { background: var(--glass); }
table.glass-table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 8px; }

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-ok      { background: var(--ok-bg);     color: var(--ok);     border-color: rgba(52,199,89,.35); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); border-color: rgba(255,69,58,.35); }
.badge-warn    { background: var(--warn-bg);   color: var(--warn);   border-color: rgba(255,214,10,.35); }
.badge-brand   { background: rgba(244,67,54,.18); color: var(--brand-light); border-color: rgba(244,67,54,.4); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ============================================================================
   ALERTAS INLINE
   ============================================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  margin-bottom: 16px;
  font-size: .88rem;
}
.alert-error   { border-color: rgba(255,69,58,.4);  background: var(--danger-bg); color: #ffd9d6; }
.alert-success { border-color: rgba(52,199,89,.4);  background: var(--ok-bg);     color: #d6ffe1; }
.alert-info    { border-color: rgba(244,67,54,.35); }

/* ============================================================================
   TOASTS
   ============================================================================ */
.toast-zone {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  font-size: .88rem;
  animation: toast-in var(--speed) ease;
}
.toast.hide { animation: toast-out var(--speed) ease forwards; }
.toast .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--brand); }
.toast.success .bar { background: var(--ok); }
.toast.error   .bar { background: var(--danger); }
.toast.warning .bar { background: var(--warn); }
.toast .close { margin-left: auto; cursor: pointer; color: var(--text-dim); background: none; border: none; font-size: 1.1rem; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

/* ============================================================================
   MODALES GLASS
   ============================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: modal-in var(--speed) ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.4rem; cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ============================================================================
   LOGIN (card centrada)
   ============================================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  text-align: center;
}
.auth-card .logo-big {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 30px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 8px 24px rgba(244, 67, 54, 0.5);
}
.auth-card h1 { font-size: 1.3rem; }
.auth-card .sub { color: var(--text-dim); font-size: .85rem; margin-bottom: 24px; }
.auth-card form { text-align: left; }

/* utilidades */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap { gap: 12px; }
.between { justify-content: space-between; align-items: center; }
.wrap-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; place-items: center; }
}

@media (max-width: 520px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .card { padding: 18px; }
}
