/* ==========================================================================
   EXECUTIVE ADMIN SYSTEM - IQOS ADMINISTRATION V2
   Corporate Slate & Dark Theme, Refined Enterprise Typography, Standard Grid Ratios
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Font Family */
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Light Theme Variables - Soothing Soft Aqua/Mint Workspace */
    --bg-body: linear-gradient(135deg, #e4f7f4 0%, #d5f2ec 40%, #e0f2fe 100%);
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --border-card: #e2e8f0;
    --border-subtle: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-heading: #0f172a;

    /* Sidebar Executive Navy Theme */
    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-link-color: #94a3b8;
    --sidebar-link-hover-bg: rgba(255, 255, 255, 0.07);
    --sidebar-link-hover-color: #ffffff;
    --sidebar-link-active-bg: #2563eb;
    --sidebar-link-active-color: #ffffff;

    --primary-color: #2563eb;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --accent-blue: #3b82f6;

    --table-bg: #ffffff;
    --table-header-bg: #f8fafc;
    --table-border: #e2e8f0;
    --input-bg: #ffffff;

    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   DARK MODE OVERRIDES - DEEP SLATE
   ========================================== */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #1e293b;
    --border-card: #334155;
    --border-subtle: #1e293b;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-heading: #ffffff;

    --sidebar-bg: #090d16;
    --sidebar-border: #1e293b;
    --sidebar-link-color: #94a3b8;
    --sidebar-link-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-link-hover-color: #ffffff;
    --sidebar-link-active-bg: #2563eb;
    --sidebar-link-active-color: #ffffff;

    --primary-color: #38bdf8;
    --table-bg: #1e293b;
    --table-header-bg: #0f172a;
    --table-border: #334155;
    --input-bg: #0f172a;

    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --card-shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* ==========================================
   BASE RESETS & TYPOGRAPHY
   ========================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.text-heading {
    color: var(--text-heading);
}

.form-label {
    color: var(--text-heading);
    font-weight: 600;
    font-size: 0.85rem;
}

.text-muted,
small.text-muted {
    color: var(--text-muted) !important;
}

body.dark-mode .text-muted,
body.dark-mode small.text-muted {
    color: #94a3b8 !important;
}

body:not(.dark-mode) .text-muted,
body:not(.dark-mode) small.text-muted {
    color: #64748b !important;
}

/* Date Input Styling */
input[type="date"],
input[type="month"] {
    color-scheme: light;
    color: var(--text-main);
    background-color: var(--input-bg);
    border: 1px solid var(--border-card);
    font-weight: 500;
    border-radius: 8px;
    padding: 6px 12px;
}

body.dark-mode input[type="date"],
body.dark-mode input[type="month"] {
    color-scheme: dark;
    color: #ffffff !important;
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

/* Insight Cards & Theme Badges */
.bg-soft-purple {
    background: rgba(147, 51, 234, 0.1) !important;
    color: #9333ea !important;
}

body.dark-mode .bg-soft-purple {
    background: rgba(168, 85, 247, 0.2) !important;
    color: #c084fc !important;
}

.insight-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
}

.insight-header {
    border-bottom: 1px solid var(--border-card);
    color: var(--text-heading);
    font-weight: 700;
}

.insight-list {
    border-bottom: 1px solid var(--border-card);
    color: var(--text-main);
}

.badge-insight-low {
    background-color: #64748b;
    color: #ffffff;
    font-weight: 600;
}

body.dark-mode .badge-insight-low {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* ==========================================
   SIDEBAR STYLING - EXECUTIVE CORPORATE NAVY
   ========================================== */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    padding-top: 20px;
    z-index: 1050;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 15px;
    text-align: center;
}

.sidebar-brand img {
    transition: opacity 0.2s ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--sidebar-link-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.1px;
    transition: all 0.2s ease;
    margin: 4px 12px;
    border-radius: 8px;
    position: relative;
}

.sidebar-icon {
    font-size: 1.1rem;
    margin-right: 12px;
    display: inline-block;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--sidebar-link-hover-bg);
    color: var(--sidebar-link-hover-color);
    transform: translateX(4px);
}

.sidebar-link:hover .sidebar-icon {
    color: #ffffff;
}

.sidebar-link.active {
    background-color: var(--sidebar-link-active-bg);
    color: var(--sidebar-link-active-color) !important;
    font-weight: 600;
}

.sidebar-link.active .sidebar-icon {
    color: #ffffff !important;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1040;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0 !important; padding: 16px !important; }
}

/* ==========================================
   MAIN CONTENT & CARDS
   ========================================== */
.main-content {
    margin-left: 260px;
    padding: 28px 32px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.glass-card, .pos-card, .card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    color: var(--text-main);
}

.glass-card:hover {
    box-shadow: var(--card-shadow-hover);
}

/* Metric / Stat Card Styling */
.stat-card {
    padding: 20px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.icon-box {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.bg-soft-primary { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.bg-soft-success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.bg-soft-danger  { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.bg-soft-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

body.dark-mode .bg-soft-primary { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
body.dark-mode .bg-soft-success { background: rgba(52, 211, 153, 0.15); color: #34d399; }
body.dark-mode .bg-soft-danger  { background: rgba(248, 113, 113, 0.15); color: #f87171; }
body.dark-mode .bg-soft-warning { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

/* Product Tile Styling (POS Kasir) */
.product-tile {
    border: 1px solid var(--border-card);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--bg-card);
    text-align: left;
    position: relative;
    color: var(--text-main);
}
.product-tile:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}
.product-tile:active { transform: scale(0.99); }
.product-tile.is-bundle {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}
body.dark-mode .product-tile.is-bundle {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

/* Dark Mode Bootstrap Utility Overrides */
body.dark-mode .text-dark {
    color: #f8fafc !important;
}

body.dark-mode .text-secondary {
    color: #94a3b8 !important;
}

body.dark-mode .text-primary {
    color: #38bdf8 !important;
}

body.dark-mode .bg-body-tertiary {
    background-color: #0f172a !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

body.dark-mode .bg-light {
    background-color: #0f172a !important;
    color: #cbd5e1 !important;
}

body.dark-mode .border {
    border-color: #334155 !important;
}

body.dark-mode .border-subtle {
    border-color: #334155 !important;
}

/* ==========================================
   TABLES & FORMS STYLING
   ========================================== */
.table-responsive {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--table-border);
}

.table {
    color: var(--text-main);
    background-color: var(--table-bg);
    margin-bottom: 0;
}

.table th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--table-border);
    padding: 12px 16px;
}

.table td {
    padding: 12px 16px;
    border-color: var(--table-border);
    vertical-align: middle;
    font-size: 0.875rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.04) !important;
}

body.dark-mode .table {
    --bs-table-bg: #1e293b !important;
    --bs-table-color: #f8fafc !important;
    --bs-table-hover-bg: rgba(56, 189, 248, 0.08) !important;
    --bs-table-hover-color: #ffffff !important;
    color: #f8fafc !important;
    background-color: #1e293b !important;
}

body.dark-mode .table td,
body.dark-mode .table tr {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

body.dark-mode .table th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

body.dark-mode .table-hover tbody tr:hover {
    background-color: rgba(56, 189, 248, 0.08) !important;
}

body.dark-mode .table-hover tbody tr:hover td {
    background-color: rgba(56, 189, 248, 0.08) !important;
    color: #ffffff !important;
}

.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    color: var(--text-main);
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: var(--font-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg);
    border-color: #2563eb;
    color: var(--text-main);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

body.dark-mode .form-control::placeholder {
    color: #64748b;
}

/* Cart Quantity Counter Input & Buttons */
.cart-qty-input {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

body.dark-mode .cart-qty-input {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: #334155 !important;
}

body.dark-mode .input-group .btn-outline-secondary {
    color: #94a3b8 !important;
    border-color: #334155 !important;
    background-color: #0f172a !important;
}

body.dark-mode .input-group .btn-outline-secondary:hover {
    color: #ffffff !important;
    background-color: #334155 !important;
}

body.dark-mode .btn-outline-primary {
    color: #38bdf8 !important;
    border-color: #38bdf8 !important;
}

body.dark-mode .btn-outline-primary:hover {
    background-color: #38bdf8 !important;
    color: #0f172a !important;
}

body.dark-mode .btn-outline-info {
    color: #2dd4bf !important;
    border-color: #2dd4bf !important;
}

body.dark-mode .btn-outline-info:hover {
    background-color: #2dd4bf !important;
    color: #0f172a !important;
}

body.dark-mode .btn-outline-danger {
    color: #f87171 !important;
    border-color: #f87171 !important;
}

body.dark-mode .btn-outline-danger:hover {
    background-color: #f87171 !important;
    color: #ffffff !important;
}

/* Modal Dark Mode Overrides */
body.dark-mode .modal-content {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    border-color: #334155 !important;
}

body.dark-mode .modal-footer {
    background-color: #0f172a !important;
}

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.875rem;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover {
    background: #1d4ed8;
    color: #ffffff;
}

.btn-outline-custom {
    border: 1px solid var(--border-card);
    color: var(--text-main);
    background: transparent;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-outline-custom:hover {
    background: var(--bg-card);
    border-color: #2563eb;
    color: #2563eb;
}

/* Topbar Header Controls */
.topbar-control {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 12px 24px;
    box-shadow: var(--card-shadow);
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border-card);
    background-color: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle-btn:hover {
    border-color: #2563eb;
    background-color: var(--border-subtle);
}

/* User Profile Badge in Topbar */
.user-profile-badge {
    background-color: var(--input-bg);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    padding: 6px 14px;
    transition: all 0.2s ease;
}

.user-profile-badge .user-name {
    color: var(--text-heading);
    font-weight: 700;
    font-size: 0.85rem;
}

.user-profile-badge .user-role-label {
    font-size: 0.70rem;
    font-weight: 700;
    color: #2563eb;
    letter-spacing: 0.5px;
}

body.dark-mode .user-profile-badge .user-role-label {
    color: #38bdf8 !important;
}

/* Badge styling */
.badge-custom {
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
}

.pop-item-list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-card);
}
.pop-item-list:last-child {
    border-bottom: none;
}

/* Responsive Dropdown Menu Overflow Safeguard */
.table-responsive .dropdown-menu {
    z-index: 1070 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
}

/* ==========================================================================
   POS CATALOG PRODUCT THUMBNAILS & 3-WAY LAYOUT VIEW MODES
   ========================================================================== */
.product-thumb-box {
    width: 100%;
    height: 110px;
    background-color: var(--input-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 8px;
    border: 1px solid var(--border-card);
    transition: all 0.25s ease;
}

.product-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.product-tile:hover .product-thumb-img {
    transform: scale(1.06);
}

.product-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(37, 99, 235, 0.08) 100%);
}

/* MODE 1: BOX GRID PHOTO MODE */
#productListContainer.mode-grid-photo .product-item {
    width: 50%;
}
@media (min-width: 768px) {
    #productListContainer.mode-grid-photo .product-item {
        width: 50%;
    }
}
#productListContainer.mode-grid-photo .product-thumb-box {
    display: flex;
}

/* MODE 2: LIST ROW PHOTO MODE */
#productListContainer.mode-list-photo .product-item {
    width: 100% !important;
}
#productListContainer.mode-list-photo .product-tile {
    flex-direction: row !important;
    align-items: center !important;
    padding: 8px 14px !important;
}
#productListContainer.mode-list-photo .product-thumb-box {
    width: 54px !important;
    height: 54px !important;
    margin-bottom: 0 !important;
    margin-right: 12px !important;
    flex-shrink: 0;
    border-radius: 8px;
}
#productListContainer.mode-list-photo .product-info-box {
    flex: 1;
    min-width: 0;
}

/* MODE 3: RINGKAS TEKS SAJA (TANPA FOTO) */
#productListContainer.mode-text-only .product-item {
    width: 50%;
}
#productListContainer.mode-text-only .product-thumb-box {
    display: none !important;
}

/* ==========================================================================
   COMPREHENSIVE MOBILE RESPONSIVENESS & TOUCH HORIZONTAL SCROLLING
   ========================================================================== */
.table-responsive {
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y;
}

/* Touch scrollbar indicator styling for mobile */
.table-responsive::-webkit-scrollbar {
    height: 5px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 4px;
}
body.dark-mode .table-responsive::-webkit-scrollbar-thumb {
    background: rgba(51, 65, 85, 0.7);
}

/* Email & Address Text Column Formatting */
.text-email-col {
    word-break: break-all !important;
    max-width: 180px;
}

.text-alamat-col {
    word-break: break-word !important;
    min-width: 180px;
    max-width: 280px;
    white-space: normal !important;
}

/* Mobile Screen Specific Optimizations (< 768px) */
@media (max-width: 768px) {
    .main-content {
        padding: 12px !important;
    }
    
    .glass-card {
        padding: 14px !important;
        border-radius: 14px !important;
    }

    /* Stack chart date filters neatly on mobile */
    .chart-filter-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .table th, .table td {
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
    }

    /* Prevent buttons inside action column from warping on small mobile screens */
    .table td .btn {
        padding: 4px 8px !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
    }

    /* Ensure chart canvas remains responsive & scrollable */
    .chart-wrapper-responsive {
        width: 100% !important;
        min-width: 320px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile POS mode grid adjustment */
    #productListContainer.mode-grid-photo .product-item,
    #productListContainer.mode-text-only .product-item {
        width: 50% !important;
    }
}
