:root {
    --primary: #1a3a5c;
    --primary-light: #2563a8;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-w: 260px;
    --sidebar-collapsed: 70px;
    --bottom-nav-h: 64px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
}

/* ===== APP WRAPPER ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR - Desktop ===== */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, #0f2540 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .user-details { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 48px; height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    filter: invert(1) brightness(2);
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    padding: 4px;
}

.brand-title { color: white; font-weight: 700; font-size: 15px; display: block; }
.brand-sub { color: rgba(255,255,255,0.6); font-size: 12px; }

.sidebar-nav { flex: 1; padding: 16px 12px; list-style: none; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 4px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.nav-link i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(245,158,11,0.4); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0;
}
.user-name { color: white; font-size: 13px; font-weight: 600; white-space: nowrap; }

.btn-logout {
    background: rgba(239,68,68,0.2);
    border: none;
    color: #fca5a5;
    width: 36px; height: 36px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-logout:hover { background: var(--danger); color: white; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-right: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease;
    min-height: 100vh;
}
.main-content.expanded { margin-right: var(--sidebar-collapsed); }

.top-bar {
    background: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle {
    background: none; border: none;
    font-size: 18px; color: var(--text-muted);
    cursor: pointer; padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }
.page-title { font-size: 17px; font-weight: 700; color: var(--primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-badge {
    background: var(--bg);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.content-area { padding: 20px; flex: 1; }

/* ===== CARDS ===== */
.card { background: var(--card-bg); border-radius: var(--radius); border: none; box-shadow: var(--shadow); }

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(0,0,0,0.12); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: white;
    flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 900; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white; border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none;
}
.btn-primary-custom:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,99,168,0.4); color: white; }

.btn-accent {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none;
}
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,158,11,0.4); color: white; }

.btn-whatsapp {
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white; border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none;
}
.btn-whatsapp:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,211,102,0.4); color: white; }

/* ===== FORMS ===== */
.form-control, .form-select {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s;
    width: 100%;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,0.1);
    outline: none;
}
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; display: block; }

/* ===== TABLE ===== */
.table-modern { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-modern thead th {
    background: var(--primary);
    color: white;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    white-space: nowrap;
}
.table-modern thead th:first-child { border-radius: 0 10px 0 0; }
.table-modern thead th:last-child { border-radius: 10px 0 0 0; }
.table-modern tbody tr { transition: background 0.15s; }
.table-modern tbody tr:hover { background: #f8fafc; }
.table-modern tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

/* ===== BADGES ===== */
.badge-sector {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

/* ===== UPLOAD AREA ===== */
.upload-zone {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafbfc;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-light);
    background: rgba(37,99,168,0.04);
}
.upload-zone i { font-size: 40px; color: var(--primary-light); margin-bottom: 12px; }

/* ===== MODAL ===== */
.modal-content { border-radius: var(--radius); border: none; }
.modal-header { background: var(--primary); color: white; border-radius: var(--radius) var(--radius) 0 0; padding: 16px 20px; }
.modal-title { font-weight: 700; }
.btn-close { filter: invert(1); }

/* ===== CONFIRM BANNER ===== */
.confirm-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.confirm-banner i { color: var(--accent); font-size: 20px; flex-shrink: 0; }
.confirm-banner strong { color: #92400e; font-size: 14px; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0f2540 50%, #1a3a5c 100%);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    padding: 20px;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: rgba(245,158,11,0.08);
    border-radius: 50%;
    top: -150px; left: -150px;
}
.login-card {
    background: white;
    border-radius: 24px;
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    position: relative; z-index: 1;
}
.login-logo {
    width: 110px; height: 110px;
    background: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* ===== RECEIPT PREVIEW ===== */
.receipt-preview {
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 380px;
    object-fit: contain;
    width: 100%;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.35s ease forwards; }
.stat-card { animation: fadeInUp 0.4s ease both; }
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }
.stat-card:nth-child(4) { animation-delay: 0.24s; }

/* ===== MOBILE OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ===== BOTTOM NAV - Mobile Only ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: white;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 1001;
    border-radius: 20px 20px 0 0;
}
.bottom-nav-inner {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    transition: all 0.2s;
    flex: 1;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active i { color: var(--accent); }
.bottom-nav-item.upload-btn {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    border-radius: 16px;
    padding: 10px 20px;
    margin: 0 4px;
}
.bottom-nav-item.upload-btn i { color: white; font-size: 22px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    /* إخفاء الـ sidebar وإظهار Bottom Nav */
    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-w) !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar .brand-text,
    .sidebar .nav-link span,
    .sidebar .user-details { display: block !important; }

    .main-content {
        margin-right: 0 !important;
        padding-bottom: var(--bottom-nav-h);
    }

    .bottom-nav { display: flex; }

    .top-bar {
        padding: 12px 16px;
    }
    .date-badge { display: none; }

    .content-area { padding: 14px; }

    /* الجداول على الموبايل */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-modern thead th,
    .table-modern tbody td { padding: 10px 10px; font-size: 12px; }

    /* البطاقات الإحصائية */
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 44px; height: 44px; font-size: 18px; }

    /* منطقة الرفع */
    .upload-zone { padding: 30px 16px; }
    .upload-zone i { font-size: 32px; }

    /* الأزرار على الموبايل */
    .btn-primary-custom, .btn-accent, .btn-whatsapp {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* صفحة الدخول */
    .login-card { padding: 32px 24px; }
    .login-logo { width: 90px; height: 90px; }

    /* إخفاء بعض الأعمدة في الجدول */
    .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
    .sidebar-overlay { display: none !important; }
}

/* ===== WELCOME BANNER ===== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #0f2540 100%);
    border-radius: var(--radius);
    padding: 16px 20px;
    color: white;
}
.welcome-banner-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}
.welcome-logo {
    width: 52px; height: 52px;
    object-fit: contain;
    filter: invert(1) brightness(2);
    flex-shrink: 0;
}
.welcome-text { flex: 1; min-width: 0; }
.welcome-text h5 { font-size: 15px; }
.welcome-date {
    font-size: 12px;
    opacity: .75;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== STAT CARD MOBILE ===== */
.stat-info { min-width: 0; }

@media (max-width: 768px) {
    .welcome-logo { width: 40px; height: 40px; }
    .welcome-text h5 { font-size: 13px; }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { width: 38px; height: 38px; font-size: 15px; border-radius: 10px; }
    .stat-value { font-size: 20px !important; }
    .stat-label { font-size: 11px; }
}

/* ===== QUICK ACTION BUTTONS ===== */
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
    width: 100%;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.quick-action-btn i { font-size: 22px; }
.quick-action-btn:hover { transform: translateY(-3px); }

.quick-action-btn.primary { background: linear-gradient(135deg,#2563a8,#1a3a5c); color: white; }
.quick-action-btn.accent  { background: linear-gradient(135deg,#f59e0b,#d97706); color: white; }
.quick-action-btn.success { background: linear-gradient(135deg,#10b981,#059669); color: white; }
.quick-action-btn.purple  { background: linear-gradient(135deg,#8b5cf6,#6d28d9); color: white; }

/* ===== RECEIPT MOBILE CARD ===== */
.receipt-mobile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg);
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.receipt-mobile-card:hover { background: #e8eef5; color: var(--text); }
.receipt-mobile-card-right { flex: 1; }
.receipt-mobile-card-left { text-align: center; flex-shrink: 0; }
