/* ── Variables ────────────────────────────────────────────────────── */
:root {
  --sidebar-width: 230px;
  --sidebar-bg: #1a1f2e;
  --sidebar-brand-bg: #141824;
  --sidebar-link: rgba(255,255,255,.65);
  --sidebar-link-hover: rgba(255,255,255,.9);
  --sidebar-link-active-bg: rgba(255,255,255,.1);
  --sidebar-link-active: #fff;
  --sidebar-icon-color: rgba(255,255,255,.45);
  --sidebar-separator: rgba(255,255,255,.08);
  --topbar-height: 0px;
  --content-bg: #f5f6fa;
  --card-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
}

[data-bs-theme="dark"] {
  --content-bg: #0f1117;
  --card-shadow: 0 1px 4px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.05);
}

/* ── Layout ───────────────────────────────────────────────────────── */
body {
  background: var(--content-bg) !important;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1030;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  background: var(--sidebar-brand-bg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  letter-spacing: .01em;
  flex-shrink: 0;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-separator);
}
.sidebar-brand .bi { font-size: 1.3rem; color: #6ea8fe; }

.sidebar-section {
  padding: .6rem .75rem .25rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .52rem 1.1rem;
  color: var(--sidebar-link);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: .4rem;
  margin: 1px .5rem;
  transition: background .15s, color .15s;
}
.sidebar-link .bi {
  font-size: 1rem;
  color: var(--sidebar-icon-color);
  flex-shrink: 0;
  transition: color .15s;
  width: 1.1rem;
  text-align: center;
}
.sidebar-link:hover {
  background: var(--sidebar-link-active-bg);
  color: var(--sidebar-link-hover);
}
.sidebar-link:hover .bi { color: rgba(255,255,255,.75); }
.sidebar-link.active {
  background: rgba(110,168,254,.18);
  color: #fff;
}
.sidebar-link.active .bi { color: #6ea8fe; }

.sidebar-sep {
  border-color: var(--sidebar-separator) !important;
  margin: .4rem .75rem;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-separator);
  padding: .75rem 1rem;
  margin-top: auto;
  flex-shrink: 0;
}
.sidebar-user {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
  line-height: 1.3;
  margin-bottom: .6rem;
}
.sidebar-user strong {
  display: block;
  color: rgba(255,255,255,.85);
  font-size: .82rem;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.btn-theme-toggle {
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.65);
  border-radius: .35rem;
  padding: .3rem .55rem;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  line-height: 1;
}
.btn-theme-toggle:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.btn-logout {
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.65);
  border-radius: .35rem;
  padding: .3rem .55rem;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  line-height: 1;
}
.btn-logout:hover {
  background: rgba(220,53,69,.3);
  color: #ff8080;
}

/* ── Mobile topbar ────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 1020;
  padding: .6rem 1rem;
  align-items: center;
  gap: .75rem;
}
.mobile-topbar .brand {
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  flex-grow: 1;
}
.btn-menu {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: .2rem .4rem;
}

@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .mobile-topbar {
    display: flex;
  }
}

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

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

/* ── Breadcrumb ───────────────────────────────────────────────────── */
.app-breadcrumb {
  background: transparent;
  padding: .6rem 1.5rem;
  border-bottom: 1px solid var(--bs-border-color);
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  box-shadow: var(--card-shadow) !important;
  border-radius: .6rem !important;
}
.card-header {
  border-bottom: 1px solid var(--bs-border-color) !important;
  background: transparent !important;
  padding: .75rem 1rem;
}
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--bs-border-color) !important;
}

/* ── Stat cards ───────────────────────────────────────────────────── */
.stat-card {
  border-radius: .6rem;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-card .stat-icon {
  font-size: 1.75rem;
  opacity: .85;
  flex-shrink: 0;
}
.stat-card .stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.stat-card .stat-lbl {
  font-size: .78rem;
  opacity: .7;
  margin-top: .2rem;
}

/* ── Tables ───────────────────────────────────────────────────────── */
.table th {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--bs-secondary-color);
  border-bottom-width: 1px !important;
}
.table td { font-size: .875rem; }
.table-hover > tbody > tr:hover > * {
  background-color: rgba(var(--bs-primary-rgb), .04);
}

/* ── Misc ─────────────────────────────────────────────────────────── */
.font-monospace { font-size: .85em; }
.badge { font-weight: 500; letter-spacing: .01em; }
.btn-sm { font-size: .8rem; }

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