@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Nunito:wght@400;500;600;700&display=swap');

:root {
  --azul: #1a2e6e;
  --azul-medio: #2545a8;
  --azul-claro: #3a5bd9;
  --verde: #2db84b;
  --verde-oscuro: #1e8f38;
  --naranja: #f47b20;
  --naranja-oscuro: #d4600f;
  --blanco: #ffffff;
  --gris-claro: #f4f6fb;
  --gris: #e2e8f0;
  --gris-texto: #64748b;
  --sombra: 0 4px 20px rgba(26,46,110,0.10);
  --sombra-hover: 0 8px 32px rgba(26,46,110,0.18);
  --radio: 12px;
  --radio-sm: 8px;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: var(--gris-claro);
  color: #1e293b;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 260px;
  background: linear-gradient(180deg, var(--azul) 0%, #0f1c4a 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.sidebar-brand-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  color: white;
  letter-spacing: 0.5px;
}

.sidebar-brand-text span {
  color: var(--naranja);
}

.sidebar-brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: block;
}

.sidebar-user {
  padding: 14px 20px;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--naranja), var(--verde));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 1px 7px;
  border-radius: 20px;
  display: inline-block;
}

.user-role.admin { background: var(--naranja); color: white; }
.user-role.gestor { background: var(--verde); color: white; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  color: white;
  background: rgba(255,255,255,0.07);
  border-left-color: var(--verde);
}

.nav-item.active {
  color: white;
  background: rgba(255,255,255,0.1);
  border-left-color: var(--naranja);
}

.nav-item .nav-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-sub {
  padding-left: 20px;
}

.nav-sub .nav-item {
  font-size: 13px;
  padding: 7px 20px 7px 12px;
  color: rgba(255,255,255,0.55);
}

.nav-sub .nav-item:hover { color: white; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  user-select: none;
}

.nav-group-toggle:hover {
  color: white;
  background: rgba(255,255,255,0.07);
}

.nav-group-toggle.open { color: white; border-left-color: var(--azul-claro); }

.nav-group-toggle .toggle-icon {
  font-size: 12px;
  transition: transform 0.25s;
}

.nav-group-toggle.open .toggle-icon { transform: rotate(90deg); }

.nav-group-content { display: none; }
.nav-group-content.open { display: block; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 16px;
  background: rgba(244,123,32,0.15);
  border: 1px solid rgba(244,123,32,0.3);
  border-radius: var(--radio-sm);
  color: var(--naranja);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--naranja);
  color: white;
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s;
}

.topbar {
  background: white;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 2px solid var(--gris);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.topbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--azul);
  letter-spacing: 0.3px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--azul);
  font-size: 22px;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--azul);
}

.page-header .breadcrumb {
  font-size: 12px;
  color: var(--gris-texto);
  margin-top: 2px;
}

/* ── CARDS ── */
.card {
  background: white;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 2px solid var(--gris);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--azul);
}

.card-body { padding: 24px; }

/* ── STATS DASHBOARD ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radio);
  padding: 20px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.2s, transform 0.2s;
  border-top: 4px solid var(--azul-claro);
}

.stat-card:hover {
  box-shadow: var(--sombra-hover);
  transform: translateY(-2px);
}

.stat-card.naranja { border-top-color: var(--naranja); }
.stat-card.verde { border-top-color: var(--verde); }
.stat-card.azul { border-top-color: var(--azul-claro); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.naranja { background: rgba(244,123,32,0.12); }
.stat-icon.verde { background: rgba(45,184,75,0.12); }
.stat-icon.azul { background: rgba(58,91,217,0.12); }

.stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--azul);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead tr {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 100%);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: white;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gris);
  transition: background 0.15s;
}

tbody tr:hover { background: rgba(58,91,217,0.04); }

tbody td {
  padding: 12px 16px;
  color: #334155;
  vertical-align: middle;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-success { background: rgba(45,184,75,0.12); color: var(--verde-oscuro); }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-warning { background: rgba(244,123,32,0.12); color: var(--naranja-oscuro); }
.badge-info { background: rgba(58,91,217,0.1); color: var(--azul-claro); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radio-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--azul-claro), var(--azul-medio));
  color: white;
  box-shadow: 0 3px 10px rgba(37,69,168,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--azul-medio), var(--azul));
  box-shadow: 0 5px 16px rgba(37,69,168,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, var(--verde), var(--verde-oscuro));
  color: white;
  box-shadow: 0 3px 10px rgba(45,184,75,0.3);
}
.btn-success:hover {
  box-shadow: 0 5px 16px rgba(45,184,75,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-naranja {
  background: linear-gradient(135deg, var(--naranja), var(--naranja-oscuro));
  color: white;
  box-shadow: 0 3px 10px rgba(244,123,32,0.3);
}
.btn-naranja:hover {
  box-shadow: 0 5px 16px rgba(244,123,32,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); color: white; }

.btn-outline {
  background: transparent;
  border: 2px solid var(--azul-claro);
  color: var(--azul-claro);
}
.btn-outline:hover { background: var(--azul-claro); color: white; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px 10px;
}

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

/* ── FORMS ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  font-weight: 700;
  color: var(--azul);
  letter-spacing: 0.3px;
}

.form-control {
  padding: 10px 14px;
  border: 2px solid var(--gris);
  border-radius: var(--radio-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  color: #1e293b;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(58,91,217,0.12);
}

select.form-control { cursor: pointer; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radio-sm);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: rgba(45,184,75,0.1); color: var(--verde-oscuro); border-left: 4px solid var(--verde); }
.alert-danger { background: rgba(239,68,68,0.08); color: #dc2626; border-left: 4px solid #ef4444; }
.alert-warning { background: rgba(244,123,32,0.1); color: var(--naranja-oscuro); border-left: 4px solid var(--naranja); }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--azul) 0%, #0a1535 50%, #0f2240 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-bg-shapes .shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.06;
}

.shape-1 {
  width: 400px; height: 400px;
  background: var(--naranja);
  top: -100px; right: -100px;
}

.shape-2 {
  width: 300px; height: 300px;
  background: var(--verde);
  bottom: -80px; left: -80px;
}

.shape-3 {
  width: 200px; height: 200px;
  background: var(--azul-claro);
  top: 40%; left: 10%;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 80px;
  object-fit: contain;
}

.login-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--azul);
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--gris-texto);
  text-align: center;
  margin-bottom: 28px;
}

.login-form .form-group { margin-bottom: 16px; }

.btn-login {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--azul-claro), var(--azul));
  color: white;
  border: none;
  border-radius: var(--radio-sm);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(37,69,168,0.4);
  margin-top: 8px;
}

.btn-login:hover {
  box-shadow: 0 8px 24px rgba(37,69,168,0.5);
  transform: translateY(-2px);
}

/* ── MODAL CONFIRM ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: white;
  border-radius: var(--radio);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  text-align: center;
}

.modal-icon { font-size: 48px; margin-bottom: 12px; }
.modal-title { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; color: var(--azul); margin-bottom: 8px; }
.modal-text { font-size: 14px; color: var(--gris-texto); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gris-texto);
}

.empty-state .empty-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--azul); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

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

  .hamburger {
    display: block;
  }

  .page-body {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── OVERLAY MOBILE ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.open { display: block; }

/* ── ACCENT LINE ── */
.accent-line {
  height: 4px;
  background: linear-gradient(90deg, var(--naranja), var(--verde), var(--azul-claro));
  border-radius: 2px;
  margin-bottom: 24px;
}

/* ── SCHEMA BADGE ── */
.schema-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.schema-operativo { background: rgba(58,91,217,0.1); color: var(--azul-claro); }
.schema-valoragregado { background: rgba(45,184,75,0.1); color: var(--verde-oscuro); }
.schema-general { background: rgba(244,123,32,0.1); color: var(--naranja-oscuro); }
