/* ============================
   Lughati - Apprentissage Arabe
   ============================ */

:root {
    --primary: #1a6b2e;
    --primary-dark: #0f4a1e;
    --primary-light: #e8f5e9;
    --accent: #1565c0;
    --text: #1a1a1a;
    --text-light: #666;
    --bg: #f8f9fa;
    --white: #ffffff;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    margin: 0;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; color: inherit; }

/* ============================
   HEADER / NAV
   ============================ */

.main-header {
    background: var(--white);
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.main-header nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo a {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}
.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 8px;
}
.nav-links li a {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text);
    transition: background 0.2s;
}
.nav-links li a:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.nav-admin {
    font-size: 1.1rem !important;
    padding: 6px 10px !important;
}

/* ============================
   MAIN CONTENT
   ============================ */

.main-content {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* ============================
   HOME - HERO
   ============================ */

.hero-section {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    margin-bottom: 40px;
}
.hero-title {
    font-size: 2.2rem;
    margin: 0 0 12px;
    line-height: 1.3;
}
.hero-brand {
    color: #ffd54f;
}
.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0 auto 28px;
    max-width: 500px;
    line-height: 1.6;
}
.btn-hero {
    display: inline-block;
    background: var(--white);
    color: var(--primary);
    padding: 14px 36px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.05rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* ============================
   HOME - FEATURES
   ============================ */

.features-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.feature-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}
.feature-card h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: var(--primary);
}
.feature-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ============================
   THEMES GRID
   ============================ */

.section-header {
    text-align: center;
    margin-bottom: 24px;
}
.section-header h2 {
    margin: 0 0 6px;
    font-size: 1.5rem;
}
.section-header p {
    margin: 0;
    color: var(--text-light);
}
.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}
.theme-card-link {
    display: block;
}
.theme-card {
    background: white;
    border-radius: 16px;
    padding: 28px 16px 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.theme-progress-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.theme-progress-mini .progress-bar {
    flex: 1;
    height: 6px;
    background: #e8e8e8;
    border-radius: 3px;
    overflow: hidden;
}

.theme-progress-mini .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.pct-text {
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
    min-width: 30px;
}
.theme-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
}
.theme-ar {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}
.theme-fr {
    display: block;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ============================
   PAGE HEADER
   ============================ */

.page-header {
    text-align: center;
    margin-bottom: 28px;
}
.page-header h1 {
    margin: 0 0 6px;
    font-size: 1.6rem;
}
.page-header p {
    margin: 0;
    color: var(--text-light);
    font-size: 1rem;
}

/* ============================
   BREADCRUMB
   ============================ */

.breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 20px;
    color: var(--text-light);
}
.breadcrumb a {
    color: var(--primary);
}
.breadcrumb a:hover {
    text-decoration: underline;
}
.breadcrumb .sep {
    margin: 0 6px;
    color: #bbb;
}
.breadcrumb .current {
    color: var(--text);
}

/* ============================
   ITEMS GRID
   ============================ */

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.item-card-link {
    display: block;
}
.item-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.item-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
}
.item-image {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.item-image img {
    max-width: 80px;
    max-height: 80px;
    height: auto;
    object-fit: contain;
}
.item-info {
    padding: 14px;
    text-align: center;
}
.item-ar {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}
.item-fr {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ============================
   FLASHCARD
   ============================ */

.flashcard-page {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}
.flashcard-nav {
    margin-bottom: 16px;
}
.back-link {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
}
.back-link:hover {
    text-decoration: underline;
}
.flashcard-container {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-hover);
    padding: 32px 24px;
    text-align: center;
}
.card-image {
    background: #f8f8f8;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-image img {
    max-width: 100px;
    max-height: 100px;
    height: auto;
    object-fit: contain;
}
.card-content {
    margin-bottom: 20px;
}
.arabic-text {
    font-size: 2.8rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px;
    line-height: 1.4;
    direction: rtl;
}
.french-translation {
    font-size: 1.1rem;
    color: var(--text-light);
    margin: 0;
}

/* Flashcard buttons */
.card-controls,
.voice-recorder {
    margin-bottom: 16px;
}
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-weight: 600;
}
.btn:active {
    transform: scale(0.98);
}
.btn-audio {
    background: #e0f2f1;
    color: #00695c;
}
.btn-audio:hover {
    background: #b2dfdb;
}
.btn-record {
    background: #f5f5f5;
    color: #333;
}
.btn-record:hover {
    background: #e0e0e0;
}
.btn-record.recording {
    background: #c62828;
    color: white;
    animation: pulse 1s infinite;
}
.status-text {
    font-size: 0.85rem;
    margin: 10px 0 0;
    min-height: 1.2em;
}
.no-audio {
    color: #aaa;
    font-size: 0.75rem;
    font-style: italic;
}

/* Spaced repetition */
.spaced-repetition-controls {
    border-top: 1px solid #eee;
    padding-top: 20px;
}
.review-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0 0 12px;
}
.review-buttons {
    display: flex;
    gap: 8px;
}
.btn-review {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.1s;
}
.btn-review:active {
    transform: scale(0.95);
}
.btn-review-hard {
    background: #ffebee;
    color: #c62828;
}
.btn-review-hard:hover {
    background: #ffcdd2;
}
.btn-review-medium {
    background: #fff8e1;
    color: #f57f17;
}
.btn-review-medium:hover {
    background: #ffecb3;
}
.btn-review-easy {
    background: #e8f5e9;
    color: #2e7d32;
}
.btn-review-easy:hover {
    background: #c8e6c9;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ============================
   FOOTER
   ============================ */

.main-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid #e0e0e0;
    margin-top: auto;
}

/* ============================
   EMPTY STATE
   ============================ */

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 48px 24px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-state a {
    color: var(--primary);
    text-decoration: underline;
}
.btn-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    font-weight: 600;
}

/* ============================
   THEME PAGE BLOCKS + PROGRESS
   ============================ */

.theme-progress {
    max-width: 960px;
    margin: 0 auto 24px;
    padding: 16px 24px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-progress .progress-bar {
    flex: 1;
    height: 12px;
    background: #e8e8e8;
    border-radius: 6px;
    overflow: hidden;
}

.theme-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #43a047);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.theme-progress .progress-text {
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
}

.theme-block {
    max-width: 960px;
    margin: 0 auto 32px;
}

.block-title {
    font-size: 1.15rem;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e8f5e9;
    color: #333;
}

.block-desc {
    color: #666;
    font-size: 0.9rem;
    margin: 0 0 12px;
}

.review-block {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

@media (max-width: 640px) {
    .theme-progress {
        flex-direction: column;
        text-align: center;
    }
    .theme-progress .progress-text {
        white-space: normal;
    }
}

/* ============================
   STATS BAR + RESUME SECTION
   ============================ */

.resume-section {
    max-width: 960px;
    margin: -20px auto 40px;
    padding: 0 24px;
}

.stats-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-item {
    background: white;
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    min-width: 100px;
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.resume-card {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.resume-card h3 {
    margin: 0;
    font-size: 1rem;
    min-width: 140px;
}

.progress-bar {
    flex: 1;
    min-width: 120px;
    height: 10px;
    background: #e8e8e8;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #43a047);
    border-radius: 5px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: #555;
    min-width: 90px;
    margin: 0;
}

.btn-sm {
    padding: 8px 20px;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .resume-card {
        flex-direction: column;
        text-align: center;
    }
    .stats-bar {
        gap: 8px;
    }
    .stat-item {
        padding: 12px 16px;
        min-width: 70px;
    }
    .stat-value {
        font-size: 1.2rem;
    }
}

/* ============================
   FLASHCARD NAV + TYPE LABEL
   ============================ */

.flashcard-nav {
    display: flex;
    gap: 12px;
    padding: 12px 24px;
    max-width: 600px;
    margin: 0 auto;
    align-items: center;
    flex-wrap: wrap;
}

.flashcard-nav .back-link {
    margin-right: auto;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.nav-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 14px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: var(--primary);
    color: white;
}

.card-type-label {
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 8px;
}

/* ============================
   PHRASE DETAILS
   ============================ */

.phrase-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.phrase-card {
    background: #f9fff9;
    border: 1px solid #e0f0e0;
    border-radius: 12px;
    padding: 16px;
}

.phrase-text {
    margin-bottom: 8px;
}

.phrase-text .item-ar.large {
    font-size: 1.3rem;
    display: block;
}

.phrase-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.85rem;
}

.phrase-link-label {
    color: #888;
    font-weight: 600;
    margin-right: 4px;
}

.phrase-link-item {
    background: #e8f5e9;
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.phrase-link-item:hover {
    background: #c8e6c9;
}

/* ============================
   THEME COUNTS
   ============================ */

.theme-counts {
    display: block;
    font-size: 0.75rem;
    color: #999;
    margin-top: 6px;
}

.block-count {
    font-size: 0.85rem;
    color: #999;
    font-weight: 400;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 640px) {
    .hero-section {
        padding: 40px 24px;
    }
    .hero-title {
        font-size: 1.6rem;
    }
    .hero-subtitle {
        font-size: 1rem;
    }
    .features-section {
        grid-template-columns: 1fr;
    }
    .themes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .review-buttons {
        flex-direction: column;
    }
    .arabic-text {
        font-size: 2.2rem;
    }
    .flashcard-container {
        padding: 20px 16px;
    }
}

/* Theme tabs */
.theme-tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.theme-tab {
    flex: 1;
    min-width: 140px;
    text-align: center;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-decoration: none;
    color: #555;
    font-size: 1rem;
    font-weight: 600;
    transition: all .2s;
    background: #fff;
}
.theme-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.theme-tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.theme-tab .tab-count {
    display: inline-block;
    background: #e0e0e0;
    color: #555;
    border-radius: 20px;
    padding: 0 10px;
    font-size: .85rem;
    margin-left: 6px;
    font-weight: 700;
}
.theme-tab.active .tab-count {
    background: rgba(255,255,255,.25);
    color: #fff;
}
.block-desc {
    color: #666;
    font-size: .9rem;
    margin: 8px 0 16px;
}

@media (max-width: 400px) {
    .themes-grid,
    .items-grid {
        grid-template-columns: 1fr;
    }
    .theme-tabs {
        flex-direction: column;
    }
    .theme-tab {
        min-width: auto;
    }
}
