:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --accent: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #22c55e;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

[dir="rtl"] {
    --font-heading: 'Cairo', sans-serif;
    --font-body: 'Cairo', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Exam Cards (Home) */
.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.exam-card {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.exam-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Admin Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin: 1rem 0;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

[dir="rtl"] th,
[dir="rtl"] td {
    text-align: right;
}

th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-light);
}

/* Utility Classes */
.text-primary {
    color: var(--primary);
}

.text-accent {
    color: var(--accent);
}

.text-success {
    color: var(--success);
}

.text-center {
    text-align: center;
}

/* Hero Section (Home) */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.hero-text {
    font-size: 1.25rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
}

.exam-card-title {
    margin-bottom: 0.5rem;
}

/* Page Headers (Generic) */
.page-header {
    padding: 2rem 0;
}

.page-title {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 2rem;
}

.page-subtitle {
    margin-bottom: 2rem;
    color: var(--text-light);
}

/* Grouped Lists (Exams Index) */
.group-section {
    margin-bottom: 3rem;
}

.group-title {
    font-size: 1.5rem;
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.subgroup-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.subgroup-title {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.category-block {
    margin-bottom: 1rem;
}

.category-title {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.exam-grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.exam-item {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: var(--background);
}

.exam-meta {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.exam-region {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.exam-links {
    display: flex;
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* Courses Grid (Posts Index) */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.course-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.course-card:hover {
    transform: translateY(-4px);
}

.course-header {
    margin-bottom: 0.5rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-cours {
    background: #dbeafe;
    color: #1e40af;
}

.badge-exercice {
    background: #fce7f3;
    color: #be185d;
}

.course-subject {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.course-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.course-title {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.course-link {
    color: var(--text);
}

.course-meta {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.btn-full {
    display: block;
    width: 100%;
    text-align: center;
}

.pagination-wrapper {
    margin-top: 2rem;
}

/* Post Detail */
.post-header {
    margin-bottom: 2rem;
}

.post-title {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.post-meta {
    color: var(--text-light);
    font-size: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.post-featured-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 1rem;
    margin-bottom: 2rem;
}

.post-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn-success {
    background: var(--success);
    color: white;
}

.post-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    line-height: 1.8;
}

/* Auth Pages */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.auth-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary);
}

.auth-error {
    color: var(--danger);
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

/* Layout Elements */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    color: white;
}

.alert-success {
    background: var(--success);
}

.footer {
    background: var(--surface);
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
}

.footer-text {
    text-align: center;
    color: var(--text-light);
}

.nav-link-active {
    font-weight: bold;
}