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

:root {
    --primary: #1B4332;
    --primary-light: #2D6A4F;
    --primary-dark: #0B2B1E;
    --accent: #D4A843;
    --accent-light: #E8C96A;
    --accent-dark: #B8892E;
    --bg: #F8F6F0;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F2B1F;
    --text: #1A1A2E;
    --text-light: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E1D8;
    --success: #059669;
    --danger: #DC2626;
    --warning: #D97706;
    --info: #2563EB;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.1), 0 8px 32px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.7;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0A1F15 100%);
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    border-left: 1px solid rgba(212,168,67,0.15);
}

.sidebar-header {
    padding: 28px 24px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(212,168,67,0.05);
}

.sidebar-logo {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    margin-bottom: 12px;
    box-shadow: 0 0 20px rgba(212,168,67,0.3);
}

.sidebar-logo-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 28px;
    color: white;
    font-weight: 800;
    border: 3px solid rgba(255,255,255,0.2);
}

.sidebar-title {
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Almarai', sans-serif;
    margin-bottom: 4px;
}

.sidebar-subtitle {
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-section {
    padding: 8px 20px;
    margin-top: 8px;
}

.nav-section-title {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    padding-right: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    box-shadow: 0 4px 12px rgba(45,106,79,0.4);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 3px;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.user-name {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-right: 280px;
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-card);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.top-bar-title {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Almarai', sans-serif;
    color: var(--primary-dark);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    padding: 28px 32px;
}

/* ===== CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.stat-card.income::before { background: var(--success); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.balance::before { background: var(--accent); }
.stat-card.docs::before { background: var(--info); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card.income .stat-icon { background: rgba(5,150,105,0.1); color: var(--success); }
.stat-card.expense .stat-icon { background: rgba(220,38,38,0.1); color: var(--danger); }
.stat-card.balance .stat-icon { background: rgba(212,168,67,0.1); color: var(--accent-dark); }
.stat-card.docs .stat-icon { background: rgba(37,99,235,0.1); color: var(--info); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    font-family: 'Almarai', sans-serif;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
}

/* ===== TABLE ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(27,67,50,0.02);
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    font-family: 'Almarai', sans-serif;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: rgba(27,67,50,0.04);
    padding: 14px 16px;
    text-align: right;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 14px;
    vertical-align: middle;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: rgba(27,67,50,0.02);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    box-shadow: 0 2px 8px rgba(27,67,50,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27,67,50,0.4);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(212,168,67,0.3);
}

.btn-accent:hover {
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(27,67,50,0.04);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.form-label .required {
    color: var(--danger);
    margin-right: 2px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    padding-left: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: rgba(5,150,105,0.1); color: var(--success); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-warning { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-info { background: rgba(37,99,235,0.1); color: var(--info); }
.badge-primary { background: rgba(27,67,50,0.1); color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Almarai', sans-serif;
    color: var(--primary-dark);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-light);
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(220,38,38,0.1);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

/* ===== ALERTS ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: rgba(5,150,105,0.08); color: var(--success); border: 1px solid rgba(5,150,105,0.2); }
.alert-danger { background: rgba(220,38,38,0.08); color: var(--danger); border: 1px solid rgba(220,38,38,0.2); }
.alert-warning { background: rgba(217,119,6,0.08); color: var(--warning); border: 1px solid rgba(217,119,6,0.2); }
.alert-info { background: rgba(37,99,235,0.08); color: var(--info); border: 1px solid rgba(37,99,235,0.2); }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(212,168,67,0.15) 0%, transparent 70%);
    top: -100px;
    left: -100px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(212,168,67,0.1) 0%, transparent 70%);
    bottom: -50px;
    right: -50px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255,255,255,0.97);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 420px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(20px);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accent);
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 800;
    font-family: 'Almarai', sans-serif;
    color: var(--primary-dark);
    margin-top: 16px;
}

.login-logo p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar, .top-bar, .btn, .no-print { display: none !important; }
    .main-content { margin: 0 !important; }
    .content-area { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.fade-in { animation: fadeIn 0.4s ease; }
.slide-in { animation: slideIn 0.4s ease; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 0;
}

.pagination a, .pagination span {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
}

.pagination a:hover {
    background: rgba(27,67,50,0.08);
    color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
}

/* ===== EDITOR ===== */
.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(27,67,50,0.03);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    flex-wrap: wrap;
}

.editor-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: var(--transition);
    font-size: 14px;
}

.editor-btn:hover {
    background: rgba(27,67,50,0.08);
    color: var(--primary);
}

.editor-content {
    min-height: 300px;
    padding: 20px;
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    outline: none;
    font-size: 15px;
    line-height: 1.8;
    direction: rtl;
}

.editor-content:focus {
    border-color: var(--primary-light);
}

/* ===== MOBILE ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
    }
    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .content-area {
        padding: 16px;
    }
    .top-bar {
        padding: 16px;
        padding-right: 60px;
    }
}

/* ===== SEARCH ===== */
.search-box {
    position: relative;
}

.search-box input {
    padding-right: 40px;
}

.search-box .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ===== ARCHIVE STATUS ===== */
.archive-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.archive-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.archive-dot.archived { background: var(--success); }
.archive-dot.not-archived { background: var(--text-muted); }

/* ===== DROPDOWN ===== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 500;
    padding: 6px;
}

.dropdown-menu.show {
    display: block;
    animation: slideUp 0.2s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: rgba(27,67,50,0.05);
    color: var(--primary);
}

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

/* ===== FILE UPLOAD ===== */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload:hover {
    border-color: var(--primary-light);
    background: rgba(27,67,50,0.02);
}

.file-upload input {
    display: none;
}

.file-upload-icon {
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ===== SWITCH ===== */
.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    right: 3px;
    transition: var(--transition);
}

.switch input:checked + .switch-slider {
    background: var(--success);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(-20px);
}
