/* =========================================================================
   THEME
   Bootstrap 4.5 has no dark mode, so these variables + overrides are what's
   left after moving layout/spacing/components to Bootstrap utility classes
   and components (card, btn, form-group, alert, nav, fixed-bottom, ...).
   ========================================================================= */

:root {
    --bg: #120d09;
    --surface: #1e1611;
    --surface-2: #2a2019;
    --border: #3d2f22;
    --text: #f3e9de;
    --text-dim: #a99883;
    --accent: #e3a458;
    --accent-2: #b56a35;
    --danger: #e2555a;
    --radius: 14px;
    --tap-target: 46px;
}

body {
    background: radial-gradient(circle at 20% 0%, #34220f 0%, var(--bg) 55%);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
}

a { color: var(--accent-2); }
a:hover { color: var(--accent); }

/* Bootstrap's .card is white by default — recolor it for the dark theme. */
.card {
    background-color: var(--surface);
    border-color: var(--border);
}

/* Small utility classes Bootstrap 4.5 doesn't provide. */
.bg-surface { background-color: var(--surface) !important; }
.bg-surface-2 { background-color: var(--surface-2) !important; }
.text-dim { color: var(--text-dim) !important; }
.border-theme { border-color: var(--border) !important; }

@media (min-width: 768px) {
    .border-top-md { border-top: 1px solid var(--border); }
}

/* Bootstrap has no responsive `btn-block`, only the all-or-nothing version. */
@media (min-width: 768px) {
    .btn-md-block { display: block; width: 100%; }
}

/* Brand mark used in the sidebar/top bar and on auth cards. */
.brand-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px var(--accent);
}

/* Gradient CTA button used on auth pages. */
.btn-gradient {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    color: #1f1108;
    font-weight: 700;
}

.btn-gradient:hover,
.btn-gradient:focus {
    color: #1f1108;
    opacity: 0.92;
}

/* Bare Django form fields (no `form-control` class) still get dark styling.
   Add `class: "form-control form-control-lg"` in the widget attrs to opt a
   field into full Bootstrap form-control behaviour (focus ring, sizing). */
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    display: block;
    width: 100%;
    min-height: var(--tap-target);
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    color: var(--text);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    background-color: var(--surface-2);
    border-color: var(--accent-2);
    color: var(--text);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(181, 106, 53, 0.3);
}

/* ---------- App shell / sidebar (desktop) ---------- */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-link { color: var(--text-dim); }

.sidebar-link:hover,
.sidebar-link.active {
    background-color: var(--surface-2);
    color: var(--text);
}

/* ---------- Mobile top bar ---------- */

.mobile-topbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

/* Icon-only action buttons used in the mobile top bar (crash test / admin / login / logout). */
.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--accent-2);
}

.icon-btn-danger {
    color: var(--danger);
    border-color: rgba(226, 85, 90, 0.35);
}

.icon-btn-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(226, 85, 90, 0.1);
}

.icon-btn-danger-filled {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.icon-btn-danger-filled:hover {
    color: #fff;
    opacity: 0.9;
}

/* ---------- Mobile bottom tab bar ---------- */

.mobile-tabbar {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
}

.tabbar-link {
    flex: 1;
    color: var(--text-dim);
    text-decoration: none;
    min-height: 48px;
    justify-content: center;
    gap: 2px;
    -webkit-tap-highlight-color: transparent;
}

.tabbar-link span { font-size: 0.68rem; font-weight: 600; }

.tabbar-link.active { color: var(--accent); }

/* ---------- Page content ---------- */

/* .main-content is the full-width flex area next to the sidebar; .content-inner
   is what actually centers the page — capped width on desktop, and padded clear
   of the fixed top/bottom bars on mobile. Kept out of Bootstrap's p-*/pb-*
   utilities on purpose: those carry `!important` and would fight the mobile
   top/bottom offsets below. */
.main-content {
    width: 100%;
    min-width: 0;
}

.content-inner {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem;
}

@media (max-width: 767.98px) {
    .content-inner {
        padding: 1.25rem;
        padding-top: calc(1.25rem + 54px + env(safe-area-inset-top));
        padding-bottom: calc(1.25rem + 64px + env(safe-area-inset-bottom));
    }
}