@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* -- core palette -- */
    --ink: #0a0b0d;
    --ink-soft: #23262c;
    --paper: #f5f4f0;
    --surface: #ffffff;
    --border: #e6e2d8;
    --text: #1f2124;
    --text-muted: #6b6f7a;

    --gold: #b9873c;
    --gold-dark: #93692a;
    --gold-tint: rgba(185, 135, 60, 0.12);

    --navy: #33507a;
    --navy-tint: rgba(51, 80, 122, 0.12);

    --success: #3f7d58;
    --success-tint: rgba(63, 125, 88, 0.12);

    --danger: #b6473f;
    --danger-tint: rgba(182, 71, 63, 0.12);

    /* -- legacy aliases (kept so nothing else that reads these breaks) -- */
    --brand-dark: var(--ink);
    --brand-accent: var(--gold);

    --sidebar-width: 250px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --shadow-card:
        0 14px 30px rgba(20, 20, 25, 0.07), 0 2px 6px rgba(20, 20, 25, 0.04);
}

* {
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}

h1,
h2,
h3,
h4,
.brand-text,
.card-title,
.stat-card-value,
.product-header h1 {
    font-family: 'Sora', sans-serif;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    min-height: 100vh;
    background: var(--ink);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    flex: 0 0 var(--sidebar-width);
}

@media (min-width: 769px) {
    .sidebar.offcanvas-md {
        background-color: var(--ink) !important;
        background-image: none !important;
        color: #ffffff;
    }
}

.app-shell {
    height: 100vh;
    min-height: 100vh;
    align-items: flex-start;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px 22px;
    position: relative;
}

.sidebar-brand::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 0;
    height: 2px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--gold) 0 6px,
        transparent 6px 12px
    );
    opacity: 0.9;
}

.sidebar-logo {
    width: 75px;
    height: 100px;
    object-fit: contain;
}

.brand-text {
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 0.01em;
    color: #ffffff;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #999ca6;
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 4px;
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.nav-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.nav-link.active {
    background: linear-gradient(
        90deg,
        rgba(185, 135, 60, 0.2),
        rgba(185, 135, 60, 0.02)
    );
    color: #f2d9ac;
    border-left: 3px solid var(--gold);
    font-weight: 600;
}

/* ---------- Main content ---------- */
.main-content {
    flex: 1;
    height: 100vh;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 0 30px 30px;
    position: relative;
}

.sidebar-toggle {
    display: none;
    border: 1px solid var(--border);
    color: var(--ink);
    background: var(--surface);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.content-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    min-height: 74px;
    padding: 16px 30px;
    background: rgba(245, 244, 240, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    width: calc(100% + 60px);
    margin: 0 -30px 20px;
    box-sizing: border-box;
}

.topbar-search input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.topbar-search button {
    border: none;
    background: var(--ink);
    color: white;
    padding: 0 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.topbar-user .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.topbar-user .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* Dropdown adjustments for topbar avatar menu */
.topbar-user.dropdown {
    position: relative;
}
.topbar-user .dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}
.topbar-user .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 175px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    padding: 6px;
}
.topbar-user .dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
}
.topbar-user .dropdown-item:hover {
    background: var(--paper);
}
.topbar-user .dropdown-item i {
    margin-right: 8px;
    color: var(--text-muted);
}

/* ---------- Statistic cards ---------- */
.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--shadow-card);
    min-height: 150px;
}

.stat-card-label {
    position: relative;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 12px;
}

.stat-card-label::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 34px;
    height: 2px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--gold) 0 5px,
        transparent 5px 9px
    );
}

.stat-card-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

.stat-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 22px;
    color: #1f2937;
    flex-shrink: 0;
}

.bg-primary-light {
    background: var(--gold-tint);
    color: var(--gold-dark);
}

.bg-success-light {
    background: var(--success-tint);
    color: var(--success);
}

.bg-info-light {
    background: var(--navy-tint);
    color: var(--navy);
}

.bg-warning-light {
    background: rgba(185, 135, 60, 0.18);
    color: var(--gold-dark);
}

.stat-card-primary .stat-card-icon,
.stat-card-success .stat-card-icon,
.stat-card-info .stat-card-icon,
.stat-card-warning .stat-card-icon {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.stat-progress {
    height: 10px;
    border-radius: 999px;
    background: #ece9e2;
    margin-top: 12px;
}

.stat-progress .progress-bar {
    border-radius: 999px;
    background: var(--gold);
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 22px 24px 16px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.card-body {
    padding: 20px 24px 24px;
}

.card-body canvas:not(#stockChart) {
    width: 100% !important;
    height: auto !important;
    max-height: 300px;
}

.stock-chart-container {
    height: 300px;
    position: relative;
    width: 100%;
}

.recent-payout-table {
    overflow-x: auto;
}

.recent-payout-table table {
    min-width: 620px;
}

#stockChart {
    height: 100% !important;
    width: 100% !important;
}

.chartjs-render-monitor {
    border-radius: 18px;
}

/* ---------- Bootstrap element overrides (kept brand-consistent) ---------- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: #201404;
}
.btn-primary:hover,
.btn-primary:focus {
    background: var(--gold-dark);
    border-color: var(--gold-dark);
    color: #ffffff;
}
.btn-primary:focus {
    box-shadow: 0 0 0 0.2rem rgba(185, 135, 60, 0.3);
}

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    background: var(--paper);
    border-color: var(--ink);
    color: var(--ink);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}
.btn-success:hover {
    background: #336749;
    border-color: #336749;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

button:active,
button.active,
.btn:active,
.btn.active,
.btn:focus:active {
    background-color: #eaeaea !important;
    border-color: #7f7f7f !important;
    color: #000000 !important;
    box-shadow: none !important;
}

.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: 10px;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 0.2rem rgba(185, 135, 60, 0.18);
}

.form-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.alert {
    border-radius: 12px;
    border: 1px solid transparent;
}
.alert-warning {
    background: rgba(185, 135, 60, 0.12);
    border-color: rgba(185, 135, 60, 0.3);
    color: #7a5620;
}
.alert-danger {
    background: var(--danger-tint);
    border-color: rgba(182, 71, 63, 0.3);
    color: #7a2b25;
}
.alert-success {
    background: var(--success-tint);
    border-color: rgba(63, 125, 88, 0.3);
    color: #245c3a;
}

.modal-content {
    border-radius: 18px;
    border: none;
    box-shadow: var(--shadow-card);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
}
.modal-header .modal-title {
    font-weight: 700;
    font-family: 'Sora', sans-serif;
}
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

/* ---------- Product page ---------- */
.product-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.product-header h1 {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--text);
}

.dashboard-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 1rem;
    width: 100%;
}

.dashboard-header-row h1 {
    min-width: 0;
}

.dashboard-header-row #report_download {
    flex: 0 0 auto;
    white-space: nowrap;
}

.product-breadcrumb {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.product-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    color: #cbc6b8;
}

.product-breadcrumb a {
    color: var(--gold-dark);
    text-decoration: none;
    font-weight: 600;
}

.product-alert {
    margin-bottom: 1.5rem;
}

.product-card {
    background: var(--surface);
    border-radius: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.product-card .card-header {
    background: linear-gradient(
        90deg,
        rgba(185, 135, 60, 0.1),
        rgba(255, 255, 255, 0.6)
    );
    border-bottom: 1px solid var(--border);
    padding: 1.35rem 1.5rem;
    position: relative;
}

.product-card .card-header::after {
    content: '';
    position: absolute;
    left: 1.5rem;
    right: 1.5rem;
    bottom: 0;
    height: 2px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--gold) 0 6px,
        transparent 6px 12px
    );
    opacity: 0.55;
}

.product-card .card-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
}

.product-card .card-body {
    padding: 1.75rem 1.75rem 2rem;
}

.product-card .table-responsive {
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;
    border-radius: 1rem;
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: 0 0 0 1px var(--border);
}

.product-card .table-responsive:last-child {
    margin-bottom: 0;
}

.product-card table.table {
    width: 100%;
    min-width: 1100px;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.product-card table.table th:last-child,
.product-card table.table td:last-child {
    min-width: 180px;
    white-space: nowrap;
}

.product-card table.table td:last-child .d-flex {
    justify-content: flex-end;
    gap: 0.5rem;
}

.product-card table.table thead th {
    background: #f2efe7;
    color: #3a3d44;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    padding: 1rem 1rem;
}

.product-card table.table tbody tr:hover {
    background: rgba(185, 135, 60, 0.07);
}

.product-card table.table td,
.product-card table.table th {
    vertical-align: middle;
    padding: 0.95rem 1rem;
}

/* DataTables 2.x (dt-3.0.1) uses new class names: dt-container, dt-length,
   dt-search, dt-info, dt-paging — NOT the old dataTables_wrapper family. */
.product-card .dt-container {
    width: 100%;
    padding: 0 0.25rem;
}

.product-card .dt-container .dt-layout-row:first-child {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.product-card .dt-length,
.product-card .dt-search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-card .dt-length label,
.product-card .dt-search label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.product-card .dt-length select,
.product-card .dt-search input {
    min-width: 120px;
    border-radius: 0.7rem;
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    background: #ffffff;
}

.product-card .dt-length select:focus,
.product-card .dt-search input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 0.15rem rgba(185, 135, 60, 0.18);
}

.product-card .dt-container .dt-layout-row:has(.dt-info) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1.25rem;
}

.product-card .dt-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.product-card .dt-paging {
    margin: 0;
}

.product-card .dt-paging .dt-paging-list {
    display: flex;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.product-card .dt-paging .dt-paging-button {
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    color: var(--text);
    min-width: 40px;
    padding: 0.4rem 0.7rem;
    text-align: center;
    background: #ffffff;
    cursor: pointer;
}

.product-card .dt-paging .dt-paging-button.current {
    background: var(--gold);
    border-color: var(--gold);
    color: #201404;
    font-weight: 700;
}

.product-card .dt-paging .dt-paging-button:not(.disabled):hover {
    background: var(--gold-tint);
    color: var(--gold-dark);
}

.product-card .dt-paging .dt-paging-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* legacy DataTables 1.x classes kept as a harmless fallback,
   in case any page still loads the old build */
.product-card .dataTables_wrapper {
    width: 100%;
}

.product-card .dataTables_wrapper .dataTables_length,
.product-card .dataTables_wrapper .dataTables_filter {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.product-card .dataTables_wrapper .dataTables_length select,
.product-card .dataTables_wrapper .dataTables_filter input {
    min-width: 120px;
    border-radius: 0.7rem;
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    background: #ffffff;
}

.product-card .dataTables_wrapper .dataTables_length select:focus,
.product-card .dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 0.15rem rgba(185, 135, 60, 0.18);
}

.product-card .dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.product-card .dataTables_wrapper .dataTables_filter label,
.product-card .dataTables_wrapper .dataTables_length label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.product-card .dataTables_wrapper .dataTables_paginate {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.product-card .dataTables_wrapper .dataTables_paginate .pagination {
    margin: 0;
}

.product-card .dataTables_wrapper .dataTables_paginate .page-item .page-link {
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    color: var(--text);
    min-width: 40px;
    text-align: center;
}

.product-card
    .dataTables_wrapper
    .dataTables_paginate
    .page-item.active
    .page-link {
    background: var(--gold);
    border-color: var(--gold);
    color: #201404;
    font-weight: 700;
}

.product-card
    .dataTables_wrapper
    .dataTables_paginate
    .page-item
    .page-link:hover {
    background: var(--gold-tint);
    color: var(--gold-dark);
}

@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .app-shell {
        height: 100dvh;
        min-height: 100dvh;
    }

    .sidebar.offcanvas-md {
        width: min(86vw, var(--sidebar-width));
        height: 100dvh;
        min-height: 100dvh;
        border: 0;
        position: fixed;
        top: 0;
    }

    .main-content {
        height: 100dvh;
        padding: 0 16px 24px;
    }

    .content-topbar {
        justify-content: space-between;
        width: calc(100% + 32px);
        margin-left: -16px;
        margin-right: -16px;
        padding: 12px 16px;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .product-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .product-card .dt-container .dt-layout-row:first-child,
    .product-card .dataTables_wrapper .dataTables_length,
    .product-card .dataTables_wrapper .dataTables_filter {
        justify-content: space-between;
    }
}

@media print {
    /* hide anything not meant for the printed report */
    .no-print {
        display: none !important;
    }

    /* reclaim full width now that the sidebar is gone */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .app-shell {
        height: auto !important;
        min-height: 0 !important;
    }

    .sidebar {
        position: static !important;
        height: auto !important;
        min-height: 0 !important;
    }

    /* page margin - space from the physical paper edge */
    @page {
        margin: 1.5cm;
    }

    /* center the report content with its own breathing room */
    .container-fluid {
        max-width: 900px;
        margin: 0 auto !important;
        padding: 0 20px !important;
    }

    /* a little top spacing so the title isn't flush against the page edge */
    .product-header {
        margin-top: 20px !important;
    }

    /* one page per report section */
    #salesSection,
    #liveViewsSection,
    #employeeSection,
    #payoutSection,
    #inventorySection {
        page-break-before: always;
        break-before: page;
    }

    /* whichever section actually renders first (set by JS) skips the leading break */
    .first-print-section {
        page-break-before: auto !important;
        break-before: auto !important;
    }

    /* let content flow inside a section if it's long (e.g. Employee/Inventory tables) */
    #salesSection,
    #liveViewsSection,
    #employeeSection,
    #payoutSection,
    #inventorySection,
    .card {
        page-break-inside: auto;
        break-inside: auto;
    }

    /* never slice a stat card or table row in half */
    .row,
    .card.border-0.bg-light,
    tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* repeat table column headers on every page a table spans */
    thead {
        display: table-header-group;
    }

    /* keep a section/card title glued to the content right after it */
    h5.fw-bold {
        page-break-after: avoid;
        break-after: avoid;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-bottom: 1px solid #ddd !important;
        margin-bottom: 20px !important;
    }

    .card-body {
        padding: 0 !important;
    }
}
