/* ============================================================
   IMPERIO REAL — Estilos
   Tema: Oscuro imperial con oro y bordeaux
   Fuentes: Cinzel (títulos) + Outfit (cuerpo)
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --bg-deep:      #08090d;
  --bg-base:      #0f1117;
  --bg-card:      #161b27;
  --bg-card-alt:  #1c2336;
  --bg-input:     #1a2030;
  --border:       rgba(180,150,80,.18);
  --border-strong:rgba(180,150,80,.35);

  --gold:         #c9a84c;
  --gold-light:   #e2c06e;
  --gold-dim:     rgba(201,168,76,.15);

  --text-primary: #e8e0d0;
  --text-secondary:#9e9585;
  --text-muted:   #5e5a52;

  --green:        #22c55e;
  --yellow:       #eab308;
  --red:          #ef4444;
  --blue:         #3b82f6;
  --purple:       #a855f7;

  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,.5);

  --font-display: 'Cinzel', serif;
  --font-body:    'Outfit', sans-serif;
  --transition:   .2s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-crown {
  font-size: 28px;
  color: var(--gold);
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(201,168,76,.5));
}

.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-main {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: .05em;
}
.logo-sub {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  display: none;
}

/* Nav */
.nav-list { flex: 1; padding: 12px 0; list-style: none; overflow-y: auto; }
.nav-item  { margin: 2px 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--gold-dim);
  border-color: var(--border);
}

.nav-item.active .nav-link {
  color: var(--gold-light);
  background: var(--gold-dim);
  border-color: var(--border-strong);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-label { flex: 1; }

/* Footer sidebar */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1px solid var(--border-strong);
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 18px;
  transition: color var(--transition);
  padding: 4px;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--red); }

/* ── Overlay móvil ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 190;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(15,17,23,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
}

.menu-btn {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 20px; cursor: pointer;
  padding: 4px; display: none;
  transition: color var(--transition);
}
.menu-btn:hover { color: var(--gold); }

.page-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: .03em;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-notif {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 6px;
  transition: color var(--transition);
}
.btn-notif:hover { color: var(--gold); }

/* Content Area */
.content-area { padding: 24px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── KPI Boxes ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.kpi-box:hover { border-color: var(--border-strong); }
.kpi-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-box.verde::before   { background: var(--green); }
.kpi-box.amarillo::before{ background: var(--yellow); }
.kpi-box.rojo::before    { background: var(--red); }
.kpi-box.total::before   { background: var(--gold); }

.kpi-num  { font-family: var(--font-display); font-size: 36px; color: var(--text-primary); line-height: 1; }
.kpi-label{ font-size: 12px; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; }
.kpi-icon { position: absolute; top: 16px; right: 16px; font-size: 24px; opacity: .3; }

/* ── Semáforo ─────────────────────────────────────────────── */
.semaforo-verde   { color: var(--green); }
.semaforo-amarillo{ color: var(--yellow); }
.semaforo-rojo    { color: var(--red); }

.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-verde    { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot-amarillo { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot-rojo     { background: var(--red);    box-shadow: 0 0 6px var(--red);  }

/* ── Tabla ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-baja    { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-media   { background: rgba(234,179,8,.15);  color: var(--yellow); }
.badge-alta    { background: rgba(249,115,22,.15); color: #f97316; }
.badge-critica { background: rgba(239,68,68,.15);  color: var(--red); }

.badge-pendiente  { background: rgba(156,163,175,.1); color: #9ca3af; }
.badge-en_proceso { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-completada { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-cancelada  { background: rgba(239,68,68,.1);   color: var(--red); }

/* ── Formularios ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--gold); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control option { background: var(--bg-card); }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Botones ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gold);
  color: #080808;
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--gold-dim); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: var(--red);
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; }
.btn-icon { padding: 7px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 16px; color: var(--gold);
  letter-spacing: .04em;
}
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 20px;
  cursor: pointer; transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body   { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── Login ────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(201,168,76,.12) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 100% 100%, rgba(201,168,76,.06) 0%, transparent 70%);
}

.login-card {
  position: relative; z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}
.login-crown {
  font-size: 52px;
  color: var(--gold);
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 16px rgba(201,168,76,.5));
}
.login-title {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700;
  color: var(--gold-light);
  letter-spacing: .06em;
}
.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .2em;
  text-transform: uppercase;
  margin-top: 4px;
}

.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
  border: 1px solid;
}
.alert-success { background: rgba(34,197,94,.1);  color: #86efac; border-color: rgba(34,197,94,.2); }
.alert-error   { background: rgba(239,68,68,.1);  color: #fca5a5; border-color: rgba(239,68,68,.2); }
.alert-warning { background: rgba(234,179,8,.1);  color: #fde68a; border-color: rgba(234,179,8,.2); }
.alert-info    { background: rgba(59,130,246,.1); color: #93c5fd; border-color: rgba(59,130,246,.2);}

/* ── Grid / Layout helpers ────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.flex    { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10  { gap: 10px; }
.mb-16   { margin-bottom: 16px; }
.mb-24   { margin-bottom: 24px; }
.mt-16   { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ── Upload zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-input);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--gold);
  background: var(--gold-dim);
}
.upload-zone-icon { font-size: 32px; margin-bottom: 8px; opacity: .5; }
.upload-zone-text { font-size: 13px; color: var(--text-muted); }
.upload-zone input[type=file] { display: none; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle { display: block; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-btn { display: block; }
  .content-area { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}

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

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,.5); }
