/* ============================================================
   Admin Dashboard — Custom Styles
   Bootstrap 5 + CSS Custom Properties for theming
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 70px;
  --navbar-height: 60px;
  --sidebar-bg: #1a1a2e;
  --sidebar-border: rgba(255,255,255,.07);
  --brand-color: #6366f1;
  --brand-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
}

[data-bs-theme="light"] {
  --sidebar-bg: #1a1a2e;
  --page-bg: #f0f2f5;
  --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
}
[data-bs-theme="dark"] {
  --page-bg: #0f0f1a;
  --card-shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
}

/* ── Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  background: var(--brand-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

.auth-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-wrapper { position: relative; z-index: 1; width: 100%; max-width: 440px; }

.auth-card {
  border: none;
  border-radius: 16px;
  overflow: hidden;
}

[data-bs-theme="dark"] .auth-card {
  background: #1e1e30;
  border: 1px solid rgba(255,255,255,.08);
}

.auth-footer {
  position: relative; z-index: 1;
  color: rgba(255,255,255,.6);
  padding: 1rem;
  margin-top: auto;
}

.theme-toggle-wrap {
  position: fixed; top: 1rem; right: 1rem; z-index: 100;
}

/* ── Brand icon ──────────────────────────────────────────── */
.brand-icon-lg {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--brand-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem;
  box-shadow: 0 8px 24px rgba(99,102,241,.4);
}

/* ── Password strength ───────────────────────────────────── */
.password-strength-bar {
  height: 4px; border-radius: 2px;
  background: var(--bs-secondary-bg);
  overflow: hidden;
}
.password-strength-bar > div {
  height: 100%; width: 0; border-radius: 2px;
  transition: width .3s, background .3s;
}

/* ── Dashboard Layout ────────────────────────────────────── */
.dash-body {
  background: var(--page-bg);
  min-height: 100vh;
}

/* 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: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: var(--navbar-height);
}

.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem; flex-shrink: 0;
}

.brand-text { color: #fff; font-weight: 700; font-size: .95rem; }

.sidebar-nav {
  flex: 1; padding: .75rem .75rem 0;
  display: flex; flex-direction: column; gap: 2px;
}

.sidebar-nav .nav-link {
  color: rgba(255,255,255,.65);
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem;
  border-radius: 10px;
  font-size: .875rem; font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(99,102,241,.25); color: #a5b4fc; }
.sidebar-nav .nav-link i { font-size: 1rem; flex-shrink: 0; }

.nav-divider { height: 1px; background: var(--sidebar-border); margin: .5rem 0; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}

.sidebar-close { color: rgba(255,255,255,.6); border-color: transparent; }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 199; display: none;
}
.sidebar-overlay.show { display: block; }

/* Main wrapper */
.dash-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s ease;
}

/* Top navbar */
.dash-navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--navbar-height);
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  backdrop-filter: blur(8px);
}

.dash-content { flex: 1; padding: 1.5rem; }
.dash-footer { padding: .75rem 1.5rem; border-top: 1px solid var(--bs-border-color); }

/* ── Nav search ──────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); font-size: .875rem; }
.search-input { padding-left: 2rem; border-radius: 8px; font-size: .875rem; width: 220px; }
.search-input:focus { width: 280px; }
.search-input { transition: width .2s ease; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px;
  color: var(--bs-body-color);
  transition: background .15s;
}
.btn-icon:hover { background: var(--bs-secondary-bg); }

/* ── Notifications badge ──────────────────────────────────── */
.notif-badge {
  position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ef4444; color: #fff;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bs-body-bg);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color);
  padding: .875rem 1.25rem;
}
.card-title { font-weight: 600; font-size: .9rem; }

/* ── Stat cards ──────────────────────────────────────────── */
.stat-card .card-body { padding: 1.25rem; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: .75rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-sub   { font-size: .75rem; margin-top: .25rem; }

/* ── Page header ─────────────────────────────────────────── */
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 0; }

/* ── Activity feed ───────────────────────────────────────── */
.activity-list { max-height: 360px; overflow-y: auto; }
.activity-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; padding-top: 1px; }
.activity-content { flex: 1; min-width: 0; }
.activity-time { flex-shrink: 0; white-space: nowrap; }

/* ── User avatars ────────────────────────────────────────── */
.user-avatar-xs, .user-avatar-sm, .user-avatar-lg {
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-avatar-xs { width: 24px; height: 24px; font-size: .65rem; }
.user-avatar-sm { width: 34px; height: 34px; font-size: .8rem; }
.user-avatar-lg { width: 72px; height: 72px; font-size: 1.75rem; }

/* ── Tables ──────────────────────────────────────────────── */
.table { --bs-table-striped-bg: transparent; font-size: .875rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.table-hover > tbody > tr:hover > * { background-color: var(--bs-secondary-bg); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .02em; }

/* ── Toast container ─────────────────────────────────────── */
#toastContainer {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem; min-width: 280px;
}
.toast-item {
  padding: .75rem 1.1rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  display: flex; align-items: center; gap: .75rem;
  font-size: .875rem; font-weight: 500;
  animation: slideInRight .25s ease;
  color: #fff;
}
.toast-item.success { background: #22c55e; }
.toast-item.danger  { background: #ef4444; }
.toast-item.info    { background: #3b82f6; }
.toast-item.warning { background: #f59e0b; color: #1a1a1a; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar.show { transform: translateX(0); }
  .dash-wrapper { margin-left: 0; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,.35); border-radius: 3px; }

/* ── Form controls ───────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 .2rem rgba(99,102,241,.15);
}
.input-group-text {
  border-radius: 8px 0 0 8px;
  background: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
  border-right: none;
}
.input-group .form-control { border-left: none; }
.input-group .form-control:focus { border-left: 1px solid #6366f1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary { background: var(--brand-gradient); border: none; }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-gradient); filter: brightness(1.1); border: none; }
.btn { border-radius: 8px; font-size: .875rem; font-weight: 500; }
.btn-lg { font-size: .95rem; padding: .65rem 1.5rem; }

/* ── Dark mode overrides ─────────────────────────────────── */
[data-bs-theme="dark"] .card { background: #1e1e30; border-color: rgba(255,255,255,.08); }
[data-bs-theme="dark"] .card-header { border-color: rgba(255,255,255,.08); }
[data-bs-theme="dark"] .table-light { --bs-table-bg: rgba(255,255,255,.04); }
[data-bs-theme="dark"] .dash-navbar { background: rgba(15,15,26,.95); border-color: rgba(255,255,255,.08); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background: #2a2a3d; border-color: rgba(255,255,255,.1); color: #e2e8f0; }
[data-bs-theme="dark"] .input-group-text { background: #2a2a3d; border-color: rgba(255,255,255,.1); }
[data-bs-theme="dark"] .btn-outline-secondary { border-color: rgba(255,255,255,.15); color: #a0aec0; }
[data-bs-theme="dark"] .dropdown-menu { background: #2a2a3d; border-color: rgba(255,255,255,.1); }
[data-bs-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,.07); }
