@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;800&family=Tajawal:wght@300;400;500;700&display=swap');

:root {
    /* Colors */
    --primary-color: #0F5132;
    /* Islamic Green */
    --primary-light: #198754;
    --secondary-color: #D4AF37;
    /* Soft Gold */
    --secondary-hover: #b8962e;

    /* Bootstrap Overrides */
    --bs-primary: #0F5132;
    --bs-primary-rgb: 15, 81, 50;
    --bs-secondary: #D4AF37;
    --bs-secondary-rgb: 212, 175, 55;
    --bs-link-color: #0F5132;
    --bs-link-hover-color: #146c43;

    /* Light Mode Backgrounds */
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;

    /* Shadows */
    --shadow-sm: 0 .125rem .25rem rgba(0, 0, 0, .075);
    --shadow-md: 0 .5rem 1rem rgba(0, 0, 0, .15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, .175);

    /* Dimensions */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Transitions */
    --transition-speed: 0.3s;
}

[data-bs-theme="dark"] {
    /* Dark Mode Variables */
    --bg-body: #1a1d21;
    --bg-card: #212529;
    --bg-sidebar: #212529;
    --text-main: #e9ecef;
    --text-muted: #adb5bd;
    --border-color: #343a40;

    --primary-color: #146c43;
    /* Lighter Green for Dark Mode */
    --secondary-color: #e0c058;
    /* Lighter Gold for Dark Mode */
}

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 1040;
    transition: transform var(--transition-speed), width var(--transition-speed);
    overflow-y: auto;
}

.sidebar .brand-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    font-weight: 800;
    font-size: 1.8rem;
    /* Increased from 1.5rem */
    color: var(--primary-color);
}

.sidebar .nav-link {
    color: var(--text-main);
    padding: 0.8rem 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    margin: 0.2rem 1rem;
    transition: all 0.2s ease-in-out;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: rgba(212, 175, 55, 0.15);
    /* Soft Gold Tint */
    color: var(--primary-color);
    border-right: 4px solid var(--secondary-color);
    /* Gold accent */
}

[data-bs-theme="dark"] .sidebar .nav-link:hover,
[data-bs-theme="dark"] .sidebar .nav-link.active {
    background-color: rgba(20, 108, 67, 0.2);
    color: var(--primary-light);
    /* Or Gold if preferred */
}

.sidebar .nav-link i {
    width: 24px;
    margin-left: 10px;
    /* RTL margin */
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    margin-right: var(--sidebar-width);
    padding: 2rem;
    transition: margin-right var(--transition-speed);
    min-height: 100vh;
}

/* Header/Navbar */
.header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    padding: 1.25rem;
}

/* Stats Cards */
.stats-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
}

.stats-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-left: 1rem;
    /* RTL */
    color: #fff;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
}

.bg-gradient-secondary {
    background: linear-gradient(135deg, var(--secondary-color), #f9d765);
    color: #212529;
}

.bg-gradient-gold {
    background: linear-gradient(135deg, #FFD700, #D4AF37);
    color: #000;
}

.bg-gradient-green {
    background: linear-gradient(135deg, #0F5132, #198754);
    color: #fff;
}

.text-gold {
    color: var(--secondary-color) !important;
}

.bg-gold {
    background-color: var(--secondary-color) !important;
    color: white;
}

/* Tables */
.table-responsive {
    border-radius: 1rem;
    overflow: hidden;
}

.table thead th {
    background-color: rgba(15, 81, 50, 0.05);
    /* Very light green hint */
    color: var(--text-main);
    border-bottom-width: 1px;
    font-weight: 700;
    padding: 1rem;
}

[data-bs-theme="dark"] .table thead th {
    background-color: rgba(255, 255, 255, 0.05);
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
        /* Hide off-canvas right */
        width: 280px;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
        backdrop-filter: blur(3px);
        /* Blur effect */
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Tablet Specific (Landscape) and Small Desktop */
@media (min-width: 992px) and (max-width: 1199.98px) {

    /* Keep sidebar visible but maybe slightly narrower if needed */
    :root {
        --sidebar-width: 240px;
    }
}

/* Button & interactive overrides */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    border-color: var(--secondary-hover);
    color: #fff;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-outline-secondary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

/* Soft Backgrounds */
.bg-soft-primary {
    background-color: rgba(15, 81, 50, 0.1) !important;
    color: var(--primary-color) !important;
}

.bg-soft-secondary {
    background-color: rgba(212, 175, 55, 0.1) !important;
    color: var(--secondary-color) !important;
}

.bg-soft-success {
    background-color: rgba(25, 135, 84, 0.1) !important;
    color: #198754 !important;
}

.bg-soft-info {
    background-color: rgba(13, 202, 240, 0.1) !important;
    color: #0dcaf0 !important;
}

.bg-soft-warning {
    background-color: rgba(255, 193, 7, 0.1) !important;
    color: #ffc107 !important;
}

.bg-soft-danger {
    background-color: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
}

/* Dark mode adjustments for soft backgrounds */
[data-bs-theme="dark"] .bg-soft-primary {
    background-color: rgba(20, 108, 67, 0.2) !important;
    color: var(--primary-light) !important;
}

[data-bs-theme="dark"] .bg-soft-secondary {
    background-color: rgba(224, 192, 88, 0.2) !important;
    color: #e0c058 !important;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RTL Specific Fixes if needed beyond Bootstrap RTL */
.ms-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

.me-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Desktop Sidebar Collapse */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: 80px;
    }

    body.sidebar-collapsed .sidebar .brand-logo {
        justify-content: center;
        padding: 0;
    }

    body.sidebar-collapsed .sidebar .nav-link span,
    body.sidebar-collapsed .sidebar .brand-logo span,
    body.sidebar-collapsed .sidebar .text-muted,
    /* Hide titles */
    body.sidebar-collapsed .sidebar .badge,
    body.sidebar-collapsed .sidebar .dropdown-toggle::after {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        padding: 1rem 0;
        margin: 5px 10px;
        text-align: center;
    }

    body.sidebar-collapsed .sidebar .nav-link i {
        margin: 0 !important;
        font-size: 1.5rem;
    }

    body.sidebar-collapsed .main-content {
        margin-right: 80px;
    }
}

/* Exam Session Styles */
.exam-header {
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

[data-bs-theme="dark"] .exam-header {
    background: var(--bg-card);
}

.exam-body {
    padding-top: 80px;
    /* Header height + gap */
    min-height: 100vh;
}

.video-placeholder {
    background-color: #212529;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
}

.mushaf-container {
    background-color: #fdfbf7;
    /* Paper color */
    border: 1px solid #e3dac9;
    border-radius: 8px;
    padding: 20px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    position: relative;
}

.mushaf-img {
    max-width: 100%;
    max-height: 75vh;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mistake-btn {
    transition: all 0.2s;
    border: 2px solid transparent;
}

.mistake-btn:active {
    transform: scale(0.95);
}

.timer-box {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--primary-color);
    background: rgba(15, 81, 50, 0.1);
    padding: 5px 15px;
    border-radius: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar .nav {
        padding-bottom: 80px;
    }
    
    .main-content {
        margin-right: 0;
        padding: 1rem;
    }
}