/* SoilSense Rwanda — Shared Stylesheet
   Provides: CSS variables, reset, layout, sidebar, page-header, mobile overlay
   Page-specific CSS lives inline in each PHP file.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Fraunces:ital,wght@1,600&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
    --bg:           #080f1e;   /* page background, darkest */
    --bg-card:      #0f1b2d;   /* sidebar, cards, panels */
    --bg-el:        #0b1525;   /* inputs, chips, secondary surfaces */
    --border:       #1e2d3d;   /* default borders */
    --border-sub:   #142030;   /* subtle / inner borders */
    --text:         #e2e8f0;   /* primary text */
    --muted:        #64748b;   /* secondary / label text */
    --accent:       #4ade80;   /* green accent */
    --acc-bg:       #163b20;   /* green dark background */
    --acc-hov:      #1d4a27;   /* green hover */
    --red:          #ef4444;
    --red-bg:       #2a0a0a;
    --red-border:   #7f1d1d;
    --yellow:       #fbbf24;
    --yel-bg:       #2a1a00;
    --yel-border:   #7c3405;
    --r-md:         8px;
    --r-lg:         12px;

    /* Backward-compat aliases (used by existing index.php component CSS) */
    --color-background-primary:   var(--bg-card);
    --color-background-secondary: var(--bg-el);
    --color-background-tertiary:  var(--bg);
    --color-border-secondary:     var(--border-sub);
    --color-border-tertiary:      var(--border);
    --color-text-primary:         var(--text);
    --color-text-secondary:       var(--muted);
    --border-radius-md:           var(--r-md);
    --border-radius-lg:           var(--r-lg);
}

/* ── BASE ─────────────────────────────────────────────────────── */
html, body {
    min-height: 100%;
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; }
button { font-family: inherit; }

/* ── APP LAYOUT ───────────────────────────────────────────────── */
.app    { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; overflow: hidden; }

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 14px 16px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
}
.sb-brand-icon {
    width: 36px; height: 36px;
    background: var(--acc-bg);
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    border: 0.5px solid #4ade8020;
}
.sb-title {
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}
.sb-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* Nav links */
.sb-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }

.sb-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.15s;
    border: 0.5px solid transparent;
}
.sb-link:hover { background: var(--bg-el); color: var(--text); }
.sb-link.active { background: var(--acc-bg); color: var(--accent); border-color: #4ade8020; }
.sb-link i { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; }

/* Separator */
.sb-sep { height: 0.5px; background: var(--border); margin: 6px 14px; flex-shrink: 0; }

/* Meta info */
.sb-meta { padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; flex-shrink: 0; }
.sb-meta-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.sb-meta-item i { font-size: 13px; width: 16px; flex-shrink: 0; }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sb-dot.online  { background: var(--accent); box-shadow: 0 0 5px #4ade8055; }
.sb-dot.offline { background: var(--red); }

/* Logout */
.sb-logout {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 8px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    color: #fca5a5;
    text-decoration: none;
    border: 0.5px solid #7f1d1d25;
    background: transparent;
    transition: all 0.15s;
    flex-shrink: 0;
}
.sb-logout:hover { background: var(--red-bg); border-color: var(--red-border); }
.sb-logout i { font-size: 16px; }

/* ── PAGE HEADER ──────────────────────────────────────────────── */
.page-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 0.5px solid var(--border);
    background: var(--bg-card);
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}
.page-title { font-size: 17px; font-weight: 600; color: var(--text); }
.page-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

.hdr-pills  { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hdr-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 0.5px solid var(--border);
    background: var(--bg-el);
    color: var(--muted);
}
.hdr-pill i { font-size: 12px; }

/* ── MOBILE BAR ───────────────────────────────────────────────── */
.mob-bar { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 240px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
    .mob-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-card);
        border-bottom: 0.5px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 40;
        flex-shrink: 0;
    }
    .mob-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        font-family: 'Fraunces', serif;
        font-style: italic;
        font-size: 15px;
        font-weight: 600;
        color: var(--text);
    }
    .mob-menu-btn {
        width: 36px; height: 36px;
        display: flex; align-items: center; justify-content: center;
        background: var(--bg-el);
        border: 0.5px solid var(--border);
        border-radius: var(--r-md);
        cursor: pointer;
        color: var(--muted);
        font-size: 18px;
    }
    .page-hdr { padding: 14px 16px; }
}

/* ── OVERLAY (mobile sidebar backdrop) ───────────────────────── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 45;
}
.overlay.show { display: block; }

/* ── LIGHT MODE OVERRIDES ─────────────────────────────────────── */
.light-mode {
    --bg:           #f1f5f9;
    --bg-card:      #ffffff;
    --bg-el:        #e8edf4;
    --border:       #cbd5e1;
    --border-sub:   #dde5f0;
    --text:         #0f172a;
    --muted:        #64748b;
    --accent:       #16a34a;
    --acc-bg:       #dcfce7;
    --acc-hov:      #bbf7d0;
    --red:          #dc2626;
    --red-bg:       #fee2e2;
    --red-border:   #fca5a5;
    --yellow:       #d97706;
    --yel-bg:       #fef3c7;
    --yel-border:   #fbbf24;
    --color-background-primary:   var(--bg-card);
    --color-background-secondary: var(--bg-el);
    --color-background-tertiary:  var(--bg);
    --color-border-secondary:     var(--border-sub);
    --color-border-tertiary:      var(--border);
    --color-text-primary:         var(--text);
    --color-text-secondary:       var(--muted);
}
/* Hardcoded-color overrides for light mode */
.light-mode .alert-banner.ok       { background:#f0fdf4; border-color:#86efac; color:#15803d; }
.light-mode .alert-row td          { background:#fee2e2 !important; }
.light-mode .toast.ok              { background:#f0fdf4; border-color:#86efac; color:#15803d; }
.light-mode .lp-footer             { color:#6b7280; border-color:#d1fae5; }
.light-mode .left-panel            { background:#f0fdf4; border-color:var(--border); }
.light-mode .form-select option    { background:#ffffff; color:#0f172a; }

/* ── TOGGLE SWITCH (shared across pages) ──────────────────────── */
.toggle-switch {
    width: 32px; height: 18px;
    background: var(--acc-bg);
    border-radius: 9px;
    border: 0.5px solid var(--accent);
    position: relative; cursor: pointer; flex-shrink: 0;
    transition: opacity 0.15s;
}
.toggle-switch.disabled { opacity: 0.4; pointer-events: none; }
.toggle-knob {
    width: 12px; height: 12px;
    background: var(--muted);
    border-radius: 50%;
    position: absolute; top: 2px; left: 2px;
    transition: left 0.2s, background 0.2s;
}
.toggle-knob.on { left: 16px; background: var(--accent); }

/* ── THEME TOGGLE BUTTON (sidebar) ───────────────────────────── */
.theme-toggle-btn {
    display: flex; align-items: center; gap: 9px;
    margin: 0 8px 8px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    font-size: 13px; font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 0.5px solid transparent;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    transition: all 0.15s;
    width: calc(100% - 16px);
    text-align: left;
}
.theme-toggle-btn:hover { background: var(--bg-el); color: var(--text); }
.theme-toggle-btn i { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; }

/* ── SHARED UTILITIES ─────────────────────────────────────────── */
.section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
}

.pill-btn {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    border: 0.5px solid var(--border);
    background: var(--bg-el);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Space Grotesk', sans-serif;
}
.pill-btn:hover   { border-color: var(--accent); color: var(--text); }
.pill-btn.active  { background: var(--acc-bg); border-color: var(--accent); color: var(--accent); }

.ctrl-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-input {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--r-md);
    border: 0.5px solid var(--border);
    background: var(--bg-el);
    color: var(--text);
    outline: none;
}
.ctrl-input:focus { border-color: var(--accent); }

/* Scrollable controls bar below page-hdr */
.controls-bar {
    background: var(--bg-card);
    border-bottom: 0.5px solid var(--border);
    padding: 11px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
