/* ============================================================
   Supermarket POS - Custom Styles
   ============================================================ */

:root {
    --primary: #4e73df;
    --primary-dark: #2e59d9;
    --secondary: #858796;
    --success: #1cc88a;
    --info: #36b9cc;
    --warning: #f6c23e;
    --danger: #e74a3b;
    --light: #f8f9fc;
    --dark: #5a5c69;
    --sidebar-bg: #1e2a3a;
    --sidebar-hover: #2c3e57;
    --sidebar-active: #4e73df;
    --body-bg: #f0f2f5;
    --card-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
    --transition: all 0.3s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: #333;
    overflow-x: hidden;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 420px;
    width: 100%;
    padding: 2.5rem;
    animation: fadeInUp 0.5s ease;
}

.login-card .logo-area {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card .logo-area i {
    font-size: 3rem;
    color: var(--primary);
}

.login-card .logo-area h4 {
    margin-top: 0.5rem;
    font-weight: 700;
    color: var(--dark);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    transition: var(--transition);
    overflow-y: auto;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar .brand {
    display: flex;
    align-items: center;
    padding: 1.2rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
}

.sidebar .brand i {
    font-size: 1.6rem;
    color: #fff;
    margin-right: 0.7rem;
}

.sidebar .brand span {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.sidebar .nav-section {
    padding: 0.6rem 0;
}

.sidebar .nav-section .nav-label {
    padding: 0.5rem 1.2rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    font-weight: 700;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.2rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--primary);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--sidebar-active);
}

.sidebar .nav-link i {
    width: 22px;
    margin-right: 0.8rem;
    font-size: 1rem;
    text-align: center;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: 260px;
    transition: var(--transition);
    min-height: 100vh;
}

/* TOP BAR */
.topbar {
    background: #fff;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar .toggle-sidebar {
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--dark);
    border: none;
    background: none;
    padding: 0.3rem 0.5rem;
    border-radius: 0.3rem;
}

.topbar .toggle-sidebar:hover {
    background: var(--light);
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar .user-info .avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.content-wrapper {
    padding: 1.5rem;
}

/* ============================================================
   DASHBOARD CARDS
   ============================================================ */
.stat-card {
    border: none;
    border-radius: 0.8rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 2rem rgba(0,0,0,0.12);
}

.stat-card .card-body {
    padding: 1.3rem;
}

.stat-card .stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    font-weight: 600;
}

/* Color classes for stat icons */
.bg-gradient-primary { background: linear-gradient(135deg, #4e73df, #224abe); }
.bg-gradient-success { background: linear-gradient(135deg, #1cc88a, #13855c); }
.bg-gradient-info    { background: linear-gradient(135deg, #36b9cc, #258391); }
.bg-gradient-warning { background: linear-gradient(135deg, #f6c23e, #dda20a); }
.bg-gradient-danger  { background: linear-gradient(135deg, #e74a3b, #be2617); }

/* ============================================================
   CARD GENERAL
   ============================================================ */
.custom-card {
    border: none;
    border-radius: 0.8rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.custom-card .card-header {
    background: #fff;
    border-bottom: 1px solid #e3e6f0;
    padding: 1rem 1.25rem;
    border-radius: 0.8rem 0.8rem 0 0 !important;
    font-weight: 700;
    color: var(--dark);
}

.custom-card .card-body {
    padding: 1.25rem;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive {
    border-radius: 0.5rem;
}

.table thead th {
    background: var(--light);
    border-bottom: 2px solid #dee2e6;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dark);
    white-space: nowrap;
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 0.4rem; font-weight: 600; font-size: 0.85rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-xs { padding: 0.2rem 0.45rem; font-size: 0.72rem; }

.action-btns .btn { margin: 0 2px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-header {
    background: linear-gradient(135deg, #4e73df, #224abe);
    color: #fff;
    border-radius: 0;
}

.modal-header .close,
.modal-header .btn-close { color: #fff; opacity: 1; }

.modal-content { border: none; border-radius: 0.6rem; overflow: hidden; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-control, .form-select, .custom-select {
    border-radius: 0.4rem;
    border-color: #d1d3e2;
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
}

.form-control:focus, .form-select:focus, .custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
}

label { font-weight: 600; font-size: 0.85rem; color: var(--dark); margin-bottom: 0.3rem; }

/* ============================================================
   SALE PAGE
   ============================================================ */
.sale-items-table th,
.sale-items-table td {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.sale-items-table .form-control {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.sale-summary {
    background: var(--light);
    border-radius: 0.5rem;
    padding: 1rem;
}

.sale-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.95rem;
}

.sale-summary .summary-row.total {
    border-top: 2px solid var(--primary);
    padding-top: 0.6rem;
    margin-top: 0.3rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-collapsed .sidebar {
    margin-left: -260px;
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

@media (max-width: 992px) {
    .sidebar {
        margin-left: -260px;
    }
    .sidebar.show {
        margin-left: 0;
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 576px) {
    .content-wrapper {
        padding: 0.8rem;
    }
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    .topbar {
        padding: 0 0.8rem;
    }
    .page-title {
        font-size: 1.05rem;
    }
    .card-header {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }
    .btn-xs {
        padding: 0.15rem 0.35rem;
        font-size: 0.68rem;
    }
    /* Stack action buttons vertically on very small screens */
    #recentBillsTable .btn-xs {
        margin-bottom: 2px;
    }
    /* Flatpickr inputs on mobile */
    .flatpickr-input {
        font-size: 0.85rem;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-gradient {
    background: linear-gradient(135deg, #4e73df, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-pill { border-radius: 50rem; }

/* DataTable custom */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.3rem !important;
    margin: 0 2px;
}

div.dataTables_wrapper div.dataTables_length select {
    border-radius: 0.3rem;
    min-width: 60px;
    padding-right: 2rem;
}

/* Fix DataTables sorting icons overlapping header text */
table.dataTable thead th,
table.dataTable thead td {
    padding-right: 26px !important;
    position: relative;
}

table.dataTable thead .sorting:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_desc:after {
    position: absolute;
    right: 8px;
    font-size: 0.7rem;
    opacity: 0.3;
}

table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_desc:after {
    opacity: 1;
}

/* Ensure DataTables filter/length row doesn't overlap */
div.dataTables_wrapper div.dataTables_filter {
    margin-bottom: 0.5rem;
}
div.dataTables_wrapper div.dataTables_length {
    margin-bottom: 0.5rem;
}

/* Fix form-select inside DataTables (Show entries dropdown) */
div.dataTables_wrapper select.form-select {
    display: inline-block;
    width: auto;
    padding-right: 2rem;
}

/* Scroll bar styling */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 5px; }

/* Page title */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title i {
    color: var(--primary);
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}

@media (max-width: 992px) {
    .sidebar.show ~ .sidebar-overlay {
        display: block;
    }
}

/* No data illustration */
.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--secondary);
}
.no-data i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

/* Select2 size match for form-control-sm */
.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.2rem 0.5rem;
    font-size: 0.875rem;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding: 0;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    margin-top: 0.15rem;
}
