/* Base/Shell CSS and variables */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #090d16;
    --bg-card: rgba(22, 28, 45, 0.45);
    --bg-card-hover: rgba(30, 39, 63, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Accents */
    --accent-emerald: #00e676;
    --accent-cyan: #00b0ff;
    --accent-amber: #ffc400;
    --accent-rose: #ff1744;
    --accent-indigo: #7c4dff;
    
    /* Tenant dynamic variables */
    --tenant-primary: #00e676;
    --tenant-bg: #090d16;
    
    /* Box shadows & Glows */
    --glow-emerald: 0 0 15px rgba(0, 230, 118, 0.25);
    --glow-cyan: 0 0 15px rgba(0, 176, 255, 0.25);
    --glow-amber: 0 0 15px rgba(255, 196, 0, 0.25);
    
    --font-ar: 'Tajawal', sans-serif;
    --font-en: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-ar);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl; /* Arabic layout */
    font-size: 14px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.number-font {
    font-family: var(--font-en);
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 240px 1fr 380px;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-container.sidebar-collapsed {
    grid-template-columns: 60px 1fr 380px;
}

.app-container.phone-hidden {
    grid-template-columns: 240px 1fr;
}

.app-container.sidebar-collapsed.phone-hidden {
    grid-template-columns: 60px 1fr;
}

/* Sidebar Styling */
.sidebar {
    background-color: rgba(11, 16, 28, 0.8);
    border-left: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    height: 100vh;
    overflow-y: auto;
}

.sidebar-menu-wrapper {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
    font-family: var(--font-en);
}

.logo-text h1 {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 10px;
    color: var(--accent-cyan);
    font-family: var(--font-en);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 176, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 176, 255, 0.15);
}

.nav-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

/* Tenant Selector inside Sidebar */
.tenant-selector-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-top: auto;
}

.tenant-selector-title {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
    font-weight: bold;
}

.tenant-select {
    width: 100%;
    background: rgba(11, 16, 28, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
}

/* Main Area Layout */
.main-content {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.title-desc h2 {
    font-size: 22px;
    font-weight: 700;
}

.title-desc p {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Glass panel */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    backdrop-filter: blur(12px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title i {
    color: var(--accent-cyan);
}

/* Form inputs & buttons */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 11px;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    outline: none;
    font-size: 12px;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent-cyan);
}

.submit-btn {
    background: linear-gradient(135deg, var(--accent-emerald), #00c853);
    border: none;
    color: #000;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.submit-btn:hover {
    opacity: 0.9;
}

/* Modals overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

/* PHONE FRAME SIMULATOR */
.phone-simulator-section {
    background-color: rgba(6, 9, 15, 0.95);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.phone-simulator-header {
    width: 100%;
    margin-bottom: 15px;
    text-align: center;
}

.phone-simulator-header h3 {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 700;
}

.phone-simulator-header p {
    font-size: 11px;
    color: var(--text-secondary);
}

.smartphone-frame {
    width: 320px;
    height: 640px;
    border: 12px solid #2d3748;
    border-radius: 40px;
    position: relative;
    background-color: var(--tenant-bg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.smartphone-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 18px;
    background-color: #2d3748;
    border-radius: 0 0 12px 12px;
    z-index: 100;
}

.phone-screen {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-top: 18px;
    background: #0d111b;
}

.phone-app-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.phone-app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-logo-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--tenant-primary);
    display: inline-block;
}

.phone-app-title {
    font-size: 12px;
    font-weight: bold;
}

.phone-cart-icon {
    font-size: 16px;
    position: relative;
    cursor: pointer;
}

.phone-cart-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: var(--tenant-primary);
    color: #000;
    font-size: 8px;
    font-family: var(--font-en);
    font-weight: bold;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-loyalty-banner {
    margin: 12px;
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.phone-loyalty-tier {
    font-size: 10px;
    color: var(--tenant-primary);
    font-weight: bold;
    text-transform: uppercase;
}

.phone-loyalty-balance {
    font-size: 16px;
    font-weight: 800;
    margin: 4px 0;
}

.phone-loyalty-progress-text {
    font-size: 9px;
    color: var(--text-secondary);
}

.phone-loyalty-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.phone-loyalty-bar-fill {
    height: 100%;
    background-color: var(--tenant-primary);
    width: 45%;
}

.phone-categories {
    display: flex;
    gap: 8px;
    padding: 0 12px 10px 12px;
    overflow-x: auto;
}

.phone-categories::-webkit-scrollbar {
    display: none;
}

.phone-category-pill {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
}

.phone-category-pill.active {
    background-color: var(--tenant-primary);
    color: #000;
}

.phone-products-list {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.phone-product-row {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 10px;
    align-items: center;
}

.phone-product-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    background-color: rgba(255,255,255,0.05);
}

.phone-product-info {
    flex: 1;
}

.phone-product-name {
    font-size: 12px;
    font-weight: bold;
}

.phone-product-price {
    font-family: var(--font-en);
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.phone-product-price span {
    color: var(--tenant-primary);
    font-weight: bold;
}

.phone-product-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
}

.phone-product-add-btn:hover {
    background-color: var(--tenant-primary);
    color: #000;
}

.phone-checkout-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #121824;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px 16px 0 0;
    padding: 16px;
    z-index: 10;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.phone-checkout-panel.active {
    transform: translateY(0);
}

.phone-checkout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.phone-checkout-title {
    font-size: 13px;
    font-weight: 700;
}

.phone-checkout-close {
    cursor: pointer;
    font-size: 18px;
}

.phone-cart-items-list {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.phone-cart-item-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.phone-upsell-offer-box {
    background: rgba(0, 230, 118, 0.08);
    border: 1px dashed var(--accent-emerald);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.phone-upsell-text h5 {
    font-size: 11px;
    color: #fff;
}

.phone-upsell-text p {
    font-size: 9px;
    color: var(--accent-emerald);
    font-weight: bold;
}

.phone-upsell-add-btn {
    background: var(--accent-emerald);
    border: none;
    color: #000;
    font-size: 9px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.apple-pay-btn {
    background-color: #fff;
    color: #000;
    border: none;
    border-radius: 8px;
    width: 100%;
    padding: 12px;
    font-weight: bold;
    font-family: var(--font-en);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
}

.apple-pay-btn:hover {
    background-color: rgba(255,255,255,0.9);
}

/* System notifications toast rules */
.system-notification-center {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.notification-toast {
    background: rgba(18, 24, 38, 0.95);
    border-left: 4px solid var(--accent-cyan);
    border-radius: 6px;
    padding: 12px 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 280px;
    max-width: 320px;
    backdrop-filter: blur(10px);
    animation: slideInLeft 0.3s ease forwards;
}

.notification-toast.whatsapp {
    border-left-color: #25d366;
}

.notification-toast.sms {
    border-left-color: var(--accent-amber);
}

.notification-toast i {
    font-size: 18px;
    margin-top: 2px;
}

.notification-toast.whatsapp i { color: #25d366; }
.notification-toast.sms i { color: var(--accent-amber); }

.notification-toast-content h5 {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.notification-toast-content p {
    font-size: 11px;
    color: #fff;
    line-height: 1.4;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Sidebar Toggle and Collapse Styling */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: auto; /* Push to left in RTL */
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

/* Collapsed Sidebar States */
.sidebar-collapsed .sidebar {
    padding: 24px 8px;
    align-items: center;
}

.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .nav-parent-header span,
.sidebar-collapsed .nav-parent-header i.chevron,
.sidebar-collapsed .nav-sub-list,
.sidebar-collapsed .tenant-selector-box,
.sidebar-collapsed .tenant-selector-title {
    display: none !important;
}

.sidebar-collapsed .logo-section {
    justify-content: center;
    margin-bottom: 20px;
    width: 100%;
}

.sidebar-collapsed .logo-icon {
    margin: 0;
}

.sidebar-collapsed .sidebar-toggle-btn {
    margin: 10px 0 0 0;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    width: 38px;
    height: 38px;
}

.sidebar-collapsed .nav-item i {
    font-size: 16px;
    margin: 0;
}

/* Loading Skeleton Shimmer CSS */
.skeleton-loader {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.08) 37%,
        rgba(255, 255, 255, 0.03) 63%
    );
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Responsive Design Media Queries */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 60px 1fr !important;
    }
    
    .phone-simulator-section {
        display: none !important;
    }
    
    .sidebar {
        padding: 24px 8px;
        align-items: center;
    }
    
    .logo-text,
    .nav-item span,
    .tenant-selector-box,
    .tenant-selector-title,
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    .logo-section {
        justify-content: center;
        margin-bottom: 20px;
        width: 100%;
    }
    
    .logo-icon {
        margin: 0;
    }
    
    .nav-item {
        justify-content: center;
        padding: 10px;
        width: 38px;
        height: 38px;
    }
    
    .nav-item i {
        font-size: 16px;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .app-container {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: auto;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 12px;
        flex-direction: row;
        align-items: center;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .logo-section {
        margin-bottom: 0;
    }
    
    .nav-links {
        flex-direction: row;
        max-height: none;
        overflow-y: visible;
        overflow-x: auto;
        width: auto;
        gap: 12px;
    }
    
    .main-content {
        padding: 16px;
        height: auto;
        overflow: visible;
    }
}

/* Print Styles for PDF Export */
@media print {
    .sidebar,
    .phone-simulator-section,
    .sidebar-toggle-btn,
    .ai-btn,
    .badge {
        display: none !important;
    }
    
    .app-container {
        display: block !important;
        grid-template-columns: 1fr !important;
        height: auto !important;
        width: 100% !important;
    }
    
    .main-content {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    .glass-panel {
        background: none !important;
        border: 1px solid #ddd !important;
        color: #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    body {
        background: #fff !important;
        color: #000 !important;
    }
}

/* WORKSPACE SWITCHER & SUB-MENUS FOR SIDEBAR */
.workspace-switcher-container {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.workspace-switcher-label {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: bold;
    text-transform: uppercase;
}
.workspace-select {
    background: #0b101c;
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 6px;
    border-radius: 6px;
    width: 100%;
    cursor: pointer;
    outline: none;
    font-family: 'Tajawal', sans-serif;
}
.workspace-select:hover {
    border-color: var(--accent-cyan);
}

.nav-parent {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-parent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s ease;
}
.nav-parent-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}
.nav-parent.open .nav-parent-header {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.02);
}
.nav-parent-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-parent-header i.chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
}
.nav-parent.open i.chevron {
    transform: rotate(180deg);
}

.nav-sub-list {
    list-style: none;
    padding: 4px 0 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    margin-right: 18px;
    transition: max-height 0.3s ease-out;
}
.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.nav-sub-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}
.nav-sub-item.active {
    background: rgba(0, 176, 255, 0.08);
    color: var(--accent-cyan);
    font-weight: bold;
}

/* Sidebar scrollbar customization */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Sidebar Search Box */
.sidebar-search-box {
    position: relative;
    margin: 10px 0 15px 0;
    flex-shrink: 0;
}
.sidebar-search-box i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
    pointer-events: none;
}
.sidebar-search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 30px 8px 12px;
    color: #fff;
    font-size: 11px;
    outline: none;
    transition: all 0.2s ease;
}
.sidebar-search-input:focus {
    border-color: var(--accent-cyan);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 0 8px rgba(0, 176, 255, 0.15);
}

/* Hover Expansion for Collapsed Sidebar */
.sidebar-collapsed .sidebar {
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease, box-shadow 0.25s ease;
    width: 60px;
    z-index: 1000;
}
.sidebar-collapsed .sidebar:hover {
    width: 240px;
    position: absolute;
    right: 0;
    background-color: rgba(11, 16, 28, 0.98);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.55);
}
.sidebar-collapsed .sidebar:hover .logo-text,
.sidebar-collapsed .sidebar:hover .nav-item span,
.sidebar-collapsed .sidebar:hover .nav-parent-header span,
.sidebar-collapsed .sidebar:hover .nav-parent-header i.chevron,
.sidebar-collapsed .sidebar:hover .nav-sub-list,
.sidebar-collapsed .sidebar:hover .tenant-selector-box,
.sidebar-collapsed .sidebar:hover .tenant-selector-title {
    display: block !important;
}
.sidebar-collapsed .sidebar:hover .nav-sub-list {
    display: flex !important;
}
.sidebar-collapsed .sidebar:hover .logo-section {
    justify-content: flex-start;
}
.sidebar-collapsed .sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
}
.sidebar-collapsed .sidebar .sidebar-search-box {
    display: none !important;
}
.sidebar-collapsed .sidebar:hover .sidebar-search-box {
    display: block !important;
}

/* Notification Drawer Panel */
.notification-drawer {
    position: fixed;
    top: 0;
    right: -340px; /* Hidden offscreen by default in RTL */
    width: 340px;
    height: 100vh;
    background: rgba(11, 16, 28, 0.96);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(20px);
    z-index: 10000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 24px;
    direction: rtl;
}

.notification-drawer.active {
    right: 0;
}

.notification-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.notification-drawer-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.notification-drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-drawer-close:hover {
    color: #fff;
}

.notification-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification-history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 11.5px;
    transition: all 0.2s;
    display: flex;
    gap: 12px;
    text-align: right;
}

.notification-history-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.notification-history-item i {
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.notification-history-item.sms i { color: var(--accent-amber); }
.notification-history-item.whatsapp i { color: #25d366; }
.notification-history-item.push i { color: var(--accent-cyan); }

.notification-history-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.notification-history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.notification-history-text {
    color: var(--text-primary);
    line-height: 1.45;
}

.notification-drawer-clear-btn {
    background: rgba(255, 23, 68, 0.08);
    border: 1px solid rgba(255, 23, 68, 0.2);
    color: var(--accent-rose);
    border-radius: 6px;
    padding: 10px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    margin-top: 15px;
    outline: none;
}

.notification-drawer-clear-btn:hover {
    background: rgba(255, 23, 68, 0.16);
    border-color: var(--accent-rose);
}

/* Floating notification bell icon */
.notification-bell-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    position: relative;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.notification-bell-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.notification-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
    background-color: var(--accent-rose);
    border-radius: 50%;
    border: 1.5px solid rgba(11, 16, 28, 0.95);
    display: none;
    animation: bellPulse 1.5s infinite;
}

@keyframes bellPulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* ==========================================================================
   LIGHT THEME  (body.theme-light)
   Overrides the design tokens + key hardcoded dark surfaces.
   ========================================================================== */
body.theme-light {
    --bg-main: #eef1f7;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: #ffffff;
    --border-color: rgba(15, 23, 42, 0.10);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #8a94a6;
    --tenant-bg: #eef1f7;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

body.theme-light .sidebar {
    background-color: #ffffff;
    border-color: var(--border-color);
    backdrop-filter: none;
}
body.theme-light .glass-panel,
body.theme-light .card,
body.theme-light .stat-card,
body.theme-light .glass-card {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
body.theme-light .gradient-text {
    background: linear-gradient(90deg, #0f172a, #475569);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
body.theme-light .nav-item {
    color: var(--text-secondary);
}
body.theme-light .nav-item:hover {
    background: rgba(15, 23, 42, 0.05);
    color: #0f172a;
}
body.theme-light .sidebar-toggle-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
}
body.theme-light ::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.03); }
body.theme-light ::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.2); }
body.theme-light ::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.35); }

body.theme-light input,
body.theme-light select,
body.theme-light textarea {
    background: #f4f6fb;
    color: var(--text-primary);
    border-color: var(--border-color);
}
body.theme-light table th { color: var(--text-secondary); }
body.theme-light table td { color: var(--text-primary); }

body.theme-light .notification-toast,
body.theme-light .notification-drawer {
    background: #ffffff;
    color: var(--text-primary);
}

/* Flip inline white text so it stays readable on light surfaces */
body.theme-light [style*="color: #fff"],
body.theme-light [style*="color:#fff"],
body.theme-light [style*="color: #FFF"],
body.theme-light [style*="color:#FFF"],
body.theme-light [style*="color: white"],
body.theme-light [style*="color:white"] {
    color: #0f172a !important;
}
/* Buttons that carry the tenant/accent colour keep their own text colour */
body.theme-light .btn-primary,
body.theme-light .btn-primary * {
    color: #000 !important;
}

/* ==========================================================================
   FLOATING THEME TOGGLE + MOBILE NAV CONTROLS
   ========================================================================== */
.theme-toggle-btn {
    position: fixed;
    bottom: 18px;
    left: 18px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
}
.theme-toggle-btn:hover { transform: scale(1.06); }

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    z-index: 1200;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.mobile-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
}
.mobile-nav-overlay.active { display: block; }

/* ==========================================================================
   MOBILE RESPONSIVE (<= 768px) — off-canvas sidebar + stacked layout
   Placed last so it takes precedence over earlier breakpoints.
   ========================================================================== */
@media (max-width: 768px) {
    .app-container,
    .app-container.sidebar-collapsed,
    .app-container.phone-hidden {
        display: block !important;
        grid-template-columns: 1fr !important;
        height: auto;
        overflow: visible;
    }

    .mobile-menu-btn { display: flex; }
    .theme-toggle-btn { bottom: 14px; left: 14px; }

    .phone-simulator-section { display: none !important; }

    /* Sidebar becomes a right-side drawer (RTL) */
    .sidebar {
        position: fixed !important;
        top: 0;
        right: -290px;
        width: 280px;
        height: 100vh !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 20px 14px !important;
        border-left: none;
        border-bottom: none;
        z-index: 1100;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }
    .app-container.mobile-nav-open .sidebar { right: 0 !important; }

    /* Restore full sidebar labels inside the drawer */
    .sidebar .logo-text,
    .sidebar .nav-item span,
    .sidebar .tenant-selector-box,
    .sidebar .tenant-selector-title,
    .sidebar .nav-parent-header span {
        display: inline-flex !important;
    }
    .sidebar .nav-links {
        flex-direction: column !important;
        overflow: visible !important;
        width: 100% !important;
        gap: 4px;
    }
    .sidebar .nav-item {
        width: 100% !important;
        height: auto !important;
        justify-content: flex-start !important;
        padding: 10px 12px !important;
    }
    .sidebar .nav-item i { margin-left: 10px; }

    .main-content {
        padding: 64px 14px 20px !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }

    /* Stack any inline/CSS multi-column grids into a single column */
    [style*="grid-template-columns"],
    .dashboard-grid-v3,
    .stats-grid,
    .cards-grid {
        grid-template-columns: 1fr !important;
    }

    .header-row { flex-wrap: wrap; gap: 10px; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
}

