/* ===========================
   Theme & Base
   =========================== */

:root {
    --bg-1: #eaf5e8; /* light mint background */
    --bg-2: #c8d8c1; /* gradient stop */
    --brand: #536942; /* header/sidebar green */
    --brand-2: #6b7f52;
    --text: #1f2a1f;
    --muted: #6b7280;
    --card: #f8fff7;
    --shadow: 0 20px 45px rgba(0,0,0,.18);
    --radius: 18px;
    --radius-sm: 12px;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    color: var(--text);
    background: radial-gradient(1200px 600px at 90% 85%, var(--bg-2), transparent 60%), radial-gradient(900px 500px at 20% 20%, #f4fff1, transparent 60%), linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

/* Links */
a {
    color: inherit;
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* ===========================
   App Shell / Layout
   =========================== */

/* Desktop shell uses grid with permanent left column for the sidebar */
.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    transition: grid-template-columns .2s ease;
}

    /* When collapsed (desktop), hide the sidebar column */
    .app-shell.nav-collapsed {
        grid-template-columns: 0 1fr;
    }

/* Sidebar */
.sidebar {
    background: var(--brand);
    color: #fff;
    overflow: auto;
    padding: 16px 12px;
    box-sizing: border-box;
    transition: transform .25s ease, width .2s ease, opacity .2s ease;
    z-index: 1001; /* above backdrop */
}

    .sidebar .brand {
        font-weight: 600;
        letter-spacing: .3px;
        margin: 6px 8px 12px;
    }

    .sidebar nav {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 6px;
    }

        .sidebar nav a {
            display: block;
            padding: 12px 14px;
            border-radius: 12px;
            background: rgba(255,255,255,.08);
        }

            .sidebar nav a:hover {
                background: rgba(255,255,255,.16);
            }

/* Content area */
.content {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 16px;
    background: var(--brand);
    color: #eaf5e8;
    position: relative;
    z-index: 900;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

    .topbar .title {
        font-weight: 600;
    }

.menu-btn {
    background: transparent;
    color: #eaf5e8;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    padding: .5rem .75rem;
    font-size: 1.25rem;
    line-height: 1;
}

    .menu-btn:hover {
        background: rgba(255,255,255,.08);
    }

/* Page body spacing */
.page-body {
    padding: 28px 24px;
}

/* Backdrop (overlay) — hidden on desktop */
.backdrop {
    display: none;
}

/* ===========================
   Cards / Forms / Buttons
   =========================== */

.center-card {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: auto;
    padding-top: 15px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    max-width: 920px;
    width: 100%;
}

.form-card .card {
    max-width: 960px;
}

h1, h2, h3 {
    margin: 10px 0 16px;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.35rem;
}

h3 {
    font-size: 1.2rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    margin: 5px 0;
}

label {
    font-weight: 600;
    color: #324034;
}

input[type="text"],
input[type="number"],
select {
    appearance: none;
    border: 1px solid #d1d8cf;
    background: #fafff7;
    color: #243124;
    padding: 12px 14px;
    border-radius: 12px;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}

    input:focus, select:focus {
        border-color: #a8b9a3;
        box-shadow: 0 0 0 3px rgba(83,105,66,.15);
    }

/* Blazor InputFile is rendered as <input type="file"> */
input[type="file"] {
    border: 1px dashed #c7d2bf;
    background: #fbfff9;
    padding: 12px;
    border-radius: 12px;
}

.hint {
    color: var(--muted);
    font-size: .9rem;
}

.btn-row {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 10px;
}

.btn {
    background: #dfe8d9;
    border: 1px solid #c5d2bf;
    color: #23301f;
    border-radius: 14px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all .15s ease;
}

    .btn:hover {
        background: #e9f1e5;
    }

    .btn.primary {
        background: var(--brand-2);
        color: #fff;
        border-color: transparent;
    }

        .btn.primary:hover {
            background: #5f764b;
        }

/* Messages */
.success {
    color: #155e2f;
    background: #e7f7ea;
    border: 1px solid #bfe8c8;
    padding: 10px 12px;
    border-radius: 10px;
    margin-top: 12px;
}

.error {
    color: #9b2226;
    background: #fff1f0;
    border: 1px solid #ffd6d6;
    padding: 10px 12px;
    border-radius: 10px;
    margin-top: 12px;
    white-space: pre-line; /* render \n or \r\n as line breaks */
}

.strike-row td { text-decoration: line-through; color: #ff0000; }
/* ===========================
   Desktop collapse behavior
   =========================== */

/* Collapse: hide the sidebar column */
.app-shell.nav-collapsed .sidebar {
    width: 0;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

/* ===========================
   Mobile / Tablet (drawer)
   =========================== */

@media (max-width: 768px) {
    /* Disable grid on small screens; use off-canvas drawer */
    .app-shell {
        display: block;
    }

    .topbar {
        position: sticky;
        top: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(85vw, 320px);
        transform: translateX(-100%); /* hidden by default */
        opacity: 1;
        pointer-events: auto;
        box-shadow: 0 10px 30px rgba(0,0,0,.25);
        /* Keep content scroll independent */
        overscroll-behavior: contain;
    }

    /* When nav is open, slide drawer in */
    .app-shell.nav-open .sidebar {
        transform: translateX(0);
    }

    /* Visual overlay ONLY on mobile and ONLY when nav is open */
    .app-shell.nav-open .backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.5);
        z-index: 1000; /* below sidebar (sidebar z-index:1100) */
    }

    /* Ensure drawer always above overlay */
    .app-shell .sidebar {
        z-index: 1100;
    }

    /* Ignore desktop column rule on mobile */
    .app-shell.nav-collapsed {
        grid-template-columns: unset;
    }

    .page-body {
        padding: 18px 14px;
    }

    .center-card { padding-top: 12px; }
    .card {
        border-radius: 16px;
        padding: 16px;
    }
}

/* ===========================
   Login specific tweaks
   =========================== */
.login-page {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fallback gradient + image layer (image optional) */
    background-image: linear-gradient( to bottom right, rgba(0,0,0,.35), rgba(0,0,0,.35) ), url('/images/logo.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Slight glass overlay for the login card on imagery */
.login-overlay {
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: var(--shadow);
}

.login-page .card {
    max-width: 520px;
}

.login-page .btn-row {
    justify-content: flex-end;
}

/* ===== Modal Dialog ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px;
}

.modal {
    background: var(--card, #fff);
    color: var(--text, #111);
    border-radius: var(--radius, 16px);
    box-shadow: 0 20px 45px rgba(0,0,0,.28);
    padding: 18px 20px;
    width: min(720px, 96vw);
    max-height: 86vh;
    overflow: auto;
}

/* ===== Results table (customers) ===== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
}

.table thead th {
    text-align: left;
    font-weight: 700;
    padding: 10px 12px;
    background: var(--brand);
    color: #fff;
}

.table tbody td {
    padding: 10px 12px;
    vertical-align: top;
}

.table tbody tr:nth-child(odd) {
    background: rgba(83,105,66,.06);
}
/* light green */
.table tbody tr:nth-child(even) {
    background: rgba(83,105,66,.12);
}
/* darker green */
.table tbody tr:hover {
    background: rgba(83,105,66,.18);
}

/* Icon column */
.col-icon {
    width: 44px;
}

.cell-icon {
    text-align: center;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #c5d2bf;
    background: #e9f1e5;
    color: #2a3825;
    cursor: pointer; /* hand cursor on hover */
    transition: transform .12s ease, background .12s ease;
}

.icon-btn:hover {
    background: #dfe8d9;
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

.icon-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(83,105,66,.25);
}

/* ===== Tabs for Customer Detail ===== */
.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 14px;
}

.tab {
    appearance: none;
    border: 1px solid #c5d2bf;
    background: #eef5ea;
    color: #1f2a1f;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.tab:hover {
    background: #e6efe0;
}

.tab.active {
    background: var(--brand-2, #6b7f52);
    color: #fff;
    border-color: transparent;
}

/* Pretty JSON inside modal (fallback renderer) */
.modal pre {
    background: #f6fbf4;
    border: 1px solid #d9e5d4;
    padding: 10px 12px;
    border-radius: 10px;
    overflow: auto;
}

/* Responsive wrapper for tables inside modal */
.table-wrap {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

.table {
    min-width: 560px;
}
/* allow horizontal scroll on very narrow screens */
@media (max-width: 520px) {
    .table {
        min-width: 480px;
    }
}

/* Groupbox styling */
.groupbox {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 5px;
    margin-bottom: 15px;
}

.groupbox > legend {
    padding: 0 6px;
    font-weight: 600;
}