﻿/* ===========================
   Core theme variables
   =========================== */
:root {
    /* brand + neutrals */
    --bg: #f7f8fb;
    --card: #fff;
    --ink: #1f2430;
    --muted: #6b7280;
    --brand: #6a1f75;
    --brand-600: #5a1a64;
    /* layout + borders + shadows */
    --ring: rgba(0,0,0,.08);
    --border: rgba(0,0,0,.08);
    --shadow: 0 14px 32px rgba(0,0,0,.08);
    /* shell sizing */
    --sidebar-w: 240px;
    --header-h: 62px;
    /* legacy helpers */
    --rail: 64px;
    --container: 1120px;
}

/* ===========================
   App shell (global layout)
   =========================== */
html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 12px 14px;
    position: sticky;
    top: 0;
    z-index: 101;
}

/* brand row */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-h);
    padding: 0 6px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

    .brand img {
        display: block;
        height: 26px; /* clamp logo size */
        width: auto;
        max-width: 180px;
    }

/* nav */
.side-nav .nav-section {
    font-size: .78rem;
    font-weight: 700;
    color: #7a7a7a;
    letter-spacing: .04em;
    margin: 10px 8px 6px;
}

.side-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    margin: 4px 6px;
    color: #222;
    text-decoration: none;
    font-weight: 500;
    transition: background-color .15s ease;
}

    .side-nav .nav-link:hover {
        background: #e4daf2;
    }
    /* lavender hover */
    .side-nav .nav-link.active {
        background: #ebe3f6;
    }
/* lavender active */

/* small purple chip for icons */
.chip {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ebe3f6;
    color: var(--brand);
    border: 2px solid #e4daf2;
    flex: 0 0 auto;
}

.side-nav .nav-link.active .chip {
    color: var(--brand-600);
}

.chip i {
    font-size: 1.1rem;
    line-height: 1;
    display: block;
}

/* main column */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
    color: var(--ink);
}

.page-wrap {
    padding: 24px 32px;
    background: var(--bg);
}

.page-card {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.06);
}

/* ===========================
   Buttons – unify brand
   =========================== */
.btn {
    border-radius: 9999px;
    font-weight: 700;
    padding: 10px 14px;
}

.btn-sm {
    padding: .35rem .75rem !important;
}

.btn-lg {
    padding: .65rem 1.25rem !important;
}

.btn-primary {
    color: #fff !important;
    background-color: var(--brand) !important;
    border-color: var(--brand) !important;
}

    .btn-primary:hover,
    .btn-primary:focus {
        background-color: var(--brand-600) !important;
        border-color: var(--brand-600) !important;
    }

    .btn-primary:focus {
        box-shadow: 0 0 0 .25rem rgba(106,31,117,.25) !important;
    }

    .btn-primary:disabled {
        opacity: .65 !important;
    }

.btn-outline-primary {
    color: var(--brand) !important;
    border-color: var(--brand) !important;
    background-color: transparent !important;
}

    .btn-outline-primary:hover {
        color: #fff !important;
        background-color: var(--brand) !important;
        border-color: var(--brand) !important;
    }

.btn-outline-secondary {
    color: #5b6b7a !important;
    border-color: #c8cfd6 !important;
    background-color: transparent !important;
}

    .btn-outline-secondary:hover {
        color: #fff !important;
        background-color: #5b6b7a !important;
        border-color: #5b6b7a !important;
    }

/* ===========================
   Tables
   =========================== */
.table {
    width: 100%;
}

/* ===========================
   Audit tabs + Pagination
   =========================== */
.audit-tabs .nav-link {
    font-weight: 700;
    color: var(--muted);
    border: 1px solid var(--ring);
    background: #fff;
    border-radius: 999px;
    padding: .5rem 1rem;
    transition: background .15s, color .15s, box-shadow .15s, border-color .15s;
    margin-right: .35rem;
}

    .audit-tabs .nav-link:hover {
        color: var(--brand);
        background: #f6f0fa;
        border-color: #e7dbef;
    }

    .audit-tabs .nav-link.active {
        color: #fff !important;
        background: var(--brand) !important;
        border-color: var(--brand) !important;
        box-shadow: 0 2px 8px rgba(106,31,117,.25);
    }

.pagination .page-link {
    color: var(--brand);
    border-radius: 8px;
    border-color: #e6e6ef;
}

    .pagination .page-link:hover {
        background-color: rgba(106,31,117,0.08);
        border-color: var(--brand);
        color: var(--brand);
    }

.pagination .page-item.active .page-link {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 .2rem rgba(106,31,117,.25);
    outline: none;
}

/* ===========================
   Cards / reports (kept)
   =========================== */
.report-card {
    cursor: pointer;
    transition: transform .06s ease, box-shadow .15s ease;
}

    .report-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 12px 28px rgba(0,0,0,.08);
    }

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 8px;
}

@media (max-width:1080px) {
    .report-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width:720px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
}

.report-card {
    background: #fff;
    border: 1px solid var(--ring);
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.rc-head {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.rc-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: #f2e9f6;
    border: 1px solid rgba(106,31,117,.28);
    color: var(--brand);
}

    .rc-ico .ico {
        width: 22px;
        height: 22px;
        display: block;
    }

/* ===========================
   Misc helpers kept from original
   =========================== */
.page-bg {
    background: var(--bg);
}

.container-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.container-global {
    max-width: 90%;
    margin: 0 auto;
}

.section {
    padding: 28px 0;
}

/* Responsive tweaks */
@media (max-width:980px) {
    :root {
        --rail: 56px;
        --sidebar-w: 220px;
    }

    .brand img {
        height: 24px;
    }

    .container-global {
        max-width: 94%;
    }
}

@media (max-width:640px) {
    .audit-tabs .nav-link {
        padding: .45rem .85rem;
    }
}

/* ===== Header rail (thin purple line under topbar) ===== */
.topbar {
    box-shadow: 0 1px 0 rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

    .topbar::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: -1px;
        height: 4px;
        background: linear-gradient(90deg, #6d2577 0%, #8a34a0 50%, #6d2577 100%);
        opacity: .75;
    }

/* ===== Section title with hairline divider ===== */
.e-section-title {
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 .5rem 0;
}

.e-section-rule {
    height: 1px;
    background: rgba(109,37,119,.22);
    margin: .75rem 0 1rem 0;
}

/* ===== Cards matching reference ===== */
.e-card {
    background: #fff;
    border: 1px solid rgba(109,37,119,.10);
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(0,0,0,.06);
}

.e-card-lg {
    border-radius: 18px;
}

.e-card-pad {
    padding: 18px;
}

.e-card-muted {
    background: linear-gradient(180deg,#faf7fc 0%, #ffffff 18%);
}

/* ===== Segmented tabs (single row) ===== */
.segmented {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #fff;
    border: 1px solid rgba(109,37,119,.18);
    border-radius: 12px;
    padding: 6px;
    width: 100%;
}

    .segmented .seg {
        flex: 1 1 auto;
        text-align: center;
        font-weight: 800;
        color: #5b6b7a;
        padding: .55rem .75rem;
        border-radius: 10px;
        letter-spacing: .02em;
        user-select: none;
        cursor: pointer;
    }

        .segmented .seg:hover {
            background: #f6f0fa;
            color: #571d5f;
        }

        .segmented .seg.active {
            background: #efe7f8;
            color: #6d2577;
            box-shadow: inset 0 0 0 2px #ccb9e8;
        }

        .segmented .seg.badge {
            flex: 0 0 auto;
            font-weight: 700;
            min-width: 64px;
        }

/* ===== Gradient CTA ===== */
.btn-gradient {
    border: 0 !important;
    color: #fff !important;
    background: linear-gradient(90deg,#6d2577 0%, #8a34a0 50%, #6d2577 100%) !important;
    box-shadow: 0 8px 18px rgba(109,37,119,.25);
}

    .btn-gradient:hover,
    .btn-gradient:focus {
        filter: brightness(.96);
        box-shadow: 0 10px 22px rgba(109,37,119,.32);
    }

.btn-soft {
    background: #f3eaf8 !important;
    border: 1px solid #e4daf2 !important;
    color: #571d5f !important;
}

    .btn-soft:hover {
        background: #efe4f7 !important;
    }

/* ===== Elevated data table ===== */
.table-elevated {
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(0,0,0,.06);
    background: #fff;
}

    .table-elevated thead th {
        background: linear-gradient(180deg,#efe7f8 0%, #ffffff 60%);
        color: #3a3a3a;
        border-bottom: 1px solid rgba(0,0,0,.08);
        font-weight: 800;
    }

    .table-elevated tbody tr:nth-child(odd) {
        background: rgba(109,37,119,.03);
    }

    .table-elevated td, .table-elevated th {
        padding: .65rem .75rem;
    }

.badge-pass {
    color: #198754;
    font-weight: 800;
}

.badge-fail {
    color: #c03221;
    font-weight: 800;
}

/* ===== Branded form focus ===== */
.form-control, .form-select, .form-check-input {
    border-radius: 12px;
    border-color: #d9c8e6;
}

    .form-control:focus, .form-select:focus {
        border-color: #6d2577;
        box-shadow: 0 0 0 .2rem rgba(109,37,119,.20);
    }

    .form-check-input:checked {
        background-color: #6d2577;
        border-color: #6d2577;
    }

.form-hint {
    color: #6b7280;
    font-size: .9rem;
}

/* pill radios (Yes/No) */
.pill-radio .form-check {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .75rem;
    border: 1px solid #e4daf2;
    border-radius: 999px;
    margin-right: .35rem;
    cursor: pointer;
}

    .pill-radio .form-check:hover {
        background: #f6f0fa;
    }

/* ===== Stat chip & mini icon ===== */
.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border: 1px solid #e4daf2;
    border-radius: 999px;
    padding: .35rem .6rem;
    background: #f7f1fb;
    color: #571d5f;
    font-weight: 700;
}

.mini-ico {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f2e9f6;
    border: 1px solid rgba(109,37,119,.28);
}

/* ===== soft diagonal panel like the chart area (optional) ===== */
.panel-diag {
    background-image: repeating-linear-gradient(135deg, rgba(109,37,119,.06) 0, rgba(109,37,119,.06) 12px, rgba(109,37,119,0) 12px, rgba(109,37,119,0) 24px);
}

/* spacing & shadows */
.gap-6 {
    gap: 1.25rem;
}

.gap-8 {
    gap: 1.5rem;
}

.shadow-smooth {
    box-shadow: 0 12px 28px rgba(0,0,0,.08);
}

.round-12 {
    border-radius: 12px;
}

.round-16 {
    border-radius: 16px;
}

/* small, muted label used in header bands */
.kv-label {
    color: #6b7280;
    font-weight: 800;
    letter-spacing: .08em;
    font-size: .72rem;
    text-transform: uppercase;
}

/* Card & Table Headers - Soft Lavender */
.e-card-header,
.table-elevated thead th {
    background: #f3eaf8; /* light purple background */
    color: #571d5f; /* darker text for contrast */
    font-weight: 700;
    border-bottom: 1px solid #e4daf2;
}

.table-elevated thead th {
    text-transform: uppercase;
    font-size: .82rem;
    letter-spacing: .04em;
}

/* Gradient Button Style */
.btn-primary,
.btn-gradient {
    border: 0 !important;
    color: #fff !important;
    background: linear-gradient(90deg, #6d2577 0%, #8a34a0 50%, #6d2577 100%) !important;
    box-shadow: 0 4px 10px rgba(109,37,119,.25);
    font-weight: 700;
    letter-spacing: .02em;
}

    .btn-primary:hover,
    .btn-gradient:hover,
    .btn-primary:focus,
    .btn-gradient:focus {
        filter: brightness(0.95);
        box-shadow: 0 6px 14px rgba(109,37,119,.32);
    }

/* Gradient Buttons with Slightly Rounded Corners */
.btn-primary,
.btn-gradient {
    border: 0 !important;
    border-radius: 8px !important; /* More square corners */
    color: #fff !important;
    background: linear-gradient(90deg, #6d2577 0%, #8a34a0 50%, #6d2577 100%) !important;
    box-shadow: 0 4px 10px rgba(109,37,119,.25);
    font-weight: 700;
    letter-spacing: .02em;
    transition: all .15s ease;
    padding: 10px 18px;
}

    .btn-primary:hover,
    .btn-gradient:hover,
    .btn-primary:focus,
    .btn-gradient:focus {
        filter: brightness(0.95);
        box-shadow: 0 6px 14px rgba(109,37,119,.32);
    }

/* ========= Unified Elephas UI polish (place at END of ordering.css) ========= */
.ele-theme {
    --ele-brand-500: #6d2577;
    --ele-brand-600: #5a1a64;
    --ele-grad-left: #6d2577;
    --ele-grad-mid: #8a34a0;
    --ele-grad-right: #6d2577;
    --ele-soft-50: #f5ecfb; /* light lavender fill */
    --ele-soft-100: #efe3f7; /* table/card header */
    --ele-soft-200: #e8d8f4; /* borders/stripes */
    --ele-border: #e6dff0;
}

    /* ---- Cards ---- */
    .ele-theme .card {
        border: 1px solid var(--ele-border) !important;
        border-radius: 14px !important;
        box-shadow: 0 8px 24px rgba(109,37,119,.06);
        background: #fff;
    }

        /* Card headers: soft lavender like reference */
        .ele-theme .card-header,
        .ele-theme .card .card-header,
        .ele-theme .page-card > .card-header {
            background: var(--ele-soft-100) !important;
            border-bottom: 1px solid var(--ele-border) !important;
            color: #2d2341;
            font-weight: 700;
        }

    /* ---- Tables ---- */
    /* header cells */
    .ele-theme table thead th,
    .ele-theme .table thead th,
    .ele-theme .table thead td,
    .ele-theme .table-light th,
    .ele-theme .table-light td {
        background: var(--ele-soft-100) !important;
        color: #2d2341 !important;
        border-bottom: 1px solid var(--ele-border) !important;
    }

    /* table outer border look */
    .ele-theme .table,
    .ele-theme .table > :not(caption) > * > th,
    .ele-theme .table > :not(caption) > * > td {
        border-color: var(--ele-border) !important;
    }

    /* optional: zebra rows very subtle */
    .ele-theme .table-striped > tbody > tr:nth-of-type(odd) > * {
        background: var(--ele-soft-50);
    }

    /* ---- Inputs/selects to match corners ---- */
    .ele-theme .form-control,
    .ele-theme .form-select,
    .ele-theme .input-group .form-control {
        border-radius: 8px !important;
        border-color: var(--ele-border);
    }

    /* ---- Buttons: fix shape + gradient ---- */
    /* override the pill rule from the layout */
    .ele-theme .btn {
        border-radius: 8px !important;
    }

    /* gradient primary */
    .ele-theme .btn-primary,
    .ele-theme .btn-gradient,
    .ele-theme .table .btn.btn-primary {
        border: 0 !important;
        color: #fff !important;
        background: linear-gradient(90deg, var(--ele-grad-left) 0%, var(--ele-grad-mid) 50%, var(--ele-grad-right) 100%) !important;
        box-shadow: 0 4px 12px rgba(109,37,119,.22);
        font-weight: 700;
        letter-spacing: .01em;
    }

        .ele-theme .btn-primary:hover,
        .ele-theme .btn-gradient:hover,
        .ele-theme .btn-primary:focus,
        .ele-theme .btn-gradient:focus {
            filter: brightness(.96);
            box-shadow: 0 6px 16px rgba(109,37,119,.28);
        }

    /* outline stays square and on-brand */
    .ele-theme .btn-outline-primary {
        border-radius: 8px !important;
        border-color: var(--ele-brand-500) !important;
        color: var(--ele-brand-500) !important;
        background: #fff !important;
    }

        .ele-theme .btn-outline-primary:hover,
        .ele-theme .btn-outline-primary:focus {
            color: #fff !important;
            background: linear-gradient(90deg, var(--ele-grad-left), var(--ele-grad-mid), var(--ele-grad-right)) !important;
            border-color: transparent !important;
        }

    /* Action chips (e.g., small buttons in tables) keep same radius */
    .ele-theme .btn-sm {
        border-radius: 8px !important;
    }

    /* ---- Utility: soft section headers / filters row ---- */
    .ele-theme .soft-header,
    .ele-theme .filter-bar {
        background: var(--ele-soft-50);
        border: 1px solid var(--ele-border);
        border-radius: 12px;
    }

    /* ---- Zebra striping for table rows ---- */
    .ele-theme table tbody tr:nth-child(odd) {
        background-color: var(--ele-soft-50) !important; /* light lavender */
    }

    .ele-theme table tbody tr:nth-child(even) {
        background-color: #fff !important; /* normal white for contrast */
    }

    /* Keep hover effect subtle */
    .ele-theme table tbody tr:hover {
        background-color: var(--ele-soft-100) !important; /* slightly deeper lavender */
    }
    /* ==== Global zebra striping (light gray) ==== */
    .ele-theme .table tbody tr:nth-child(odd) > *,
    .ele-theme table tbody tr:nth-child(odd) td,
    .ele-theme table tbody tr:nth-child(odd) th {
        background-color: #f9f9f9 !important; /* light gray stripe */
    }

    .ele-theme .table tbody tr:nth-child(even) > *,
    .ele-theme table tbody tr:nth-child(even) td,
    .ele-theme table tbody tr:nth-child(even) th {
        background-color: #fff !important; /* normal white rows */
    }

    /* Hover effect with slightly darker gray */
    .ele-theme .table-hover tbody tr:hover > *,
    .ele-theme table tbody tr:hover > * {
        background-color: #f1f1f1 !important;
        transition: background-color .15s ease;
    }

    /* Override Bootstrap's built-in striping so ours wins */
    .ele-theme .table.table-striped > :not(caption) > * > * {
        --bs-table-accent-bg: transparent;
    }

    .ele-theme .table.table-striped tbody tr:nth-of-type(odd) > * {
        background-color: #f9f9f9 !important;
    }

    .badge-elephas {
      background-color: var(--ele-purple, #6d2577) !important;
      color: #fff !important;
  }

/* history icon button */
.btn-history {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px; /* a bit larger tap target */
    border-radius: 12px;
    padding: 0;
    border: 1px solid rgba(109,37,119,.25);
    background: #fff;
    transition: background .15s, box-shadow .15s, border-color .15s;
    line-height: 0; /* prevent font-size from affecting SVG */
}

    .btn-history:hover {
        background: #f6f2fa;
        border-color: rgba(109,37,119,.45);
        box-shadow: 0 2px 6px rgba(0,0,0,.08);
    }
    /* force SVG size */
    .btn-history .ico {
        width: 25px !important;
        height: 25px !important;
        display: block;
        color: var(--ele-purple, #6d2577);
        fill: currentColor;
    }

    /* Force clock size inside .btn-history */
.btn-history svg.ico {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px;
  min-height: 20px;
  display: inline-block;
  vertical-align: middle;
}

/* Make the button itself square and bigger */
.btn-history {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  line-height: 1; /* avoids shrinking due to Bootstrap */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: auto;
}

.loading-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
}

.loading-spinner-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
/* Global loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
}

.loading-overlay-visible {
    opacity: 1;
    pointer-events: auto;
}

.loading-backdrop {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(3px);
    background-color: rgba(0, 0, 0, 0.45);
}

.loading-spinner-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-text {
    font-size: 0.95rem;
}
