/* Unified app shell — used by both public (dark) and admin (light) pages.
   Theme controlled via body class: .theme-dark | .theme-light */

:root {
  --app-sidenav-width: 260px;
  --app-topbar-height: 56px;
}

body.app-shell { margin: 0; }
.app-shell-wrap { display: flex; min-height: 100vh; }

/* ── Sidenav (shared structure) ── */
.app-sidenav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--app-sidenav-width);
  z-index: 1050;
  transform: translateX(-100%);
  transition: transform .25s ease;
  will-change: transform;
  display: flex;
  flex-direction: column;
}
.app-sidenav.is-open { transform: translateX(0); }
.app-sidenav-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 16px 0 0;
}

.app-brand {
  display: flex; align-items: center; justify-content: center;
  padding: 6px 16px 16px;
  text-decoration: none;
}
.app-brand-logo { max-height: 64px; width: auto; }
.app-brand-text { font-size: 1.1rem; letter-spacing: .06em; }

.app-menu { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.app-menu-link, .app-menu-group-toggle, .app-submenu-link {
  display: block; padding: 10px 14px; border-radius: 8px;
  text-decoration: none; font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
}
.app-menu-group { border: 0; padding: 0; margin: 0; }
.app-menu-group-toggle {
  list-style: none;
  position: relative;
  padding-right: 28px;
}
.app-menu-group-toggle::-webkit-details-marker { display: none; }
.app-menu-group-toggle::after {
  content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
  position: absolute; right: 14px; top: 12px; font-size: .65rem;
  transition: transform .2s;
  opacity: .55;
}
.app-menu-group[open] > .app-menu-group-toggle::after { transform: rotate(180deg); }
.app-submenu { padding: 4px 0 6px 14px; display: flex; flex-direction: column; gap: 1px; }
.app-submenu-link { padding: 7px 12px; font-size: .85rem; font-weight: 400; border-left: 2px solid transparent; }

.app-sidenav-footer {
  margin-top: auto; padding: 10px;
  border-top: 1px solid currentColor; border-top-color: rgba(128,128,128,.18);
}
.app-sidenav-user-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
}
.app-sidenav-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex: 0 0 36px; text-decoration: none;
}
.app-sidenav-user-info { flex: 1; min-width: 0; text-decoration: none; }
.app-sidenav-user-name { font-size: .85rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidenav-user-email { font-size: .72rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidenav-logout { padding: 6px 10px; border-radius: 6px; text-decoration: none; }

.app-sidenav-login, .app-sidenav-register {
  display: block; text-align: center;
  padding: 9px 12px; border-radius: 8px;
  text-decoration: none; font-size: .85rem; font-weight: 600;
  margin-bottom: 6px;
}

/* Backdrop for off-canvas */
.app-sidenav-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040;
}
body.app-sidenav-open .app-sidenav-backdrop { display: block; }
body.app-sidenav-open { overflow: hidden; }

/* ── Main area ── */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--app-topbar-height); padding: 0 14px;
}
.app-topbar-left, .app-topbar-right { display: flex; align-items: center; gap: 8px; }
.app-hamburger {
  background: transparent; border: 0; padding: 8px 10px; cursor: pointer;
  font-size: 1.1rem; border-radius: 8px;
}
.app-topbar-title { font-size: .95rem; }
.app-topbar-icon {
  position: relative;
  background: transparent; border: 0; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; text-decoration: none;
}
.app-topbar-badge {
  position: absolute; top: 2px; right: 2px;
  background: #dc2626; color: #fff;
  font-size: .62rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px; line-height: 1.2;
}
.app-topbar-login {
  display: inline-flex; align-items: center;
  padding: 7px 14px; border-radius: 8px;
  text-decoration: none; font-size: .85rem; font-weight: 600;
}

.app-content { flex: 1; }

/* ────────────────────────────────────────── */
/* THEME = LIGHT (admin / tools)              */
/* ────────────────────────────────────────── */
body.app-shell.theme-light { background: #f8fafc; color: #111827; }
body.theme-light .app-sidenav { background: #0a1428; color: #d1d5db; box-shadow: 0 0 20px rgba(0,0,0,.15); }
body.theme-light .app-menu-link, body.theme-light .app-menu-group-toggle { color: #d1d5db; }
body.theme-light .app-submenu-link { color: #9ca3af; }
body.theme-light .app-menu-link:hover, body.theme-light .app-menu-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
body.theme-light .app-submenu-link:hover { background: rgba(255,255,255,.04); color: #fff; }
body.theme-light .app-menu-link.is-active, body.theme-light .app-menu-group.is-active > .app-menu-group-toggle { background: #FBBF24; color: #0a1428; }
body.theme-light .app-submenu-link.is-active { color: #FBBF24; border-left-color: #FBBF24; background: rgba(251,191,36,.07); }
body.theme-light .app-sidenav-footer { border-top-color: rgba(255,255,255,.1); }
body.theme-light .app-sidenav-avatar { background: #FBBF24; color: #0a1428; }
body.theme-light .app-sidenav-user-name { color: #fff; }
body.theme-light .app-sidenav-user-email { color: rgba(255,255,255,.5); }
body.theme-light .app-sidenav-logout { color: rgba(255,255,255,.7); }
body.theme-light .app-sidenav-logout:hover { color: #fff; background: rgba(255,255,255,.08); }
body.theme-light .app-sidenav-login { background: #FBBF24; color: #0a1428; }
body.theme-light .app-sidenav-register { background: rgba(255,255,255,.08); color: #fff; }
body.theme-light .app-topbar { background: #fff; border-bottom: 1px solid #e5e7eb; }
body.theme-light .app-topbar-title { color: #111827; }
body.theme-light .app-hamburger, body.theme-light .app-topbar-icon { color: #374151; }
body.theme-light .app-hamburger:hover, body.theme-light .app-topbar-icon:hover { background: #f3f4f6; }
body.theme-light .app-topbar-login { background: #FBBF24; color: #0a1428; }

/* Light desktop: sidenav fixed visible, content offset */
@media (min-width: 992px) {
  body.theme-light .app-sidenav { transform: translateX(0); }
  body.theme-light .app-main { margin-left: var(--app-sidenav-width); }
  body.theme-light .app-sidenav-backdrop { display: none !important; }
  body.theme-light .app-hamburger { display: none; }
}

/* ────────────────────────────────────────── */
/* THEME = DARK (public / marketing)          */
/* ────────────────────────────────────────── */
body.app-shell.theme-dark { background: #0a1428; color: #e5e7eb; }
body.theme-dark .app-sidenav { background: #0a1428; color: #d1d5db; border-right: 1px solid rgba(201,168,76,.18); }
body.theme-dark .app-menu-link, body.theme-dark .app-menu-group-toggle { color: #d1d5db; }
body.theme-dark .app-submenu-link { color: #9ca3af; }
body.theme-dark .app-menu-link:hover, body.theme-dark .app-menu-group-toggle:hover { background: rgba(201,168,76,.08); color: #fff; }
body.theme-dark .app-submenu-link:hover { background: rgba(201,168,76,.06); color: #fff; }
body.theme-dark .app-menu-link.is-active, body.theme-dark .app-menu-group.is-active > .app-menu-group-toggle { background: #c9a84c; color: #0a1428; }
body.theme-dark .app-submenu-link.is-active { color: #c9a84c; border-left-color: #c9a84c; background: rgba(201,168,76,.07); }
body.theme-dark .app-sidenav-footer { border-top-color: rgba(255,255,255,.08); }
body.theme-dark .app-sidenav-avatar { background: #c9a84c; color: #0a1428; }
body.theme-dark .app-sidenav-user-name { color: #fff; }
body.theme-dark .app-sidenav-user-email { color: rgba(255,255,255,.5); }
body.theme-dark .app-sidenav-logout { color: rgba(255,255,255,.7); }
body.theme-dark .app-sidenav-logout:hover { color: #fff; background: rgba(255,255,255,.06); }
body.theme-dark .app-sidenav-login { background: #c9a84c; color: #0a1428; }
body.theme-dark .app-sidenav-register { background: rgba(255,255,255,.06); color: #fff; border: 1px solid rgba(201,168,76,.3); }
body.theme-dark .app-topbar { background: rgba(10,20,40,.8); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(201,168,76,.12); }
body.theme-dark .app-topbar-title { color: #fff; }
body.theme-dark .app-hamburger, body.theme-dark .app-topbar-icon { color: #d1d5db; }
body.theme-dark .app-hamburger:hover, body.theme-dark .app-topbar-icon:hover { background: rgba(255,255,255,.05); color: #fff; }
body.theme-dark .app-topbar-login { background: #c9a84c; color: #0a1428; }

/* Dark: sidenav always off-canvas — preserves hero full-width design */

/* ── Old layout overrides ── */
/* Hide old site-header on dark theme (now in topbar) */
body.app-shell .site-header,
body.app-shell .wrap > .site-header { display: none !important; }
/* Hide old admin shell elements if accidentally rendered */
body.app-shell .admin-shell,
body.app-shell .admin-sidenav,
body.app-shell .admin-topbar { display: none !important; }

/* Typography enforcement: light theme = dark text on white. */
body.theme-light, body.theme-light h1, body.theme-light h2, body.theme-light h3,
body.theme-light h4, body.theme-light h5, body.theme-light h6,
body.theme-light p, body.theme-light label, body.theme-light a:not(.btn):not(.app-menu-link):not(.app-submenu-link):not(.app-menu-group-toggle):not(.app-sidenav-login):not(.app-sidenav-register):not(.app-sidenav-user-info):not(.app-sidenav-logout):not(.app-sidenav-avatar):not(.app-topbar-login):not(.app-topbar-icon):not(.app-brand) {
  color: #111827;
}
body.theme-light .dash-greeting h1, body.theme-light .text-white {
  color: #111827 !important;
}
/* Form controls on light theme — force white bg + dark text (overrides any dark theme leftovers). */
body.theme-light input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]),
body.theme-light select,
body.theme-light textarea,
body.theme-light .form-control,
body.theme-light .form-select {
  background-color: #fff !important;
  color: #111827 !important;
  border-color: #d1d5db;
}
body.theme-light input::placeholder,
body.theme-light textarea::placeholder { color: #9ca3af !important; opacity: 1; }
body.theme-light .form-control:focus,
body.theme-light .form-select:focus,
body.theme-light input:focus, body.theme-light select:focus, body.theme-light textarea:focus {
  background-color: #fff !important;
  color: #111827 !important;
  border-color: #FBBF24;
  box-shadow: 0 0 0 .2rem rgba(251,191,36,.18);
}
/* Bootstrap cards on light theme — white with subtle border. */
body.theme-light .card {
  background-color: #fff !important;
  color: #111827 !important;
  border-color: #e5e7eb !important;
}
body.theme-light .card-header, body.theme-light .card-footer {
  background-color: #f9fafb !important;
  color: #6b7280 !important;
  border-color: #e5e7eb !important;
}
body.theme-light .card-body { color: #111827 !important; }
body.theme-light .card-body label, body.theme-light .card-body .form-check-label { color: #374151 !important; }
/* Checkbox/radio markers visible */
body.theme-light input[type="checkbox"], body.theme-light input[type="radio"] {
  accent-color: #0a1428;
  background: #fff !important;
}
body.theme-light .form-check-input {
  background-color: #fff !important;
  border-color: #9ca3af !important;
}
body.theme-light .form-check-input:checked {
  background-color: #FBBF24 !important;
  border-color: #FBBF24 !important;
}
/* Buttons that don't have explicit theme — keep white surface. */
body.theme-light .btn-outline-secondary {
  color: #374151 !important;
  border-color: #d1d5db !important;
  background-color: #fff !important;
}
body.theme-light .btn-outline-danger {
  color: #991b1b !important;
  border-color: #fca5a5 !important;
  background-color: #fff !important;
}
/* Tables on light theme — white with dark text. */
body.theme-light table, body.theme-light .table {
  background-color: transparent !important;
  color: #111827 !important;
  --bs-table-bg: #fff;
  --bs-table-color: #111827;
  --bs-table-border-color: #e5e7eb;
  --bs-table-striped-bg: #f9fafb;
  --bs-table-striped-color: #111827;
  --bs-table-hover-bg: #fef3c7;
  --bs-table-hover-color: #111827;
}
body.theme-light thead, body.theme-light tbody, body.theme-light tfoot,
body.theme-light tr, body.theme-light th, body.theme-light td {
  background-color: transparent !important;
  color: inherit !important;
  border-color: #e5e7eb !important;
}
body.theme-light th { color: #6b7280 !important; font-weight: 700; }
body.theme-light .table-responsive, body.theme-light .card .table, body.theme-light .card-body .table {
  background-color: #fff !important;
  border-radius: 8px;
}
body.theme-light tbody tr { background-color: #fff !important; }
body.theme-light tbody tr:hover { background-color: #fef9e7 !important; }

/* Make sure content padding is consistent */
body.theme-light .app-content { padding: 16px 24px; }
body.theme-dark .app-content { padding: 0; }
@media (max-width: 991.98px) {
  body.theme-light .app-content { padding: 12px 14px; }
}
