/* Admin Portal layout. Colours follow Bootstrap 5.3 CSS variables, so dark mode works. */
:root {
    --topbar-height: 56px;
    --sidebar-width: 240px;
    --sidebar-bg: #1e293b;
    --sidebar-fg: rgba(255, 255, 255, .72);
    --sidebar-active: #3b82f6;
}
[data-bs-theme="dark"] { --sidebar-bg: #111827; }

body.portal { background: var(--bs-tertiary-bg); min-height: 100vh; }

/* Top bar */
.portal-topbar { height: var(--topbar-height); background: var(--bs-body-bg); z-index: 1030; padding-left: calc(var(--sidebar-width) + 1rem) !important; transition: padding .2s; }
.portal-topbar .nav-link { color: var(--bs-body-color); }
.portal-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bs-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .9rem; }
[data-bs-theme="light"] .theme-icon-dark, [data-bs-theme="dark"] .theme-icon-light { display: none; }

/* Sidebar */
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-width); background: var(--sidebar-bg); z-index: 1040; overflow-y: auto; transition: transform .2s; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.sidebar-brand { height: var(--topbar-height); padding: 0 1.25rem; color: #fff; background: rgba(0,0,0,.15); }
.sidebar-brand:hover { color: #fff; }
.sidebar-nav { list-style: none; padding: .5rem 0 3rem; margin: 0; }
.sidebar-heading { padding: 1rem 1.25rem .35rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.4); }
.sidebar .nav-link { display: flex; align-items: center; padding: .55rem 1.25rem; color: var(--sidebar-fg); border-left: 3px solid transparent; font-size: .92rem; }
.sidebar .nav-link i { width: 1.25rem; margin-right: .75rem; font-size: 1.05rem; text-align: center; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar .nav-link.active { color: #fff; background: rgba(59,130,246,.18); border-left-color: var(--sidebar-active); }

.main-content { margin-left: var(--sidebar-width); padding-top: var(--topbar-height); min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s; }
.main-content > .container-fluid { flex: 1; }

body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }
body.sidebar-collapsed .portal-topbar { padding-left: 1rem !important; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .portal-topbar { padding-left: 1rem !important; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; }
}

/* Cards / stats */
.card { border: 0; }
.portal-stat:hover { transform: translateY(-2px); transition: transform .15s; }
.portal-stat-icon { width: 48px; height: 48px; border-radius: .75rem; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }

/* DataTables */
.portal-table { font-size: .875rem; }
.portal-table thead th { white-space: nowrap; background: var(--bs-secondary-bg); }
.portal-table thead tr.portal-col-search-row th { background: var(--bs-body-bg); padding: .3rem; font-weight: normal; }
.portal-table thead tr.portal-col-search-row th::before, .portal-table thead tr.portal-col-search-row th::after { display: none !important; }
.portal-table .portal-col-search, .portal-table .portal-col-daterange input { min-width: 6rem; font-size: .8rem; }
.portal-table .portal-col-daterange input { min-width: 7.5rem; }
div.dataTables_wrapper div.dataTables_processing { z-index: 5; }

/* Offcanvas form */
#myCanvas { width: min(640px, 100vw); }
.offcanvas-footer { background: var(--bs-body-bg); }

/* Select2 inside offcanvas / dark mode */
.select2-container { z-index: 1060; }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background-color: var(--bs-body-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__rendered { color: var(--bs-body-color) !important; }

.swal2-container { z-index: 2000; }

/* Login */
.portal-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b, #3b82f6); }
.portal-auth .card { width: min(420px, 92vw); }

/* context switch next to the page title (e.g. one activity at a time) */
.portal-context { width: auto; }
.portal-context .form-select { min-width: 240px; max-width: 420px; font-weight: 600; }
.portal-context-locked { display: inline-block; font-size: .875rem; padding: .25rem .75rem; border-radius: 999px; background: var(--bs-secondary-bg); color: var(--bs-body-color); }
