/* ===========================================================================
   Facebook Manager - Stylesheet
   Bootstrap 5 base + custom admin layout, dark/light theme, components.
   =========================================================================== */

:root {
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --app-bg: #f4f6fb;
  --app-surface: #ffffff;
  --app-border: #e3e6ee;
  --app-text: #1f2937;
  --app-muted: #6b7280;
  --app-primary: #2563eb;
  --app-primary-rgb: 37, 99, 235;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1d4ed8;
}

html.theme-dark {
  --app-bg: #0b1220;
  --app-surface: #111827;
  --app-border: #1f2937;
  --app-text: #e5e7eb;
  --app-muted: #9ca3af;
  --sidebar-bg: #020617;
  --sidebar-text: #94a3b8;
}

/* ---- Base ---- */
body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: .95rem;
  min-height: 100vh;
}

a { color: var(--app-primary); text-decoration: none; }
a:hover { color: #1d4ed8; }

html.theme-dark a:hover { color: #60a5fa; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar .navbar-brand { font-weight: 600; color: var(--app-text); }
.topbar-search { position: relative; min-width: 280px; }
.topbar-search .bi-search {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--app-muted); pointer-events: none;
}
.topbar-search input {
  padding-left: 34px; border-radius: 999px;
  background: var(--app-bg); border-color: var(--app-border);
  color: var(--app-text);
}
.theme-toggle { color: var(--app-muted); font-size: 1.1rem; }
.theme-toggle:hover { color: var(--app-primary); }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: calc(100vh - var(--topbar-height)); }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.1rem 1.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; gap: .5rem;
  letter-spacing: .3px;
}
.sidebar-brand .bi { color: #60a5fa; }
.sidebar-nav { flex: 1; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .15rem; }
.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: .65rem .9rem;
  border-radius: .5rem;
  display: flex; align-items: center; gap: .75rem;
  font-size: .92rem;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}
.sidebar-nav .nav-link .bi { font-size: 1.05rem; }
.sidebar-footer { padding: 1rem 1.25rem; color: #64748b; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: var(--topbar-height) 0 0 0;
  background: rgba(0,0,0,.45);
  z-index: 1035;
}
.sidebar-backdrop.show { display: block; }

/* ---- Main ---- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  padding: 0;
}

/* ---- Cards ---- */
.card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); font-weight: 600; }

html.theme-dark .table { color: var(--app-text); }
html.theme-dark .table > :not(caption) > * > * { background-color: transparent; }
html.theme-dark .table-hover > tbody > tr:hover { background-color: rgba(255,255,255,.04); color: var(--app-text); }
html.theme-dark .form-control,
html.theme-dark .form-select {
  background-color: var(--app-bg);
  border-color: var(--app-border);
  color: var(--app-text);
}
html.theme-dark .form-control::placeholder { color: #6b7280; }
html.theme-dark .dropdown-menu { background: var(--app-surface); border-color: var(--app-border); }
html.theme-dark .dropdown-item { color: var(--app-text); }
html.theme-dark .dropdown-item:hover { background: var(--app-bg); }
html.theme-dark .list-group-item { background: var(--app-surface); border-color: var(--app-border); color: var(--app-text); }
html.theme-dark .alert { background: var(--app-surface); border-color: var(--app-border); }

/* ---- Stat cards ---- */
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}

/* ---- Login ---- */
.login-body {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #1d4ed8 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.login-wrapper { width: 100%; max-width: 420px; }
.login-card {
  background: #fff;
  border-radius: 1rem;
  padding: 2.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .bi { font-size: 2.5rem; color: var(--app-primary); }
.login-brand h1 { font-size: 1.5rem; font-weight: 700; margin: .5rem 0 .25rem; }
.login-hint {
  margin-top: 1.25rem; padding: .75rem 1rem;
  background: #f1f5f9; border-radius: .5rem;
  font-size: .85rem; color: #475569; text-align: center;
}

/* ---- Badges / buttons ---- */
.badge { font-weight: 500; }
.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg: #1e40af;
}

/* ---- Responsive ---- */
.sidebar-toggle { color: var(--app-muted); text-decoration: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .topbar-search { display: none; }
}

/* ---- Loading spinner ---- */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.spinner-overlay.show { display: flex; }
html.theme-dark .spinner-overlay { background: rgba(11,18,32,.6); }

/* ---- Toast container ---- */
.toast-container { z-index: 2050; }
