/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --sidebar-bg: #1a1f2e;
  --sidebar-hover: #2d3548;
  --sidebar-active: #3b5bdb;
  --sidebar-text: #c1c8d4;
  --sidebar-text-muted: #6c7a93;
  --topnav-height: 56px;
  --topnav-bg: #ffffff;
  --body-bg: #f0f2f5;
  --card-shadow: 0 2px 12px rgba(0,0,0,.07);
  --primary: #3b5bdb;
  --success: #2f9e44;
  --danger: #e03131;
  --warning: #f08c00;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--body-bg); }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.3s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-hover) transparent;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.sidebar-brand i { font-size: 1.3rem; color: var(--sidebar-active); }

.sidebar-menu {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.sidebar-menu .nav-item { margin: 1px 8px; }

.sidebar-link {
  color: var(--sidebar-text) !important;
  border-radius: 8px;
  padding: .6rem .85rem !important;
  font-size: .88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: background .18s, color .18s;
  text-decoration: none;
}

.sidebar-link:hover { background: var(--sidebar-hover); color: #fff !important; }
.sidebar-link.active { background: var(--sidebar-active) !important; color: #fff !important; }

.sidebar-link .chevron {
  transition: transform .25s;
  font-size: .75rem;
}

.sidebar-link[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.submenu { padding-left: .5rem; }

.sidebar-sublink {
  color: var(--sidebar-text-muted) !important;
  border-radius: 8px;
  padding: .45rem .85rem !important;
  font-size: .83rem;
  display: flex;
  align-items: center;
  transition: background .18s, color .18s;
  text-decoration: none;
}

.sidebar-sublink:hover { background: var(--sidebar-hover); color: var(--sidebar-text) !important; }
.sidebar-sublink.active { color: #fff !important; background: rgba(59,91,219,.3) !important; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: .75rem; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #c1c8d4; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-text-muted); font-size: .72rem; }

/* ── Topnav ────────────────────────────────────────────────────────────────── */
.topnav {
  height: var(--topnav-height);
  background: var(--topnav-bg);
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topnav-left, .topnav-right { display: flex; align-items: center; gap: .5rem; }

.topnav-toggle {
  border: none;
  background: transparent;
  color: #6c757d;
  padding: .4rem .5rem;
  border-radius: 8px;
  cursor: pointer;
}

.topnav-toggle:hover { background: #f0f2f5; color: #1a1f2e; }

.topnav-user {
  border: 1px solid #dee2e6;
  background: transparent;
  border-radius: 20px;
  padding: .3rem .85rem;
  color: #495057;
  font-size: .875rem;
}

.topnav-user:hover { background: #f0f2f5; }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Sidebar overlay (mobile) ──────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1030;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid #e9ecef;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
  border-radius: 12px 12px 0 0 !important;
  padding: 1rem 1.25rem;
  font-weight: 600;
}

/* ── Stat cards (dashboard) ────────────────────────────────────────────────── */
.stat-card {
  border-radius: 14px;
  border: none;
  box-shadow: var(--card-shadow);
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-card { border-radius: 12px; overflow: hidden; }
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table-hover tbody tr:hover { background: #f8f9ff; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #2f4ac4; border-color: #2f4ac4; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-control, .form-select { border-radius: 8px; border-color: #dee2e6; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(59,91,219,.18);
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { border-radius: 6px; font-weight: 500; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h4, .page-header h5 {
  margin: 0;
  font-weight: 700;
  color: #1a1f2e;
}

/* ── Nav tabs ──────────────────────────────────────────────────────────────── */
.nav-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid #dee2e6;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link {
  color: #6c757d;
  border-radius: 8px 8px 0 0;
  font-size: .875rem;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
  padding: .5rem .85rem;
}
.nav-tabs .nav-link:hover {
  color: #495057;
  border-color: #e9ecef #e9ecef transparent;
  background-color: #f8f9fa;
}
.nav-tabs .nav-link.active {
  color: var(--primary);
  font-weight: 600;
  background-color: #fff;
  border-color: #dee2e6 #dee2e6 #fff;
}

/* Tab card: card debajo de nav-tabs, sin borde ni radio superior */
.tab-card {
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  background: #fff;
}
.tab-card .tab-pane.card-body {
  padding: 1.25rem;
}

/* ── Filas clickeables en tablas ────────────────────────────────────────────── */
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover td { background: #f0f4ff; }
tr.row-clickable .cell-no-click { cursor: default; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3548 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
}

/* ── Sidebar collapsed (desktop) ───────────────────────────────────────────── */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary-soft { background: rgba(59,91,219,.1); }
.bg-success-soft { background: rgba(47,158,68,.1); }
.bg-danger-soft { background: rgba(224,49,49,.1); }
.bg-warning-soft { background: rgba(240,140,0,.1); }
.bg-info-soft { background: rgba(16,152,173,.1); }
.rounded-3 { border-radius: .75rem !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.btn-xs { --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .4rem; --bs-btn-font-size: .75rem; }
