/* Zoom Mall Design System - Bootstrap Integration */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
    /* Zoom Mall Brand Identity Colors */
    --zm-primary: #274384; 
    --zm-primary-dark: #1a2d59;
    --zm-primary-light: #3d60ba;
    
    --zm-secondary: #0F172A;
    --zm-accent: #F9A826;

    --zm-background: #f4f6f9;
    --zm-surface: #ffffff;
    --zm-surface-hover: #f8f9fa;

    --zm-text: #212529;
    --zm-muted: #6c757d;
    --zm-border: #dee2e6;

    --zm-success: #198754;
    --zm-warning: #ffc107;
    --zm-danger: #dc3545;
    --zm-info: #0dcaf0;

    /* Override Bootstrap variables */
    --bs-primary: var(--zm-primary);
    --bs-primary-rgb: 39, 67, 132;
    --bs-secondary: var(--zm-secondary);
    --bs-success: var(--zm-success);
    --bs-info: var(--zm-info);
    --bs-warning: var(--zm-warning);
    --bs-danger: var(--zm-danger);
    --bs-body-bg: var(--zm-background);
    --bs-body-color: var(--zm-text);
    --bs-font-sans-serif: 'Tajawal', sans-serif;
    
    --sidebar-width: 260px;
    --header-height: 70px;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--zm-background);
    color: var(--zm-text);
    overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Sidebar Custom Styling */
.zm-sidebar {
    width: var(--sidebar-width);
    background-color: var(--zm-primary);
    color: #fff;
    height: 100vh; /* Fixed height is required for overflow-y to work inside */
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1040;
    transition: transform 0.3s ease-in-out;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.zm-sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--zm-primary-dark);
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo-z {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--zm-primary-dark);
    font-family: 'Arial', sans-serif;
    -webkit-text-stroke: 2px #e2e8f0;
    text-shadow: 0 0 15px rgba(226, 232, 240, 0.8), 0 4px 8px rgba(0,0,0,0.4);
    line-height: 1;
    display: inline-block;
}

.zm-sidebar-menu {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.zm-sidebar-link {
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.8);
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    gap: 10px;
}

.zm-sidebar-link:hover, .zm-sidebar-link.active {
    color: #fff;
    background-color: rgba(255,255,255,0.1);
    border-right: 4px solid var(--zm-accent);
}

/* Main Wrapper */
.zm-main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease-in-out;
}

/* Top Navbar */
.zm-header {
    height: var(--header-height);
    background-color: var(--zm-surface);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    position: sticky;
    top: 0;
}

.zm-header-title {
    font-weight: 800;
    color: var(--zm-primary);
    margin: 0;
    font-size: 1.25rem;
}

/* Content Area */
.zm-content {
    padding: 2rem;
    flex-grow: 1;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .zm-sidebar {
        transform: translateX(100%); /* RTL hidden is translated positive X */
    }
    .zm-sidebar.show {
        transform: translateX(0);
    }
    .zm-main-wrapper {
        margin-right: 0;
    }
    .zm-content {
        padding: 1rem;
    }
    /* Mobile Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

/* Deep Mobile Optimizations */
@media (max-width: 767.98px) {
    html {
        /* Globally scales down all REM-based units (fonts, paddings, margins, components) by ~18% */
        font-size: 13px;
    }
    .auth-card {
        padding: 1.25rem !important;
        margin-top: 2vh;
        margin-bottom: 2vh;
    }
    .auth-brand img {
        max-width: 140px;
        margin-bottom: 0.5rem;
    }
    .auth-brand-text {
        font-size: 1.25rem;
    }
    .kpi-card {
        height: 100%; /* Force equal heights */
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 12px 10px;
        gap: 6px;
        margin-bottom: 0.5rem; /* Additional external gap */
    }
    .kpi-title { font-size: 0.8rem; margin-bottom: 0; }
    .kpi-value { font-size: 1.25rem; font-weight: 800; }
    .kpi-desc { display: none; /* Hide on mobile to save space */ }

    /* Make all tables scrollable horizontally on mobile automatically */
    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    /* Sticky First Column for Tables */
    .table th:first-child, .table td:first-child {
        position: sticky;
        right: 0;
        background-color: var(--zm-surface);
        z-index: 1;
        box-shadow: -3px 0 5px -2px rgba(0,0,0,0.1);
    }

    /* Compact standard cards */
    .card-body {
        padding: 1rem;
    }
    /* Touch Targets & Compact Forms - Reverted to Native Proportions */
    .form-control, .form-select {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
        border-radius: 0.375rem;
        margin-bottom: 0.5rem; /* Ensure they are not glued together */
    }
    .btn {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
        border-radius: 0.375rem;
        margin-bottom: 0.5rem;
    }
    /* Protect Sidebar Toggle Button Size */
    #sidebar-toggle i {
        font-size: 1.5rem !important;
    }
    #sidebar-toggle {
        padding: 0.25rem 0.5rem !important;
        margin-bottom: 0 !important;
    }
    /* Default checkbox sizes */
    input[type="checkbox"], input[type="radio"] {
        width: 18px;
        height: 18px;
        margin-left: 0.5rem;
    }
    /* Center Card Headers on Mobile */
    .card-header {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
    }
    .card-header .btn {
        width: 100%;
    }
    /* Compact Main Area */
    .zm-content {
        padding: 0.75rem;
    }
}

/* Generic Bootstrap Overrides */
.btn-primary {
    background-color: var(--zm-primary);
    border-color: var(--zm-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--zm-primary-dark);
    border-color: var(--zm-primary-dark);
}
.btn-secondary {
    background-color: var(--zm-secondary);
    border-color: var(--zm-secondary);
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}
.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--zm-border);
    font-weight: 700;
    color: var(--zm-primary);
    padding: 1rem 1.25rem;
}

.table th {
    font-weight: 700;
    color: var(--zm-primary-dark);
    background-color: var(--zm-surface-hover);
    white-space: nowrap;
}
.table td {
    vertical-align: middle;
}

/* Custom Utilities */
.text-primary-custom {
    color: var(--zm-primary) !important;
}
.bg-primary-custom {
    background-color: var(--zm-primary) !important;
}

/* Form Overrides */
.form-control:focus, .form-select:focus {
    border-color: var(--zm-primary-light);
    box-shadow: 0 0 0 0.25rem rgba(39, 67, 132, 0.25);
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: var(--zm-background);
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 500px;
    margin-top: 6vh;
    margin-bottom: 6vh;
    border-top: 5px solid var(--zm-primary);
    background-color: var(--zm-surface);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.05);
    padding: 2rem;
}
.auth-brand {
    text-align: center;
    margin-bottom: 0.5rem;
}
.auth-brand img {
    max-width: 180px;
    margin: 0 auto 1rem;
    display: block;
}
.auth-brand-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--zm-primary);
}
.auth-subtitle {
    text-align: center;
    color: var(--zm-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.auth-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--zm-border);
}


/* Custom Components Restored for Bootstrap */
.kpi-card {
    background-color: var(--zm-surface);
    border: 1px solid var(--zm-border);
    border-radius: 0.5rem;
    padding: 24px;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 4px solid var(--zm-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}
.kpi-card.kpi-gold { border-top-color: var(--zm-warning); }
.kpi-card.kpi-green { border-top-color: var(--zm-success); }
.kpi-card.kpi-red { border-top-color: var(--zm-danger); }

.kpi-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--zm-muted);
}
.kpi-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--zm-primary);
}
.kpi-desc {
    font-size: 0.85rem;
    color: var(--zm-muted);
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--zm-muted);
    background: var(--zm-background);
    border-radius: 0.5rem;
    border: 2px dashed var(--zm-border);
    margin-bottom: 24px;
}
.empty-state .empty-text {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--zm-primary);
}
