/* ==========================================================================
   VBReports - Formal Educational Design System (Light Theme)
   ========================================================================== */

/* --- 1. CSS Variables (Design Tokens) --- */
:root {
    /* Backgrounds & Surfaces */
    --bg-main: #f4f7fb;          /* Soft gray-blue background for low eye strain */
    --surface-white: #ffffff;    /* Pure white for cards */
    --surface-hover: #f8fafc;
    --border-color: #e2e8f0;     /* Soft border for structure */
    
    /* Brand Colors - Formal & Calm */
    --primary: #1e40af;          /* Deep calm blue for primary actions (Trust/Official) */
    --primary-light: #eff6ff;    /* Light blue for subtle backgrounds */
    --primary-hover: #1e3a8a;
    
    /* Semantic Colors - Subtle but clear */
    --success: #10b981;          /* Green for success/good indicators */
    --success-bg: #ecfdf5;
    --warning: #f59e0b;          /* Orange/Yellow for pending */
    --warning-bg: #fffbeb;
    --danger: #ef4444;           /* Red for alerts */
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    
    /* Typography */
    --text-heading: #0f172a;     /* Very dark blue-gray for high contrast */
    --text-body: #334155;        /* Main text color */
    --text-muted: #64748b;       /* Secondary text */
    
    /* Layout & Geometry */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    /* Subtle Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-smooth: 0.3s ease;
    
    /* Dimensions */
    --sidebar-width: 260px;
}

/* --- 2. Global Resets & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-body);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography specific */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 700;
}

.counter, .time, .badge, .status-badge, .english-num {
    font-family: 'Outfit', sans-serif;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
button:focus { outline: 2px solid var(--primary-light); }

/* --- 3. Core Components --- */
.card {
    background: var(--surface-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color var(--transition-fast);
}

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

.btn-secondary {
    background-color: white;
    color: var(--text-heading);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background-color: var(--surface-hover);
    border-color: #cbd5e1;
}

/* --- 4. Layout & Sidebar --- */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-white);
    border-left: 1px solid var(--border-color); /* RTL */
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.ministry-logo-icon {
    width: 36px;
    height: 36px;
    background-color: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.brand-text {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

.sidebar-menu {
    padding: 1.5rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.menu-item a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.menu-item a:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.menu-item.active a {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    border-right: 3px solid var(--primary); /* RTL active indicator */
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.1rem;
}

.user-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- 5. Main Content --- */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width); /* RTL */
    padding: 2rem 3rem;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 1.6rem;
    margin-bottom: 0.2rem;
}

.page-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: white;
}

.search-box i {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.kpi-title {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-primary { background: var(--primary-light); color: var(--primary); }
.icon-success { background: var(--success-bg); color: var(--success); }
.icon-warning { background: var(--warning-bg); color: var(--warning); }
.icon-info { background: #eff6ff; color: var(--info); }

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.kpi-trend {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-neutral { color: var(--text-muted); }

/* Analytics Section */
.analytics-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.section-header h2 {
    font-size: 1.2rem;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Tables Section */
.data-table-section {
    margin-bottom: 2rem;
}

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

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

.formal-table th {
    background-color: var(--surface-hover);
    padding: 1rem;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.formal-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.formal-table tr:last-child td {
    border-bottom: none;
}

.formal-table tr:hover {
    background-color: #f8fafc;
}

.report-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.report-icon {
    color: var(--primary);
    font-size: 1.2rem;
}

.report-title {
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.2rem;
}

.report-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success { background: var(--success-bg); color: #059669; }
.badge-warning { background: var(--warning-bg); color: #d97706; }
.badge-info { background: var(--primary-light); color: var(--primary); }

.action-links {
    display: flex;
    gap: 0.8rem;
}

.action-link {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.action-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* --- 6. Utilities & Animations --- */
/* Smooth fade-in for page load */
.fade-in {
    animation: fadeIn var(--transition-smooth) forwards;
}

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

/* Remove staggering and use simple delay if needed */
.delay-1 { animation-delay: 0.1s; opacity: 0; }
.delay-2 { animation-delay: 0.2s; opacity: 0; }
.delay-3 { animation-delay: 0.3s; opacity: 0; }

/* Responsive */
@media (max-width: 1024px) {
    .analytics-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .main-content {
        margin-right: 0;
        padding: 1rem;
    }
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .search-box {
        width: 100%;
    }
}
