﻿/* =====================================================================
   AgriLedger App Theme
   Shared design system for internal (authenticated) pages.
   Reuses the palette/type established on Default.aspx so the marketing
   site and the working app feel like the same product.
   ===================================================================== */

:root {
    --loam: #23301E;
    --loam-panel: #2E3B27;
    --loam-panel-2: #354330;
    --husk: #F4EEDF;
    --husk-dim: #C9C3AE;
    --maize: #D9A441;
    --maize-bright: #EFC168;
    --canopy: #6B8F5C;
    --clay: #B4502F;
    --line: rgba(35,48,30,0.12);
    --line-dark: rgba(244,238,223,0.14);
    /* Light app surface — internal pages use a light husk-paper
       background (working documents) rather than the dark marketing
       ground, but keep the same accent vocabulary throughout. */
    --surface: #FBF8F1;
    --surface-panel: #FFFFFF;
    --ink: #23301E;
    --ink-dim: #5B6653;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body.app-shell {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
}

.app-shell h1, .app-shell h2, .app-shell h3, .app-shell h4, .app-shell h5 {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Layout: sidebar + main ---------- */
/* Sidebar is position:fixed and taken out of flow, so .app-layout no
   longer needs to be a flex row — .app-main is offset with margin-left
   instead. This keeps the sidebar pinned in place while the content
   column scrolls independently.

   Sidebar visibility is now controlled by a class on .app-layout at
   EVERY screen width, not just on mobile:
     - Mobile (<=860px): hidden by default, ".sidebar-open" reveals it
       as an overlay (with backdrop) — unchanged from before.
     - Desktop (>860px): visible by default, ".sidebar-collapsed" hides
       it and drops .app-main's margin-left to 0, so content becomes
       true edge-to-edge full width with only its existing padding
       left — no leftover margin. */
.app-layout {
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.app-sidebar {
    width: 232px;
    background: var(--loam);
    color: var(--husk);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh; /* fallback for older browsers that don't understand dvh */
    z-index: 200;
    box-shadow: 0 0 40px rgba(0,0,0,0.35);
    transform: translateX(-100%);
    transition: transform .25s ease;
}

.app-layout.sidebar-open .app-sidebar {
    transform: translateX(0);
}

/* Slim bar holding the hamburger toggle + brand. Shown at every screen
   width now — previously desktop had no way to reach the toggle at
   all, since this bar (and the sidebar-toggle button inside it) only
   rendered below 860px. */
.app-mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 150;
    background: var(--loam);
    color: var(--husk);
    padding: 14px 18px;
}

.app-mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--husk);
    text-decoration: none;
}

.sidebar-toggle {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--line-dark);
    color: var(--husk);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

    .sidebar-toggle span,
    .sidebar-toggle span::before,
    .sidebar-toggle span::after {
        content: "";
        display: block;
        width: 18px;
        height: 2px;
        background: var(--husk);
        position: relative;
        transition: transform .2s ease, opacity .2s ease;
    }

        .sidebar-toggle span::before {
            position: absolute;
            top: -6px;
        }

        .sidebar-toggle span::after {
            position: absolute;
            top: 6px;
        }

.app-layout.sidebar-open .sidebar-toggle span {
    background: transparent;
}

    .app-layout.sidebar-open .sidebar-toggle span::before {
        transform: translateY(6px) rotate(45deg);
    }

    .app-layout.sidebar-open .sidebar-toggle span::after {
        transform: translateY(-6px) rotate(-45deg);
    }

/* Dims and blocks the page behind an open mobile sidebar. Desktop
   collapsing doesn't use a backdrop — it reflows the layout instead
   of overlaying it, so this stays mobile-only (see media query below). */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(35,48,30,0.45);
    z-index: 190;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
    color: var(--husk);
    border-bottom: 1px solid var(--line-dark);
}

.sidebar-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--maize);
    color: var(--loam);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transform: rotate(-6deg);
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 14px 12px;
    
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 7px;
    color: var(--husk-dim);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}

    .sidebar-link .icon {
        font-size: 16px;
        width: 20px;
        text-align: center;
    }

    .sidebar-link:hover {
        background: rgba(244,238,223,0.06);
        color: var(--husk);
    }

    .sidebar-link.active {
        background: rgba(217,164,65,0.16);
        color: var(--maize-bright);
    }

    .sidebar-link .badge-count {
        margin-left: auto;
        background: var(--clay);
        color: var(--husk);
        font-family: 'IBM Plex Mono', monospace;
        font-size: 10.5px;
        font-weight: 600;
        padding: 1px 7px;
        border-radius: 100px;
    }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--line-dark);
    font-size: 13px;
}

.sidebar-user {
    color: var(--husk);
    font-weight: 600;
    margin-bottom: 6px;
}

.sidebar-footer a {
    color: var(--husk-dim);
    text-decoration: none;
}

    .sidebar-footer a:hover {
        color: var(--maize-bright);
    }

/* ---------- Main content column ---------- */
/* No margin by default now (mobile-first) — desktop gets the sidebar
   offset back at >=861px below, and loses it again when collapsed. */
.app-main {
    margin-left: 0;
    min-width: 0;
    width: auto;
    max-width: 100%;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .25s ease;
}

.app-main-body {
    flex-grow: 1;
    width: 100%;
    min-width: 0;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
    flex-wrap: wrap;
    gap: 12px;
}

    .page-head h1 {
        font-size: 26px;
        margin: 0;
    }

    .page-head .page-sub {
        color: var(--ink-dim);
        font-size: 14px;
        margin-top: 4px;
    }

/* ---------- Responsive table wrapping ---------- */
/* .table-responsive-wrap is the class Site.Master's script actually
   applies to every <table>/GridView — .table-responsive alone (below)
   was a manual-use helper that never matched what the script adds, so
   wrapped tables were being clipped by html{overflow-x:hidden} instead
   of scrolling internally. Both classes now share the same rule. */
.table-responsive,
.table-responsive-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

    .table-responsive-wrap table {
        margin-bottom: 0;
    }

/* ---------- Thin scrollbars (global) ---------- */
* {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--husk-dim) transparent;
}

    *::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    *::-webkit-scrollbar-track {
        background: transparent;
    }

    *::-webkit-scrollbar-thumb {
        background-color: var(--husk-dim);
        border-radius: 100px;
    }

        *::-webkit-scrollbar-thumb:hover {
            background-color: var(--canopy);
        }

/* The sidebar's scroll region sits on the dark --loam background, so
   it needs a lighter thumb than the default husk-dim used elsewhere. */
.sidebar-scroll {
    scrollbar-color: rgba(244,238,223,0.35) transparent;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0; /* lets a flex child actually shrink/scroll instead of pushing the footer off */
}

    .sidebar-scroll::-webkit-scrollbar-thumb {
        background-color: rgba(244,238,223,0.35);
    }

        .sidebar-scroll::-webkit-scrollbar-thumb:hover {
            background-color: var(--maize);
        }

/* Long, unbroken strings (IDs, URLs, emails) shouldn't force overflow
   inside cards/panels either. */
.panel, .card, .module-card {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform .1s ease, box-shadow .1s ease, background .15s, border-color .15s;
    font-family: 'Inter', sans-serif;
}

    .btn:focus-visible {
        outline: 3px solid var(--maize-bright);
        outline-offset: 2px;
    }

.btn-sm {
    padding: 7px 13px;
    font-size: 13px;
}

.btn-success, .btn-primary {
    background: var(--maize);
    color: var(--loam);
}

    .btn-success:hover, .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(217,164,65,0.35);
    }

.btn-outline-primary, .btn-outline-success {
    background: transparent;
    color: var(--canopy);
    border: 1px solid var(--canopy);
}

    .btn-outline-primary:hover, .btn-outline-success:hover {
        background: rgba(107,143,92,0.1);
    }

.btn-secondary, .btn-outline-secondary {
    background: transparent;
    color: var(--ink-dim);
    border: 1px solid rgba(35,48,30,0.2);
}

    .btn-secondary:hover, .btn-outline-secondary:hover {
        border-color: var(--ink-dim);
    }

.btn-danger {
    background: var(--clay);
    color: var(--husk);
}

/* ---------- Cards / panels ---------- */
.panel, .card {
    background: var(--surface-panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(35,48,30,0.06);
}

.module-card {
    display: block;
    padding: 24px;
    border-radius: 10px;
    background: var(--surface-panel);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    height: 100%;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

    .module-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 24px rgba(35,48,30,0.1);
        border-color: var(--maize);
        color: var(--ink);
        text-decoration: none;
    }

.module-icon {
    font-size: 30px;
    margin-bottom: 10px;
}

.module-card h5 {
    font-size: 17px;
    margin-bottom: 6px;
}

.module-card p {
    color: var(--ink-dim);
    font-size: 13.5px;
    margin: 0;
}

.summary-card {
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    color: #fff;
}

    .summary-card h2 {
        font-family: 'IBM Plex Mono', monospace;
        font-size: 32px;
        margin: 0 0 4px;
        color: #fff;
    }

    .summary-card.bg-danger {
        background: var(--clay);
    }

    .summary-card.bg-warning {
        background: var(--maize);
        color: var(--loam);
    }

        .summary-card.bg-warning h2 {
            color: var(--loam);
        }

    .summary-card.bg-secondary {
        background: #5B6653;
    }
/* ---------- Responsive row layouts (summary cards / chart panels) ---------- */
/* Used by pages like Accounting.aspx that lay out 2-3 equal-width blocks.
   flex-wrap + a sane min-width basis means blocks wrap onto their own
   line instead of being squeezed/clipped as the viewport narrows. */
.summary-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

    .summary-cards-row > div {
        flex: 1 1 200px;
        min-width: 0; /* allow shrinking below content size instead of overflowing */
    }

.summary-card h2 {
    /* Scales smoothly between 22px and 32px based on viewport width,
       instead of a fixed size that overflows small screens. */
    font-size: clamp(22px, 5vw, 32px);
}

.charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 28px;
}

    .charts-row > .panel {
        flex: 1 1 320px;
        min-width: 0;
    }

        .charts-row > .panel canvas {
            max-width: 100%;
        }

/* Below 768px, force charts to stack one under the other rather than
   wrapping at an awkward width where they'd still be cramped. */
@media (max-width: 768px) {
    .charts-row {
        flex-direction: column;
    }
}

/* Below 560px, stack summary cards too — three-across is unreadable
   at that width even with wrapping. */
@media (max-width: 560px) {
    .summary-cards-row {
        flex-direction: column;
    }

    .summary-card {
        padding: 16px;
    }
}
/* ---------- Tables ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-panel);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(35,48,30,0.06);
}

    .table thead.table-dark th {
        background: var(--loam);
        color: var(--husk);
        font-family: 'IBM Plex Mono', monospace;
        font-size: 11.5px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: 600;
        padding: 12px 16px;
        text-align: left;
        border: none;
    }

    .table td {
        padding: 12px 16px;
        border-bottom: 1px solid var(--line);
        font-size: 14px;
        vertical-align: middle;
    }

    .table tbody tr:last-child td {
        border-bottom: none;
    }

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(107,143,92,0.04);
}

.table-sm td, .table-sm th {
    padding: 8px 12px;
}

.low-stock {
    background: rgba(217,164,65,0.12) !important;
}

/* ---------- Badges (growth stage / severity) ---------- */
.stage-badge {
    padding: 4px 11px;
    border-radius: 100px;
    font-size: 11.5px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    color: #fff;
    display: inline-block;
}

.stage-Germination {
    background-color: #8B8563;
}

.stage-Vegetative {
    background-color: var(--canopy);
}

.stage-Flowering {
    background-color: var(--maize);
    color: var(--loam);
}

.stage-Fruiting {
    background-color: #C67C24;
}

.stage-Maturity {
    background-color: #4A6B8A;
}

.stage-Harvested {
    background-color: var(--loam);
}

.badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 100px;
}

.bg-warning.text-dark {
    background: var(--maize) !important;
    color: var(--loam) !important;
}

.badge-overdue {
    background-color: var(--clay);
    color: #fff;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 10.5px;
    font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Insight / event cards ---------- */
.insight-card {
    border-left: 4px solid var(--canopy);
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(107,143,92,0.07);
    border-radius: 0 6px 6px 0;
    font-size: 13.5px;
}

    .insight-card.alert {
        border-left-color: var(--clay);
        background: rgba(180,80,47,0.07);
    }

.event-card {
    padding: 14px 18px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 5px solid #ccc;
    background: var(--surface-panel);
    box-shadow: 0 1px 3px rgba(35,48,30,0.06);
}

    .event-card.Critical {
        border-left-color: var(--clay);
    }

    .event-card.Warning {
        border-left-color: var(--maize);
    }

    .event-card.Info {
        border-left-color: var(--canopy);
    }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border: 1px solid rgba(35,48,30,0.18);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--surface-panel);
    color: var(--ink);
    width: 100%;
}

    .form-control:focus, .form-select:focus {
        outline: none;
        border-color: var(--canopy);
        box-shadow: 0 0 0 3px rgba(107,143,92,0.15);
    }

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-dim);
    margin-bottom: 5px;
    display: block;
}

.alert {
    padding: 12px 16px;
    border-radius: 7px;
    font-size: 13.5px;
}

.alert-danger {
    background: rgba(180,80,47,0.1);
    color: #7A3620;
    border: 1px solid rgba(180,80,47,0.3);
}

.alert-success {
    background: rgba(107,143,92,0.12);
    color: #3E5B34;
    border: 1px solid rgba(107,143,92,0.3);
}

.alert-warning {
    background: rgba(217,164,65,0.14);
    color: #7A5A1C;
    border: 1px solid rgba(217,164,65,0.35);
}

/* ---------- Modals (Bootstrap structure, restyled) ---------- */
.modal-content {
    border-radius: 10px;
    border: none;
    box-shadow: 0 20px 50px rgba(35,48,30,0.25);
}

.modal-header {
    border-bottom: 1px dashed var(--line);
    padding: 18px 22px;
}

    .modal-header .modal-title {
        font-family: 'Roboto Slab', serif;
        font-size: 18px;
    }

.modal-body {
    padding: 20px 22px;
}

.modal-footer {
    border-top: 1px solid var(--line);
    padding: 16px 22px;
}

.btn-close {
    filter: none;
}

.nav-tabs {
    border-bottom: 1px solid var(--line);
}

    .nav-tabs .nav-link {
        color: var(--ink-dim);
        border: none;
        font-size: 14px;
        font-weight: 500;
    }

        .nav-tabs .nav-link.active {
            color: var(--canopy);
            border-bottom: 2px solid var(--canopy);
            background: none;
        }

/* ---------- Login / Register (public, pre-auth) ---------- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--loam);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface-panel);
    border-radius: 12px;
    padding: 34px 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

    .auth-card.wide {
        max-width: 480px;
    }

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 4px;
    color: var(--ink);
}

.auth-tagline {
    text-align: center;
    color: var(--ink-dim);
    font-size: 13.5px;
    margin-bottom: 24px;
}

.auth-link-row {
    text-align: center;
    margin-top: 18px;
    font-size: 14px;
}

    .auth-link-row a {
        color: var(--canopy);
        font-weight: 600;
        text-decoration: none;
    }

        .auth-link-row a:hover {
            text-decoration: underline;
        }

/* ---------- App footer (shown at the base of every authenticated page) ---------- */
.app-footer {
    margin-top: 48px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.app-footer-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 28px;
    margin-bottom: 20px;
}

.app-footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
}

.app-footer-about p {
    color: var(--ink-dim);
    font-size: 13.5px;
    margin: 10px 0 0;
    max-width: 38ch;
}

.app-footer h4 {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dim);
    margin: 0 0 12px;
}

.app-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-footer li {
    margin-bottom: 8px;
    font-size: 13.5px;
}

.app-footer a {
    color: var(--ink);
    text-decoration: none;
}

    .app-footer a:hover {
        color: var(--canopy);
    }

.app-footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 0 4px;
    border-top: 1px dashed var(--line);
    font-size: 12.5px;
    color: var(--ink-dim);
}

    /* ---------- Loading overlay ---------- */
    #loadingOverlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(251,248,241,0.75);
        z-index: 9999;
    }

        #loadingOverlay > div {
            text-align: center;
            margin-top: 20%;
            font-family: 'IBM Plex Mono', monospace;
            color: var(--ink-dim);
        }

    /* ---------- Desktop (>860px): sidebar visible by default, ---------- */
    /* toggle collapses it — this is the part that's new. Collapsing        */
    /* removes .app-main's margin-left entirely, giving true full-width     */
    /* content with only its existing padding, no leftover margin.          */
    @media (min-width: 861px) {
        .app-sidebar {
            transform: translateX(0);
        }

        .app-main {
            margin-left: 232px;
        }

        .app-layout.sidebar-collapsed .app-sidebar {
            transform: translateX(-100%);
        }

        .app-layout.sidebar-collapsed .app-main {
            margin-left: 0;
        }
    }

    @media (max-width: 860px) {
        .app-layout.sidebar-open .app-sidebar-backdrop {
            display: block;
        }

        .app-main {
            padding: 24px 20px;
        }

        .app-footer-grid {
            grid-template-columns: 1fr 1fr;
            gap: 24px;
        }
    }

    @media (max-width: 560px) {
        .app-main {
            padding: 20px 16px;
        }

        .app-footer-grid {
            grid-template-columns: 1fr;
            gap: 22px;
        }

        .app-footer-bottom {
            flex-direction: column;
            align-items: flex-start;
        }
    }
    /* ---------- Generic responsive split-row layout ---------- */
    /* Reusable 2-3 column flex row that wraps/stacks on narrow screens.
       Use for any side-by-side panels (category lists, comparison blocks,
       settings columns, etc.) instead of ad-hoc inline flex styles. */
    .split-row {
        display: flex;
        flex-wrap: wrap;
        gap: 24px;
    }

        .split-row > div {
            flex: 1 1 280px;
            min-width: 0; /* let content shrink instead of overflowing */
        }

    /* Stack fully below 640px — two 280px columns don't have room to
       wrap side-by-side usefully at that width anyway. */
    @media (max-width: 640px) {
        .split-row {
            flex-direction: column;
            gap: 20px;
        }
    }
