/* ============================================================
   StaffTrack Base Layer
   Reset, typography, and the application shell (sidebar,
   mobile header, main content, page headers).
   Reads tokens.css. Loads before components.css.
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--ground);
    color: var(--body);
    font-family: var(--font-ui);
    font-size: var(--t-base);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */

/* Headings never carry a fixed colour: the container decides.
   A bare `color` here is what put dark text on dark card
   headers in production. Do not reintroduce it. */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5rem;
    color: inherit;
    font-weight: 650;
    line-height: var(--lh-tight);
    letter-spacing: var(--track-tight);
    text-wrap: balance;
}

h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-base); }
h5 { font-size: var(--t-base); }
h6 { font-size: var(--t-cap); }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

small, .small { font-size: var(--t-sm); }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--ease);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

strong, b { font-weight: 650; color: var(--ink); }

/* Bootstrap utility, remapped onto our token */
.text-muted { color: var(--muted) !important; }

/* Any figure that lines up in a column reads as tabular */
.money, .num, td.text-end, th.text-end, .tabular {
    font-variant-numeric: tabular-nums;
}

/* Uppercase micro-label used across the app */
.label-cap {
    font-size: var(--t-xs);
    font-weight: 600;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
}

/* ============================================
   Focus — visible on every interactive element
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-control);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-w);
    height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 1.25rem 0 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--ease);
}

.sidebar-nav-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.15rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.85rem;
}

.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--r-control);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: none;
}

.sidebar-logo-img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-brand-text {
    color: var(--ink);
    font-weight: 700;
    font-size: var(--t-lg);
    letter-spacing: var(--track-tight);
}
.sidebar-brand-text span { color: var(--accent); }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-nav-section {
    padding: 1rem 1.25rem 0.4rem;
    font-size: var(--t-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--track-label);
    color: var(--muted);
}

.sidebar-nav-item { margin: 1px 0.65rem; }

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    color: var(--body);
    text-decoration: none;
    border-radius: var(--r-control);
    transition: background var(--ease), color var(--ease);
    font-weight: 500;
    font-size: var(--t-cap);
}

.sidebar-nav-link:hover {
    background: var(--accent-wash);
    color: var(--accent);
    text-decoration: none;
}

/* Flat wash, not a gradient pill. */
.sidebar-nav-link.active {
    background: var(--accent-wash);
    color: var(--accent);
    font-weight: 650;
    box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex: none;
}

.sidebar-user {
    padding: 0.9rem 1.25rem;
    background: var(--panel-alt);
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--r-pill);
    background: var(--accent-wash);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 650;
    font-size: var(--t-cap);
    flex: none;
}

.sidebar-user-details { min-width: 0; }

.sidebar-user-name {
    color: var(--ink);
    font-weight: 650;
    font-size: var(--t-cap);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: var(--muted);
    font-size: var(--t-sm);
}

/* ============================================
   Mobile header
   ============================================ */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 900;
    color: var(--ink);
}

.mobile-menu-btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    font-size: 1.15rem;
    cursor: pointer;
    transition: background var(--ease);
}
.mobile-menu-btn:hover { background: var(--accent-wash); color: var(--accent); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgb(22 33 30 / 0.45);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ease), visibility var(--ease);
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ============================================
   Main content and page headers
   ============================================ */
.main-content {
    margin-left: var(--nav-w);
    min-height: 100vh;
    padding: 1.75rem 2rem 3rem;
}

.page-header { margin-bottom: 1.5rem; }

.page-title {
    font-size: var(--t-xl);
    font-weight: 700;
    color: var(--ink);
    letter-spacing: var(--track-tight);
    margin: 0;
}

.page-subtitle {
    color: var(--muted);
    margin-top: 0.2rem;
    font-size: var(--t-cap);
}

/* Page-level h1 in templates that don't use .page-title */
.main-content > h1,
.main-content > .d-flex h1 {
    font-size: var(--t-xl);
    color: var(--ink);
    font-weight: 700;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    opacity: 1;
    margin: 1.25rem 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1.25rem 1rem 3rem; }
}

@media (min-width: 992px) {
    .mobile-header { display: none; }
    .sidebar-overlay { display: none; }
}

@media (max-width: 575.98px) {
    .main-content { padding: 1rem 0.85rem 2.5rem; }
    .page-title, .main-content > h1 { font-size: var(--t-lg); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar, .mobile-header, .sidebar-overlay, .btn { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    body { background: #fff; }
}
