:root {
  --bg: #0d0b14;
  --panel: #17141f;
  --panel-2: #1e1a2a;
  --border: #2c273a;
  --purple: #8b3dff;
  --purple-dark: #6b28cc;
  --yellow: #ffd60a;
  --text: #f4f2f8;
  --text-dim: #a79fc0;
  --green: #2ecc71;
  --red: #ff4d6d;
  --orange: #ffa62b;
  --lilac: #c77dff;
  --lilac-glow: 0 0 8px rgba(199,125,255,.55);
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1b1330 0%, var(--bg) 60%);
}
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 32px; width: 100%; max-width: 380px; padding: 24px; }
.login-brand { text-align: center; }
.logo-mark {
  margin: 0 auto 12px;
}
.logo-mark img { display: block; height: 64px; width: auto; margin: 0 auto; }
.login-brand h1 { font-size: 22px; margin: 0; }
.login-brand h1 span { color: var(--yellow); }
.login-brand p { color: var(--text-dim); font-size: 13px; margin: 6px 0 0; }
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; width: 100%;
}
.login-card h2 { margin: 0 0 18px; font-size: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 13px; color: var(--text-dim); margin-top: 10px; }
.login-card input {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--purple); }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-block { width: 100%; justify-content: center; margin-top: 18px; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-yellow { background: var(--yellow); color: #1a1a1a; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-green { background: var(--green); color: #06210f; }
.btn-red { background: var(--red); color: #2a0510; }
.btn-orange { background: var(--orange); color: #2a1600; }
.btn-lilac { background: var(--lilac); color: #22052e; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- App shell ---------- */
/* La cabecera (logo + usuario) y la franja de pestañas son "chrome" fijo:
   siempre oscuras, sin importar el tema elegido — solo el contenido de
   .app-main hacia abajo responde al interruptor claro/oscuro. Por eso acá
   usamos colores fijos en vez de las variables de tema. */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #17141f;
  position: sticky; top: 0; z-index: 10;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #f4f2f8; }
.app-header .brand .logo-mark img { height: 40px; width: auto; }
.app-header .brand .logo-mark { margin: 0; }
.app-header .user-box { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #f4f2f8; }
.app-header .role-pill {
  background: #1e1a2a; border: 1px solid #2c273a; padding: 4px 10px; border-radius: 100px;
  color: #ffd60a; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
}
.app-header .btn-outline { color: #f4f2f8; border-color: #2c273a; }
.app-main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.nav-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.nav-tabs a {
  padding: 8px 14px; border-radius: 100px; background: #17141f; border: 1px solid #2c273a;
  font-size: 13px; text-decoration: none; color: #a79fc0;
}
.nav-tabs a.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.nav-tabs-strip { background: #2a2a30; border-bottom: 1px solid #2c273a; padding: 14px 24px; }

/* ---------- Grid / Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.card h3 {
  margin: 0 0 4px; font-size: 15px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--lilac); text-shadow: var(--lilac-glow);
}
.card .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }

.stat-card { border-top: 3px solid var(--purple); }
.stat-card .num { font-size: 30px; font-weight: 800; }
.stat-card .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }

/* ---------- Machine cards ---------- */
.machine-card { border-top: 3px solid var(--green); }
.machine-card.ocupado { border-top-color: var(--red); background: #241016; }
.machine-card.mantenimiento { border-top-color: var(--orange); background: #241a0c; }
.machine-card.reservado { border-top-color: var(--lilac); background: #1e1428; }
.machine-card .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.badge { padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; }
.badge-disponible { background: rgba(46,204,113,.15); color: var(--green); }
.badge-ocupado { background: rgba(255,77,109,.15); color: var(--red); }
.badge-mantenimiento { background: rgba(255,166,43,.15); color: var(--orange); }
.badge-reservado { background: rgba(199,125,255,.18); color: var(--lilac); }
.machine-card .actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Session / visita cards ---------- */
.visita-card { border-top: 3px solid var(--purple); }
.visita-card .timer { font-size: 30px; font-weight: 800; }
.visita-card .timer.tolerancia { color: var(--red); }
.progress { height: 6px; background: var(--panel-2); border-radius: 100px; overflow: hidden; margin: 10px 0; }
.progress .fill { height: 100%; background: var(--purple); }
.progress .fill.tolerancia { background: var(--red); }
.visita-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; color: var(--text-dim); margin: 10px 0; }
.visita-meta b { color: var(--text); display: block; font-size: 13px; }
.visita-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px; font-family: var(--font);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--purple); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-error { background: rgba(255,77,109,.12); color: #ff8fa3; border: 1px solid rgba(255,77,109,.3); }
.alert-success { background: rgba(46,204,113,.12); color: #7ee2a8; border: 1px solid rgba(46,204,113,.3); }
.alert-empty { color: var(--text-dim); text-align: center; padding: 30px; font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Cola de espera (clicable) ---------- */
.cola-list { display: flex; flex-direction: column; gap: 8px; }
.cola-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; cursor: pointer; transition: border-color .15s;
}
.cola-row:hover { border-color: var(--purple); }
.cola-row-main { display: flex; flex-direction: column; gap: 2px; }
.cola-row-main b { font-size: 14px; }
.cola-row-main .sub { font-size: 12px; color: var(--text-dim); margin: 0; }
.cola-row-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ---------- Autocompletado ---------- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  margin-top: 4px; max-height: 220px; overflow-y: auto;
}
.autocomplete-item { padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.autocomplete-item:hover { background: var(--panel); }
.autocomplete-item b { font-size: 13px; }
.autocomplete-item span { font-size: 11px; color: var(--text-dim); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 420px;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.modal-header h3 { margin: 0; text-transform: none; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; }

/* ---------- Alertas flotantes (toast) ---------- */
#alerta-flotante { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: 320px; max-width: calc(100vw - 32px); }
.alerta-toast { box-shadow: 0 4px 16px rgba(0,0,0,.4); animation: toast-in .15s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Botón flotante volver arriba ---------- */
.btn-flotante {
  position: fixed; bottom: 24px; right: 24px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--purple); color: #fff; border: none; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); z-index: 90; transition: opacity .2s, transform .2s;
}
.btn-flotante:hover { transform: translateY(-2px); }

/* ---------- Tema claro (global, activado con [data-theme="light"] en <html>) ---------- */
:root[data-theme="light"] {
  --bg: #f3f1f8;
  --panel: #ffffff;
  --panel-2: #f1eef7;
  --border: #e0dcea;
  --text: #1c1830;
  --text-dim: #726a82;
}
[data-theme="light"] .machine-card.ocupado { background: #ffe4ea; }
[data-theme="light"] .machine-card.mantenimiento { background: #fff2df; }
[data-theme="light"] .machine-card.reservado { background: #f3e6ff; }

/* El brillo neon de los titulos es para fondo oscuro; en el tema claro
   se ve mal (demasiado intenso). Aca usamos un morado normal, sin resplandor,
   del mismo tono que los bordes superiores de las tarjetas (stat-card, etc). */
[data-theme="light"] .card h3 {
  color: var(--purple-dark);
  text-shadow: none;
}

/* ---------- Botón de cambiar tema ---------- */
.theme-toggle {
  background: #1e1a2a; border: 1px solid #2c273a; color: #f4f2f8;
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; font-size: 15px; padding: 0;
}
.theme-toggle:hover { border-color: var(--purple); }
