/* 
    Inventory & Sales Manager - Design System 
    Modern, Premium, Glassmorphism, Responsive
    Version 2.0 — Full Mobile Support
*/

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

/* ══════════════════════════════════════════════════════════════════
   CSS VARIABLES — Light / Dark Mode
══════════════════════════════════════════════════════════════════ */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f43f5e;
    --accent-color: #10b981;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --card-bg: rgba(255, 255, 255, 0.72);
    --card-border: rgba(255, 255, 255, 0.55);
    --input-border: #1f2225;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #ffffff;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.18);
    --sidebar-width: 270px;
}

[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --secondary-color: #fb7185;
    --accent-color: #34d399;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(30, 41, 59, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --input-border: #475569;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --sidebar-bg: #1e293b;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.05);
}

/* ══════════════════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════════════════ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background .3s, color .3s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════
   GLASS CARD
══════════════════════════════════════════════════════════════════ */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    transition: transform .25s ease, box-shadow .25s ease;
}

/* Only lift on hover for non-table-row elements */
.glass-card:not(td):not(tr):hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 48px 0 rgba(31, 38, 135, 0.12);
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    padding: 1.75rem 1.25rem;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: left .35s cubic-bezier(.4, 0, .2, 1), box-shadow .35s;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
    padding-left: .5rem;
}

.sidebar-logo span {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ── Nav Links ── */
.nav-list {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: .88rem;
    transition: all .25s ease;
    margin-bottom: 4px;
}

.nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, .28);
}

/* Section label */
.nav-section-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 700;
    padding: .75rem 1rem .3rem;
    margin-top: .5rem;
}

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 1.75rem;
    min-height: 100vh;
    transition: margin .35s ease;
}

/* ── Top Navbar ── */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: .75rem;
}

/* ══════════════════════════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════════════════════════ */
.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 18px;
}

.stat-icon {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}

.bg-sales {
    background: linear-gradient(135deg, #6366f1, #818cf8);
}

.bg-purchases {
    background: linear-gradient(135deg, #f43f5e, #fb7185);
}

.bg-profit {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.bg-stock {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════════ */
.btn-primary {
    background: var(--primary-color);
    border: none;
    padding: 10px 22px;
    border-radius: 12px;
    font-weight: 600;
    transition: all .25s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.btn:focus {
    box-shadow: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   TABLES — Mobile Friendly
══════════════════════════════════════════════════════════════════ */
.table {
    color: var(--text-main);
}

.table th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table td {
    padding: .7rem 1rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: background .15s;
}

.table-hover tbody tr:hover {
    background: rgba(99, 102, 241, .04);
}

/* Make tables scroll horizontally on small screens */
.table-responsive {
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

/* ══════════════════════════════════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════════════════════════════════ */
.form-control,
.form-select,
.input-group-text {
    background: var(--card-bg);
    border: 1px solid grey;
    color: var(--text-main);
    border-radius: 10px;
    transition: border-color .2s, box-shadow .2s;
}

.form-control:focus,
.form-select:focus {
    background: var(--card-bg);
    color: var(--text-main);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

/* ══════════════════════════════════════════════════════════════════
   MODAL STYLING
══════════════════════════════════════════════════════════════════ */
.modal-content {
    background: var(--sidebar-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
}

.modal-header,
.modal-footer {
    border-color: var(--card-border) !important;
}

/* ══════════════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════════════ */
.badge {
    font-weight: 600;
    letter-spacing: .3px;
}

/* ══════════════════════════════════════════════════════════════════
   PRODUCT CARD (POS)
══════════════════════════════════════════════════════════════════ */
.product-card {
    cursor: pointer;
    transition: all .2s ease;
    border: 1.5px solid transparent !important;
    background: var(--card-bg);
    border-radius: 14px;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color) !important;
    box-shadow: 0 8px 24px rgba(99, 102, 241, .18);
}

/* ══════════════════════════════════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════════════════════════════════ */
@media print {

    .sidebar,
    .top-nav,
    .btn,
    .nav-link,
    #notifDropdown {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .glass-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  (≤ 992px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
    }

    .sidebar.show {
        left: 0;
        box-shadow: 6px 0 28px rgba(0, 0, 0, .18);
    }

    /* Dim overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1049;
    }

    .sidebar.show~.sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 12px;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 1.1rem;
    }

    /* Stack page-header row */
    .page-header-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .75rem;
    }

    /* Smaller period btn-group */
    .btn-group .btn {
        padding: .3rem .65rem;
        font-size: .8rem;
    }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤ 576px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    .main-content {
        padding: .75rem;
    }

    h4.fw-bold {
        font-size: 1.1rem;
    }

    h5.fw-bold {
        font-size: 1rem;
    }

    h3.fw-bold {
        font-size: 1.2rem;
    }

    .glass-card {
        border-radius: 14px;
    }

    .top-nav {
        margin-bottom: 1rem;
    }

    /* KPI cards: 2-per-row on extra-small */
    .col-6.col-xl-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Notification menu full-width on mobile */
    #notifMenu {
        width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 0 16px 16px !important;
    }

    /* Stack modal on mobile */
    .modal-dialog {
        margin: .5rem;
    }

    /* Table font size */
    .table th,
    .table td {
        font-size: .78rem;
        padding: .55rem .6rem;
    }

    /* DataTables override */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
        float: none !important;
        margin-bottom: .5rem;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: left !important;
    }

    /* POS layout: stacked on mobile */
    .pos-grid {
        flex-direction: column;
    }

    /* Sidebar full width on mobile */
    :root {
        --sidebar-width: 85vw;
    }

    /* Summary number */
    .fs-5 {
        font-size: 1rem !important;
    }

    /* Assignment page stat cards */
    .stat-card .stat-icon {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE TABLE RESPONSIVENESS
   NOTE: #staffTable mobile card-view CSS removed — display:block/flex
   on <tr>/<td> before DataTables init causes "Incorrect column count"
   (tn/18). Mobile responsiveness is handled by DataTables responsive:true.
══════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════
   ANIMATION HELPERS
══════════════════════════════════════════════════════════════════ */
.fade-in-up {
    animation: fadeInUp .4s ease both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress bars */
.progress {
    background: rgba(0, 0, 0, .06);
}

[data-theme="dark"] .progress {
    background: rgba(255, 255, 255, .08);
}

/* Scrollbar — global */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}