:root {
    --deep-navy: #061B35;
    --navy-gradient: linear-gradient(180deg, #031225 0%, #082B55 100%);
    --royal-blue: #2563EB;
    --gold: #D8A940;
    --white: #FFFFFF;
    --bg-gray: #F5F7FB;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

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

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

.hidden { display: none !important; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

.loading-box {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-box {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Login */
.login-page {
    background: var(--navy-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.login-wrapper {
    width: min(640px, 100%);
}

.login-card {
    background: var(--white);
    padding: 56px 64px;
    border-radius: 24px;
    width: 100%;
    text-align: center;
    border-top: 6px solid var(--gold);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

.ministry-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    background: var(--deep-navy);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 2.75rem;
    font-weight: 700;
}

.login-header h1 { font-size: 1.85rem; color: var(--deep-navy); margin-bottom: 8px; line-height: 1.4; }
.login-header p { font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 36px; }

.login-page .form-group { text-align: right; margin-bottom: 24px; }
.login-page .form-group label { font-size: 1rem; margin-bottom: 10px; }
.login-page .form-group input {
    padding: 16px 18px;
    font-size: 1.05rem;
    border-radius: 10px;
}

.login-page .btn-primary.full-width {
    padding: 16px 24px;
    font-size: 1.1rem;
    margin-top: 8px;
    border-radius: 10px;
}

@media (max-width: 640px) {
    .login-card {
        padding: 40px 28px;
    }

    .login-header h1 { font-size: 1.5rem; }
}

.form-group { text-align: right; margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-footer { display: flex; justify-content: flex-end; margin-bottom: 25px; }
.forgot-link { color: var(--royal-blue); text-decoration: none; font-size: 0.85rem; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 280px;
    background: var(--deep-navy);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header { padding: 30px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header .logo {
    width: 60px; height: 60px;
    margin: 0 auto 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--gold); font-size: 1.5rem; font-weight: 700;
}
.sidebar-header h3 { color: var(--gold); font-size: 1rem; line-height: 1.5; }

.sidebar-menu { padding: 20px 0; flex: 1; }
.menu-item {
    display: flex; align-items: center;
    padding: 12px 30px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: 0.3s;
}
.menu-item:hover, .menu-item.active { background: var(--royal-blue); color: white; }
.menu-item i { margin-left: 15px; font-style: normal; font-size: 1.1rem; min-width: 24px; text-align: center; }

.sidebar-footer { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-logout {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.main-wrapper { flex: 1; margin-right: 280px; padding: 30px; min-height: 100vh; }
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 16px; }
.top-bar h1 { font-size: 1.5rem; color: var(--deep-navy); }
.welcome-text { color: var(--text-secondary); font-size: 0.9rem; }
.page-info p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }

/* Buttons */
.btn-primary { background: var(--royal-blue); color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: 700; transition: 0.3s; text-decoration: none; display: inline-block; font-size: 0.9rem; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: 600; }
.btn-secondary { background: var(--bg-gray); color: var(--text-primary); border: 1px solid var(--border); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.full-width { width: 100%; }
.btn-text { color: var(--royal-blue); text-decoration: none; font-weight: 600; font-size: 0.85rem; background: none; border: none; cursor: pointer; font-family: inherit; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card { background: white; padding: 20px; border-radius: 12px; box-shadow: var(--card-shadow); text-align: center; }
.kpi-label { display: block; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 5px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; color: var(--deep-navy); }
.border-gold { border-top: 4px solid var(--gold); }
.border-blue { border-top: 4px solid var(--royal-blue); }
.border-green { border-top: 4px solid var(--success); }
.border-red { border-top: 4px solid var(--danger); }

/* Cards & Tables */
.card { background: white; border-radius: 15px; padding: 25px; box-shadow: var(--card-shadow); margin-bottom: 25px; }
.card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.dashboard-content-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 25px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: right; padding: 12px; border-bottom: 2px solid var(--bg-gray); color: var(--text-secondary); font-size: 0.85rem; }
.data-table td { padding: 15px 12px; border-bottom: 1px solid var(--bg-gray); font-size: 0.9rem; }
.data-table tr:hover { background: #fafbfc; }

.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; display: inline-block; }
.badge-in-progress, .badge-in_progress { background: #e0e7ff; color: #4338ca; }
.badge-pending, .badge-pending_review { background: #fef3c7; color: #92400e; }
.badge-completed, .badge-approved { background: #dcfce7; color: #166534; }
.badge-late, .badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-returned { background: #ffedd5; color: #9a3412; }
.badge-draft { background: #f3f4f6; color: #374151; }
.badge-urgent { background: #fee2e2; color: #991b1b; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-medium { background: #e0e7ff; color: #4338ca; }
.badge-low { background: #f3f4f6; color: #374151; }

.list-item { display: flex; flex-direction: column; padding: 12px 0; border-bottom: 1px solid var(--bg-gray); }
.list-item:last-child { border-bottom: none; }
.list-item strong { font-size: 0.9rem; margin-bottom: 4px; }
.list-item small { color: var(--text-secondary); font-size: 0.75rem; }

.search-filter-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; align-items: center; }
.search-input { flex: 1; min-width: 200px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { padding: 8px 16px; border: 1px solid var(--border); background: white; border-radius: 20px; cursor: pointer; font-family: inherit; font-size: 0.85rem; }
.filter-btn.active, .filter-btn:hover { background: var(--royal-blue); color: white; border-color: var(--royal-blue); }

/* Events */
.events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.event-card { display: flex; gap: 20px; align-items: flex-start; }
.event-date { background: var(--deep-navy); color: white; padding: 12px; border-radius: 10px; text-align: center; min-width: 70px; }
.event-date .day { display: block; font-size: 1.5rem; font-weight: 700; }
.event-date .month { font-size: 0.75rem; opacity: 0.8; }
.event-details h3 { margin-bottom: 8px; font-size: 1rem; }
.event-details p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 4px; }

/* Approvals */
.approval-card { margin-bottom: 16px; }
.approval-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.approval-meta { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 16px; }
.approval-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Profile */
.profile-card { max-width: 700px; }
.profile-header { display: flex; gap: 24px; align-items: center; margin-bottom: 30px; padding-bottom: 24px; border-bottom: 1px solid var(--bg-gray); }
.profile-avatar { width: 80px; height: 80px; background: var(--royal-blue); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; }
.profile-info h2 { margin-bottom: 4px; }
.profile-info p { color: var(--text-secondary); margin-bottom: 8px; }
.section-title { font-weight: 700; margin: 20px 0 12px; color: var(--deep-navy); }
.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bg-gray); font-size: 0.9rem; }
.detail-row span { color: var(--text-secondary); }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: white; padding: 30px; border-radius: 16px; width: 100%; max-width: 480px; }
.modal h2 { margin-bottom: 16px; font-size: 1.1rem; }
.modal textarea { width: 100%; min-height: 100px; margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; }

/* Calendar */
.calendar-nav { display: flex; align-items: center; gap: 16px; }
.calendar-nav span { font-weight: 700; min-width: 140px; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-header { text-align: center; font-weight: 700; font-size: 0.85rem; color: var(--text-secondary); padding: 8px; }
.calendar-day {
    min-height: 80px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}
.calendar-day:hover { border-color: var(--royal-blue); background: #f8fafc; }
.calendar-day.empty { border: none; cursor: default; background: transparent; }
.calendar-day.has-events { border-color: var(--gold); background: #fffbeb; }
.calendar-day.selected { border-color: var(--royal-blue); background: #eff6ff; }
.calendar-day { text-decoration: none; color: inherit; display: block; }
.menu-badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    margin-right: auto;
}
.pagination-wrap { margin-top: 20px; }
.pagination-wrap nav { display: flex; gap: 8px; flex-wrap: wrap; }
.pagination-wrap a, .pagination-wrap span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
}
.pagination-wrap span[aria-current="page"] { background: var(--royal-blue); color: white; border-color: var(--royal-blue); }
.profile-card { max-width: 700px; }
.calendar-day .day-num { font-weight: 700; font-size: 0.9rem; }
.calendar-day .event-dot {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--royal-blue);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}
.calendar-list .calendar-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--bg-gray); }
.calendar-item .time { color: var(--royal-blue); font-weight: 700; min-width: 100px; }

.notification-item.unread { border-right: 4px solid var(--royal-blue); }
.badge-scheduled { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #e0e7ff; color: #4338ca; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* Brand logo */
.brand-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.brand-logo img { object-fit: contain; border-radius: 50%; background: white; padding: 4px; }
.brand-logo-text { display: flex; flex-direction: column; gap: 4px; }
.brand-logo-text strong { color: var(--deep-navy); line-height: 1.4; }
.brand-logo-text small { color: var(--text-secondary); font-size: 0.85rem; }
.sidebar-header .brand-logo-text strong { color: var(--gold); }
.sidebar-header .brand-logo-text small { color: rgba(255,255,255,0.75); }
.sidebar-header .brand-logo img { box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.login-header .brand-logo-text strong { font-size: 1.5rem !important; }
.profile-logo { width: 88px; height: 88px; object-fit: contain; border-radius: 50%; background: white; padding: 6px; border: 2px solid var(--gold); }

/* Action buttons */
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.workflow-decision-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
    padding: 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    background: #fafafa;
}
.workflow-decision-form textarea {
    width: 100%;
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}
.btn-action-form { display: inline-flex; margin: 0; }
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: 0.2s;
    line-height: 1.2;
}
.btn-action:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.btn-action-icon { font-size: 0.9rem; }
.btn-action-view { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn-action-edit { background: #fffbeb; color: #a16207; border-color: #fde68a; }
.btn-action-delete { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-action-approve, .btn-action-complete { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.btn-action-reject { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-action-return { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.data-table .action-buttons { min-width: 180px; }

.form-section-title {
    font-weight: 700;
    color: var(--deep-navy);
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg-gray);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: min(420px, calc(100vw - 48px));
}
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 14px;
    background: white;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-right: 5px solid var(--royal-blue);
    opacity: 0;
    transform: translateY(-12px);
    transition: 0.3s ease;
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-hide { opacity: 0; transform: translateY(-12px); }
.toast-success { border-right-color: var(--success); }
.toast-error { border-right-color: var(--danger); }
.toast-warning { border-right-color: var(--warning); }
.toast-info { border-right-color: var(--royal-blue); }
.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.toast-success .toast-icon { background: #dcfce7; color: #166534; }
.toast-error .toast-icon { background: #fee2e2; color: #991b1b; }
.toast-warning .toast-icon { background: #fef3c7; color: #92400e; }
.toast-info .toast-icon { background: #dbeafe; color: #1e40af; }
.toast-message { flex: 1; font-size: 0.95rem; line-height: 1.5; }
.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

@media (max-width: 1200px) {
    .dashboard-content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .sidebar { width: 80px; }
    .sidebar-header .brand-logo-text { display: none; }
    .sidebar-header .brand-logo img { width: 48px !important; height: 48px !important; }
    .menu-item span { display: none; }
    .main-wrapper { margin-right: 80px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-wrapper { margin-right: 0; padding: 16px; }
}
