/* ── Gray Supply WM – Design System ─────────────────────────────────────────
   Loaded on all pages. Defines tokens, reset, layout, sidebar, typography.
   components.css adds cards, buttons, forms, tables, and nav-grid.
 ─────────────────────────────────────────────────────────────────────────── */

/* ─── Design Tokens ─────────────────────────────────────────────────────────── */

/* Light theme — default (no attribute needed; also explicit via [data-theme="light"]) */
:root,
[data-theme="light"] {
    /* Native controls (date picker icon and popup, selects, scrollbars) follow the theme. */
    color-scheme: light;

    /* Backgrounds */
    --bg:          #f4f6f8;
    --bg-surface:  #ffffff;
    --bg-raised:   #edf0f3;
    --bg-hover:    #e5e9ed;

    /* Borders */
    --border:        #dde3ea;
    --border-subtle: #eaecf0;
    --border-input:  #c8d0d9;

    /* Text */
    --text:         #1a202c;
    --text-muted:   #4a5568;
    --text-dim:     #94a3b8;
    --text-heading: #0f172a;

    /* Accent — GSC teal, darkened for light-background contrast */
    --accent:       #0d9aa0;
    --accent-hover: #0a8288;
    --accent-dark:  #077a80;
    --accent-text:  #ffffff;

    /* Accent-derived (focus rings, subtle fills) */
    --accent-ring:      rgba(13, 154, 160, 0.18);
    --accent-bg-subtle: rgba(13, 154, 160, 0.08);
    --accent-bg-faint:  rgba(13, 154, 160, 0.10);

    /* Status */
    --green:     #059669;
    --green-bg:  rgba(5, 150, 105, 0.09);
    --red:       #dc2626;
    --red-bg:    rgba(220, 38, 38, 0.08);
    --yellow:    #d97706;
    --yellow-bg: rgba(217, 119, 6, 0.09);
    --blue:      #2563eb;
    --blue-bg:   rgba(37, 99, 235, 0.09);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow:    0 4px 12px rgba(0,0,0,.09);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.13);
}

/* Dark theme */
[data-theme="dark"] {
    color-scheme: dark;

    /* Backgrounds */
    --bg:          #0d0d1a;
    --bg-surface:  #12122a;
    --bg-raised:   #1a1a35;
    --bg-hover:    #1e1e40;

    /* Borders */
    --border:        #1e1e35;
    --border-subtle: #252545;
    --border-input:  #33336a;

    /* Text */
    --text:         #e0e0e0;
    --text-muted:   #9999bb;
    --text-dim:     #55557a;
    --text-heading: #ffffff;

    /* Accent — GSC teal */
    --accent:       #45e0e6;
    --accent-hover: #36c8ce;
    --accent-dark:  #2aa8ad;
    --accent-text:  #0d0d1a;

    /* Accent-derived */
    --accent-ring:      rgba(69, 224, 230, 0.15);
    --accent-bg-subtle: rgba(69, 224, 230, 0.07);
    --accent-bg-faint:  rgba(69, 224, 230, 0.10);

    /* Status */
    --green:     #4ade80;
    --green-bg:  rgba(74, 222, 128, 0.10);
    --red:       #f87171;
    --red-bg:    rgba(248, 113, 113, 0.10);
    --yellow:    #fbbf24;
    --yellow-bg: rgba(251, 191, 36, 0.10);
    --blue:      #60a5fa;
    --blue-bg:   rgba(96, 165, 250, 0.10);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow:    0 4px 12px rgba(0,0,0,.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
}

/* Non-themed tokens — identical in both themes */
:root {
    --sidebar-w: 240px;

    --font:        Calibri, system-ui, -apple-system, sans-serif;
    --font-size:   15px;
    --line-height: 1.55;

    --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
    --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px;

    --r-sm: 4px;   --r: 6px;   --r-lg: 10px;
}

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

html {
    font-size: var(--font-size);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    line-height: var(--line-height);
    color: var(--text);
    background: var(--bg);
    margin: 0;
}

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

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    line-height: 1.25;
    margin: 0;
    font-family: var(--font);
}

p { margin: 0 0 1em; }

/* ─── Layout Shell ─────────────────────────────────────────────────────────── */
.wm-layout {
    display: flex;
    min-height: 100vh;
}

.wm-main {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.2s ease;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.2s ease;
}

.sidebar-header {
    padding: 20px 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.sidebar-brand:hover { text-decoration: none; color: inherit; }

.sidebar-logo {
    height: 72px;
    flex-shrink: 0;
    background: #fff;
    padding: 4px;
    object-fit: cover;
    object-position: left center;
}

.sidebar-brand-name {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-heading);
    letter-spacing: 0.01em;
    text-align: center;
}
.sidebar-brand-sub {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
}

/* ─── Sidebar Navigation ───────────────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
    white-space: nowrap;
}
.sidebar-link:hover {
    color: var(--text);
    background: var(--bg-raised);
    border-left-color: var(--border-subtle);
    text-decoration: none;
}
.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-bg-subtle);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    padding: 10px 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logout { color: var(--text-dim); }
.sidebar-logout:hover {
    color: var(--red);
    background: rgba(248, 113, 113, 0.06);
    border-left-color: transparent;
}

/* ─── Mobile hamburger ─────────────────────────────────────────────────────── */
.nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: var(--r-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.nav-toggle:hover { background: var(--bg-raised); }

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
    content: '';
    position: absolute;
    left: 0;
}
.nav-toggle span::before { top: -5px; }
.nav-toggle span::after  { top:  5px; }

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 90;
}

/* ─── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
    padding: 26px 32px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.page-breadcrumb a        { color: var(--text-muted); }
.page-breadcrumb a:hover  { color: var(--accent); }

.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}
.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    margin-bottom: 0;
}

/* ─── Page Content ─────────────────────────────────────────────────────────── */
.page-content {
    padding: 28px 32px;
    flex: 1;
}

/* ─── Pure.css neutralization ─────────────────────────────────────────────── */
.pure-menu-heading,
.pure-menu-selected { background: transparent !important; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .wm-main { margin-left: 0; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .nav-toggle  { display: flex; }
    .nav-overlay.open { display: block; }

    .page-header  { padding: 14px 18px 12px; padding-left: 62px; }
    .page-content { padding: 18px; }
}
