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

:root {
    --bg-main: #060913;
    --bg-secondary: rgba(16, 23, 42, 0.65);
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --accent: #c084fc;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(16, 23, 42, 0.6);
    --glass-blur: blur(24px);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glow: 0 0 20px rgba(129, 140, 248, 0.4);
}

:root[data-theme="light"] {
    --bg-main: #eef2ff;
    --bg-secondary: rgba(255, 255, 255, 0.7);
    --primary: #6366f1;
    --primary-hover: #4338ca;
    --accent: #a855f7;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-blur: blur(24px);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .input-glass {
    background: #ffffff !important;
    color: #1e293b;
    border: 1px solid #94a3b8 !important;
}
[data-theme="light"] .input-glass:focus {
    background: #f8fafc;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
[data-theme="light"] .dashboard-preview {
    background: rgba(241, 245, 249, 0.9) !important;
    border-color: rgba(15, 23, 42, 0.1) !important;
}
[data-theme="light"] .text-muted, [data-theme="light"] th {
    color: #4b5563 !important; /* Tailwind gray-600 */
}
[data-theme="light"] th { font-weight: 700; }
[data-theme="light"] .store-card, 
[data-theme="light"] .public-plan-card,
[data-theme="light"] .stat-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
}
[data-theme="light"] .user-profile {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}
[data-theme="light"] .glass-panel {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
}
[data-theme="light"] .nav-item.active {
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary-hover);
}
[data-theme="light"] .nav-item:hover:not(.active) {
    background: rgba(15, 23, 42, 0.05);
    color: #1e293b;
}
[data-theme="light"] .webhook-clipboard {
    background: #e2e8f0;
    color: #334155;
    border-color: #cbd5e1;
}
[data-theme="light"] .webhook-clipboard:hover {
    background: #f8fafc;
    border-color: var(--primary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects for high-end Glassmorphism */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(56, 189, 248, 0.1) 0%, transparent 50%);
    z-index: -2;
    pointer-events: none;
    animation: slowSpin 30s linear infinite;
}

[data-theme="light"] body::before {
    background: 
        radial-gradient(circle at 20% 40%, rgba(99, 102, 241, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 80% 60%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(56, 189, 248, 0.2) 0%, transparent 50%);
}

@keyframes slowSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Typography Utilities */
h1, h2, h3, h4 { color: var(--text-main); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Inputs & Buttons */
.input-glass {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

.input-glass:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Glass Cards */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-top: 1px solid rgba(255, 255, 255, 0.15); /* Adds premium 3D edge */
    border-radius: 20px;
    box-shadow: var(--shadow);
}

/* Auth Layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }

/* Switch Auth Mode */
.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-switch a:hover { color: var(--accent); }

/* Alerts / Toasts */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    z-index: 1000;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast.error { border-left-color: #ef4444; }
.toast.success { border-left-color: #10b981; }

/* Dashboard Layout */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border);
    border-left: 1px solid rgba(255, 255, 255, 0.03); /* Subtle 3D edge */
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    letter-spacing: -0.5px;
}

.sidebar-logo span {
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}

.sidebar-logo i {
    font-size: 1.6rem;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    filter: drop-shadow(0px 4px 10px rgba(56, 189, 248, 0.4));
    transform: rotate(-10deg);
}

.nav-item {
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.nav-item:hover, .nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}
.nav-item.active {
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

/* Main Content */
.main-content {
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.user-profile {
    position: relative;
    display: inline-block;
}

.user-profile-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s;
}

.user-profile-pill:hover {
    background: rgba(255,255,255,0.05);
}

.user-profile-email {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.user-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    background: var(--text-main);
    color: var(--bg-main);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

/* Profile Dropdown Menu */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 250px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.profile-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
    cursor: pointer;
}

.dropdown-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
}

.dropdown-item:hover {
    background: rgba(255,255,255,0.05);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Notification UI */
.notification-bell {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: color 0.3s;
    margin-left: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.notification-bell:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-main);
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification-badge.show {
    transform: scale(1);
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    left: -100px;
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.notification-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

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

.notification-header h4 { margin: 0; font-size: 1rem; }
.mark-all-read { font-size: 0.8rem; color: var(--primary); cursor: pointer; }
.mark-all-read:hover { text-decoration: underline; }

.notification-list {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.notification-item:hover { background: rgba(255, 255, 255, 0.03); }
.notification-item.unread { background: rgba(99, 102, 241, 0.05); }

.notification-item.unread::before {
    content: '';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.notification-icon.success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.notification-icon.danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.notification-icon.warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.notification-icon.info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

.notification-content h5 { margin: 0 0 4px 0; font-size: 0.9rem; color: var(--text-main); }
.notification-content p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.notification-content .time { font-size: 0.7rem; color: #6b7280; margin-top: 5px; display: block; }

.notification-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
}
.notification-empty i { font-size: 2rem; margin-bottom: 10px; opacity: 0.5; }

/* إشعار قابل للضغط — يحتوي رابط */
.notification-item.notif-clickable {
    transition: background 0.2s, border-color 0.2s;
}
.notification-item.notif-clickable:hover {
    background: rgba(124, 58, 237, 0.08) !important;
    border-right: 3px solid var(--primary);
}

/* Cards Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 18px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.3s ease;
}
.stat-card:hover { transform: translateY(-5px); border-color: rgba(99, 102, 241, 0.3); }
.stat-title { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-main); }

/* Stores Table / List */
.table-container {
    width: 100%;
    margin-top: 1rem;
}
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.store-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.store-card:hover {
    background: rgba(255,255,255,0.04);
}

.store-info h3 { margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.store-meta { font-size: 0.85rem; color: var(--text-muted); }

.platform-badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
}
.platform-shopify { background: rgba(150, 191, 72, 0.15); color: #96bf48; }
.platform-youcan { background: rgba(0, 85, 255, 0.15); color: #0055ff; }
.platform-woocommerce { background: rgba(150, 88, 138, 0.15); color: #96588a; }
.platform-googlesheets { background: rgba(15, 157, 88, 0.15); color: #0F9D58; }

.webhook-clipboard {
    background: rgba(0,0,0,0.3);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border: 1px solid transparent;
}
.webhook-clipboard:hover { border-color: var(--primary); color: white; }
.webhook-clipboard i { color: var(--primary); }


/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    border-radius: 20px;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }

.modal-header { display: flex; justify-content: space-between; margin-bottom: 2rem; }
.close-modal { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.5rem; transition: color 0.2s;}
.close-modal:hover { color: white; }


/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loaders */
.loader {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}
/* Showing loader inside button */
.btn-primary.loading { color: transparent; position: relative;}
.btn-primary.loading .loader { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ==========================================================================
   Pagination Bar
   ========================================================================== */
.pg-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 38px;
}
.pg-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.pg-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.pg-btn.pg-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 3px 10px rgba(124,58,237,0.35);
}

/* ==========================================================================
   Print Optimization (@media print)
   ========================================================================== */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    
    body::before {
        display: none !important;
    }
    
    /* Hide navigational UI */
    .sidebar, 
    .topbar, 
    .btn, 
    .btn-primary, 
    .btn-outline,
    .modal-overlay,
    .action-badge,
    .print-hide {
        display: none !important;
    }
    
    /* Make Main Content take full page without scrolling/sidebar gaps */
    .app-container {
        display: block !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .print-header {
        display: block !important;
        page-break-after: avoid;
    }
    
    /* Optimize glass panels and cards for ink */
    .glass-panel,
    .dashboard-preview {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Print tables clearly with lines */
    .data-table {
        border-collapse: collapse !important;
        width: 100% !important;
        border: 1px solid #ccc !important;
    }
    .data-table th, 
    .data-table td {
        border: 1px solid #ccc !important;
        padding: 8px !important;
        color: #000 !important;
    }
    .data-table td:last-child,
    .data-table th:last-child {
        display: none !important; /* Usually Actions column, hide it */
    }

    /* Text Colors overrides for clarity */
    .text-primary, .text-muted, .text-red {
        color: #000 !important;
    }
    
    /* Audit timeline print fixes */
    .timeline::after {
        background: #ccc !important;
    }
    .timeline-content {
        border: 1px solid #ccc !important;
        background: transparent !important;
    }
    .timeline-item::after {
        border-color: #000 !important;
        background: #fff !important;
    }
    
    @page {
        margin: 1cm;
        size: auto;
    }
}

/* ==========================================================================
   Mobile Responsiveness — نسخة الجوال المحسّنة
   ========================================================================== */

/* ===== Bottom Navigation Bar (جوال فقط) ===== */
.mobile-bottom-nav {
    display: none;
}

/* ===== FAB — زر إضافة طلبية عائم ===== */
.fab-btn {
    display: none;
}

/* Ensure mobile toggle is hidden on desktop */
.mobile-menu-toggle {
    display: none !important;
}
.sidebar-logo i.mobile-close-btn {
    display: none !important;
}

/* ========== MOBILE BREAKPOINT ========== */
@media (max-width: 768px) {

    /* ===== Layout ===== */
    .app-container {
        display: block;
        padding-bottom: 70px; /* مساحة لـ Bottom Nav */
    }

    /* ===== Sidebar — يُخفى ويظهر كـ Drawer ===== */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        transform: translateX(110%) !important;
        visibility: hidden;
        width: 280px;
        height: 100vh;
        z-index: 9999 !important;
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), visibility 0s 0.3s !important;
        overflow-y: auto;
    }
    .sidebar.mobile-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), visibility 0s 0s !important;
        box-shadow: -10px 0 50px rgba(0,0,0,0.6) !important;
    }

    /* ===== Overlay ===== */
    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        backdrop-filter: blur(4px);
        z-index: 9998 !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    .mobile-sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    /* ===== Main Content ===== */
    .main-content {
        padding: 0.75rem;
        width: 100vw;
        overflow-x: hidden;
    }

    /* ===== Topbar ===== */
    .topbar {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        gap: 8px;
        flex-wrap: wrap;
    }
    .topbar > div:nth-child(2) {
        order: 3;
        width: 100%;
        text-align: right;
    }
    .topbar > div:nth-child(2) h2 { font-size: 1.1rem !important; margin-bottom: 1px; }
    .topbar > div:nth-child(2) p  { display: none; }
    .topbar > div:last-child {
        order: 2;
        display: flex;
        align-items: center;
    }

    /* ===== Mobile Menu Toggle ===== */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--primary);
        font-size: 1.15rem;
        cursor: pointer;
        flex-shrink: 0;
        order: 1;
    }
    .sidebar-logo i.mobile-close-btn {
        display: block !important;
        cursor: pointer;
        color: var(--text-muted);
        background: none !important;
        -webkit-text-fill-color: var(--text-muted) !important;
        transform: none !important;
        filter: none !important;
    }

    /* ===== Bottom Navigation Bar ===== */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15,23,42,0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        z-index: 9990;
        padding: 6px 0 max(6px, env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
    }
    .mob-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 6px 12px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.62rem;
        font-family: 'Tajawal', sans-serif;
        border-radius: 10px;
        transition: color 0.2s;
        min-width: 55px;
    }
    .mob-nav-item i { font-size: 1.2rem; }
    .mob-nav-item.active,
    .mob-nav-item:hover { color: var(--primary); }
    .mob-nav-item.active i { color: var(--primary); }

    /* ===== FAB زر إضافة ===== */
    .fab-btn {
        display: flex;
        position: fixed;
        bottom: 75px;
        left: 50%;
        transform: translateX(-50%);
        width: 54px;
        height: 54px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), #6d28d9);
        color: white;
        border: none;
        font-size: 1.4rem;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 9991;
        box-shadow: 0 4px 20px rgba(124,58,237,0.5);
        transition: transform 0.2s, box-shadow 0.2s;
    }
    .fab-btn:active {
        transform: translateX(-50%) scale(0.93);
        box-shadow: 0 2px 10px rgba(124,58,237,0.4);
    }

    /* ===== Notification Dropdown — يفتح للأسفل على الجوال ===== */
    .notification-dropdown {
        left: auto !important;
        right: -10px !important;
        width: calc(100vw - 20px) !important;
        max-width: 360px;
        top: calc(100% + 10px) !important;
    }

    /* ===== Cards & Panels ===== */
    .glass-panel { padding: 1rem; }
    .stat-card   { padding: 1rem; }

    /* ===== Dashboard Grid ===== */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }
    .stat-card .stat-value { font-size: 1.4rem !important; }

    /* ===== Tables → Card Layout ===== */
    .table-responsive {
        width: 100%;
        overflow-x: hidden !important;
    }
    .data-table {
        min-width: 0 !important;
        display: block;
        width: 100%;
    }
    .data-table thead { display: none !important; }
    .data-table tbody { display: block; }
    .data-table tr {
        display: block;
        margin-bottom: 0.9rem;
        background: rgba(255,255,255,0.025);
        border: 1px solid rgba(255,255,255,0.07);
        border-radius: 12px;
        padding: 0.6rem 0.75rem;
        transition: border-color 0.2s;
    }
    .data-table tr:active { border-color: rgba(124,58,237,0.4); }
    .data-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 0.6rem 0.25rem !important;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        font-size: 0.9rem;
    }
    .data-table td:last-child { border-bottom: none; }
    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: var(--primary);
        font-size: 0.75rem;
        margin-bottom: 3px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .data-table td[colspan] { display: block; text-align: center !important; }
    .data-table td[colspan]::before { content: none; }

    /* ===== Action Buttons in Table ===== */
    .data-table td .btn,
    .data-table td .btn-primary,
    .data-table td select,
    .data-table td input { width: 100% !important; margin-bottom: 5px; }

    /* ===== Filter Form ===== */
    #filterForm {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    #filterForm select,
    #filterForm input  { width: 100% !important; }
    #filterForm .btn-primary { width: 100%; }

    /* ===== Bulk Actions Bar ===== */
    #bulkActionsBar {
        flex-direction: column !important;
        gap: 8px !important;
    }
    #bulkActionsBar > div {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    #bulkActionsBar .btn,
    #bulkActionsBar .btn-primary,
    #bulkActionsBar select { flex: 1 !important; min-width: 120px; }

    /* ===== Modals ===== */
    .modal-content {
        padding: 1.25rem !important;
        margin: 8px !important;
        width: calc(100% - 16px) !important;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: 16px !important;
    }
    .modal-header h2 { font-size: 1.1rem; }

    /* ===== Forms ===== */
    .form-group { margin-bottom: 0.9rem; }
    form div[style*="display: flex"],
    form div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    /* ===== Grid Overrides ===== */
    div[style*="display: grid"],
    div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* ===== Store Cards ===== */
    .store-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
    }
    .store-card > div:last-child {
        width: 100% !important;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .webhook-clipboard {
        width: 100%;
        direction: ltr;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .webhook-clipboard span {
        max-width: 100% !important;
        white-space: normal !important;
        word-break: break-all;
        font-size: 0.78rem;
    }

    /* ===== Pagination Bar ===== */
    #paginationBar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        padding: 1rem 0 !important;
    }
    .pg-btn {
        padding: 8px 12px !important;
        font-size: 0.82rem !important;
        min-width: 36px;
        min-height: 36px;
    }

    /* ===== Typography ===== */
    h2 { font-size: 1.2rem !important; }
    .stat-value { font-size: 1.4rem !important; }

    /* ===== Touch Targets — أزرار أكبر ===== */
    .btn, .btn-primary {
        min-height: 40px;
        padding: 10px 16px;
    }
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px !important; /* يمنع zoom في iOS */
    }

    /* ===== Topbar Buttons ===== */
    .topbar .btn, .topbar .btn-primary {
        font-size: 0.82rem;
        padding: 8px 12px;
    }

    /* ===== Generic flex panels ===== */
    .glass-panel div[style*="display: flex"],
    .glass-panel div[style*="display:flex"] {
        flex-wrap: wrap;
    }
    .glass-panel button.btn-primary {
        flex: 1;
        min-width: 100px;
        text-align: center;
    }
}

/* ===== Small screens (< 400px) ===== */
@media (max-width: 400px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .mob-nav-item {
        font-size: 0.58rem;
        padding: 5px 8px;
        min-width: 44px;
    }
    .mob-nav-item i { font-size: 1.1rem; }
}

@media (max-width: 768px) {
    .app-container {
        display: block; /* Remove grid */
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        transform: translateX(100%) !important; /* Hide off-screen to the right */
        visibility: hidden; /* Prevent leaking artifacts like the logo */
        width: 280px;
        height: 100vh;
        z-index: 9999 !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.3s !important;
        overflow-y: auto;
    }

    /* When sidebar is active */
    .sidebar.mobile-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s !important;
        box-shadow: -10px 0 50px rgba(0,0,0,0.5) !important;
    }

    /* Mobile Overlay for sidebar */
    .mobile-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(4px);
        z-index: 9998 !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .mobile-sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    /* Main Content adjustments */
    .main-content {
        padding: 1rem;
        width: 100vw;
        overflow-x: hidden;
    }

    .topbar {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        justify-content: space-between;
        padding: 1rem;
    }
    
    /* Title Section */
    .topbar > div:nth-child(2) {
        order: 3;
        width: 100%;
        margin-top: 5px;
        text-align: right;
        flex: none;
    }
    .topbar > div:nth-child(2) h2 { font-size: 1.25rem !important; margin-bottom: 2px; }
    .topbar > div:nth-child(2) p { display: none; } /* Save vertical space */

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--primary);
        font-size: 1.2rem;
        cursor: pointer;
        z-index: 100;
        flex-shrink: 0;
        order: 1; /* Top right in RTL */
    }

    /* Hide sidebar logo on mobile since we have a topbar toggle */
    .sidebar-logo {
        font-size: 1.4rem;
    }
    
    .sidebar-logo i.mobile-close-btn {
        display: block !important;
        cursor: pointer;
        color: var(--text-muted);
        background: none !important;
        -webkit-text-fill-color: var(--text-muted) !important;
        transform: none !important;
        filter: none !important;
    }

    /* Mobile Sidebar Visibility */
    .sidebar.mobile-open {
        transform: translateX(0) !important;
        box-shadow: -10px 0 50px rgba(0,0,0,0.5);
    }
    
    .mobile-sidebar-overlay.active {
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Card-based tables for mobile */
    .table-responsive {
        width: 100%;
        overflow-x: hidden !important; /* No more horizontal scroll */
    }
    
    .data-table {
        min-width: 0 !important;
        display: block;
        width: 100%;
    }
    
    .data-table thead {
        display: none !important; /* Strictly hide headers */
    }
    
    .data-table tbody {
        display: block;
    }
    
    .data-table tr {
        display: block;
        margin-bottom: 1rem;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        padding: 0.5rem;
    }
    
    /* Ensure Webhook URLs and Store Cards don't overflow */
    .store-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px;
    }
    
    .store-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        word-break: break-word;
        white-space: normal;
    }
    
    .store-info h3 {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        line-height: 1.4;
    }
    
    .store-card > div:last-child {
        width: 100% !important;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        gap: 10px;
    }

    .webhook-clipboard {
        width: 100%;
        box-sizing: border-box;
        text-align: left;
        direction: ltr; /* Essential for URLs */
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .webhook-clipboard span {
        max-width: 100% !important;
        white-space: normal !important;
        word-break: break-all;
        font-size: 0.8rem;
    }

    /* Adjust filters */
    #filterForm {
        flex-direction: column;
        align-items: stretch;
    }
    
    #filterForm .btn-primary {
        width: 100%;
    }

    /* Adjust cards */
    .glass-panel {
        padding: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    /* Adjust topbar profile section to fit mobile */
    .topbar > div:last-child {
        order: 2; /* Top left in RTL */
        width: auto !important;
        margin-top: 0 !important;
        border-top: none !important;
        padding-top: 0 !important;
        justify-content: flex-end !important;
        display: flex;
        align-items: center;
    }
    
    /* Print buttons full width on mobile */
    .topbar .btn, .topbar .btn-primary {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
    
    /* 1. Force Grids to Single Column on Mobile */
    div[style*="display: grid"],
    div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* 2. Forms & Inputs Stacking */
    form div[style*="display: flex"],
    form div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    /* 3. Allow wrapping for other generic panels */
    .glass-panel div[style*="display: flex"],
    .glass-panel div[style*="display:flex"] {
        flex-wrap: wrap;
    }
    
    /* Ensure filter buttons wrap on dashboard */
    .glass-panel button.btn-primary {
        flex: 1;
        min-width: 100px;
        text-align: center;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }

    /* 2. Modals & Popups */
    .modal-content {
        padding: 1.2rem !important;
        margin: 10px !important;
        width: calc(100% - 20px) !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }

    /* 3. Dashboard Cards */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    /* 4. Tables & Data Grids (Card Layout) */
    .data-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 0.75rem 0.5rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.02);
        text-align: right;
        font-size: 0.95rem;
    }
    
    .data-table td:last-child {
        border-bottom: none;
    }
    
    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: var(--primary);
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }

    /* Handle empty/loading state in mobile tables */
    .data-table td[colspan] {
        display: block;
        text-align: center !important;
    }
    .data-table td[colspan]::before {
        content: none;
    }
    
    /* Make action buttons row look nice */
    .data-table td .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    /* Global Typography adjustments for mobile */
    h2 {
        font-size: 1.25rem !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
    }
}

/* Ensure mobile toggle is hidden on desktop */
.mobile-menu-toggle {
    display: none !important;
}
.sidebar-logo i.mobile-close-btn {
    display: none !important;
}
