/**
 * Projet Wiqyaya - Styles principaux
 * Mobile-first, accessible, performant
 */

:root {
    --primary: #1B4F72;
    --primary-light: #2E86C1;
    --teal: #17A589;
    --gold: #D4AC0D;
    --pink: #F1948A;
    --sky: #85C1E9;
    --green: #58D68D;
    --purple: #BB8FCE;
    --gray: #AEB6BF;
    --dark: #1C2833;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --bg: #F8F9FA;
    --white: #FFFFFF;
    --border: #E5E8EB;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s ease;
}

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

html, body {
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== APP SHELL ===== */
#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
    position: relative;
}

#app-content {
    padding-bottom: 80px;
    min-height: calc(100vh - 80px);
}

/* ===== BOTTOM NAVIGATION ===== */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 70px;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 22px; }

/* ===== SCREENS ===== */
.screen { padding: 16px; animation: fadeIn 0.2s ease; }

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

.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 16px;
}

.screen-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

/* ===== ONBOARDING ===== */
.onboarding-screen {
    padding: 40px 24px;
    text-align: center;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.onboarding-logo { width: 80px; margin-bottom: 24px; }

.onboarding-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.onboarding-subtitle {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 32px;
}

.language-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

.lang-btn {
    padding: 16px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.lang-btn.selected {
    border-color: var(--primary);
    background: #EBF5FB;
}

.lang-native { font-size: 18px; font-weight: 700; }
.lang-name { font-size: 12px; color: var(--text-light); }

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

.profile-btn {
    padding: 20px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.profile-btn:hover, .profile-btn:active {
    border-color: var(--accent, var(--primary));
    transform: scale(1.02);
}

.profile-emoji { font-size: 32px; }
.profile-label { font-size: 13px; font-weight: 600; color: var(--text); }

.step-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--border);
}

.dot.active { background: var(--primary); width: 24px; border-radius: 4px; }

/* ===== HOME ===== */
.home-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
}

.home-greeting { font-size: 14px; color: var(--text-light); }
.home-title { font-size: 24px; font-weight: 800; color: var(--dark); }

.connection-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.connection-badge.online { background: #D5F5E3; color: #1E8449; }
.connection-badge.offline { background: #FDEDEC; color: #C0392B; }

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0 12px;
    color: var(--dark);
}

.category-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar { display: none; }

.category-card {
    min-width: 120px;
    padding: 16px 12px;
    border-radius: var(--radius);
    background: var(--white);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.category-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.category-icon { font-size: 28px; }
.category-icon img { width: 28px; height: 28px; }
.category-name { font-size: 13px; font-weight: 600; color: var(--text); }
.category-count { font-size: 11px; color: var(--text-light); }

.featured-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.featured-card:hover { box-shadow: var(--shadow-lg); }
.featured-img { width: 100%; height: 160px; object-fit: cover; }
.featured-content { padding: 16px; }
.featured-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary);
    color: var(--white);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
}

.featured-content h3 { font-size: 18px; margin-bottom: 4px; }
.featured-content p { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.featured-meta { font-size: 12px; color: var(--text-light); }

/* ===== CATEGORIES LIST ===== */
.categories-list { display: flex; flex-direction: column; gap: 12px; }

.category-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--white);
    border-radius: var(--radius);
    border-left: 4px solid var(--cat-color, var(--primary));
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.category-row:hover { transform: translateX(4px); }
.cat-row-icon { font-size: 32px; }
.cat-row-icon img { width: 32px; height: 32px; }
.cat-row-info h3 { font-size: 16px; margin-bottom: 2px; }
.cat-row-info p { font-size: 13px; color: var(--text-light); }
.cat-row-count {
    margin-left: auto;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* ===== MODULES LIST ===== */
.modules-list { display: flex; flex-direction: column; gap: 12px; }

.module-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.module-card:hover { box-shadow: var(--shadow-lg); }
.module-number {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.module-info h3 { font-size: 16px; margin-bottom: 4px; }
.module-info p { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.module-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-light); }

/* ===== CARD VIEWER ===== */
.card-viewer { padding: 0; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

.card-progress { font-size: 14px; font-weight: 600; color: var(--text-light); }

.card-progress-bar {
    height: 3px;
    background: var(--border);
}

.card-progress-fill {
    height: 100%;
    background: var(--teal);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.card-content { padding: 0 16px 16px; }
.card-image { width: 100%; border-radius: var(--radius); margin-bottom: 16px; }
.card-video { width: 100%; border-radius: var(--radius); margin-bottom: 16px; }
.card-title { font-size: 22px; font-weight: 700; margin-bottom: 12px; color: var(--dark); }
.card-body { font-size: 15px; line-height: 1.7; color: var(--text); }

.card-audio { margin-top: 16px; }
.btn-audio {
    padding: 12px 24px;
    border: 2px solid var(--primary);
    border-radius: 30px;
    background: var(--white);
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.tag {
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-light);
}

.card-nav {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* ===== QUIZ ===== */
.quiz-screen { padding: 16px; }
.quiz-header { margin-bottom: 24px; }
.quiz-question h2 { font-size: 20px; margin-bottom: 16px; line-height: 1.5; }
.quiz-image { width: 100%; border-radius: var(--radius); margin-bottom: 16px; }

.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    font-size: 15px;
    text-align: left;
}

.quiz-option:hover { border-color: var(--primary-light); }
.quiz-option.selected { border-color: var(--primary); background: #EBF5FB; }

.option-letter {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.quiz-result { text-align: center; padding: 40px 24px; }
.result-icon { font-size: 64px; margin-bottom: 16px; }
.score-circle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    border: 4px solid var(--teal);
    border-radius: 50%;
    width: 140px; height: 140px;
    justify-content: center;
    margin: 24px 0;
}

.score-number { font-size: 36px; font-weight: 800; color: var(--teal); }
.score-label { font-size: 12px; color: var(--text-light); }

/* ===== RECIPES ===== */
.recipes-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.recipe-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.recipe-card:hover { box-shadow: var(--shadow-lg); }
.recipe-card-img { width: 100%; height: 120px; object-fit: cover; }
.placeholder-img {
    width: 100%; height: 120px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.recipe-card-info { padding: 10px; }
.recipe-card-info h3 { font-size: 14px; margin-bottom: 4px; }
.recipe-card-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 8px; }

/* ===== PROFILE ===== */
.profile-info { text-align: center; padding: 24px 0; }
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin: 0 auto 12px;
}

.profile-info h2 { font-size: 22px; }
.profile-type { font-size: 14px; color: var(--text-light); }

.profile-stats {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.stat { text-align: center; }
.stat-num { font-size: 24px; font-weight: 800; color: var(--primary); display: block; }
.stat-label { font-size: 12px; color: var(--text-light); }

.profile-actions { display: flex; flex-direction: column; gap: 4px; }

/* ===== BUTTONS ===== */
.btn-primary {
    padding: 14px 24px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    padding: 14px 24px;
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
}

.btn-full { width: 100%; margin-bottom: 8px; }
.btn-text {
    background: none; border: none; color: var(--text-light);
    font-size: 14px; cursor: pointer; padding: 8px;
    font-family: var(--font);
}

.btn-back {
    width: 36px; height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-back:hover { background: var(--border); }

.btn-icon {
    width: 36px; height: 36px;
    border: none; background: none;
    font-size: 20px; cursor: pointer;
}

.btn-row {
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: var(--white);
    text-align: left;
    font-size: 15px;
    font-family: var(--font);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.btn-row:hover { background: var(--bg); }
.btn-danger { color: #E74C3C; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; text-align: left; }
.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font);
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint { font-size: 13px; color: var(--text-light); margin-top: 6px; }

/* ===== UTILITIES ===== */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-light);
    font-size: 15px;
}

.placeholder-text { color: var(--text-light); font-size: 14px; }

.skeleton-card {
    height: 200px;
    background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SETTINGS ===== */
.settings-list { display: flex; flex-direction: column; }
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.setting-value { color: var(--text-light); font-size: 14px; }

.about-section {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 13px;
}

.about-credits { font-size: 12px; margin-top: 4px; }

/* ===== RECIPE MINI ===== */
.recipe-card-mini {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.recipe-thumb { width: 80px; height: 80px; border-radius: var(--radius-sm); object-fit: cover; }
.recipe-thumb-placeholder {
    width: 80px; height: 80px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.recipe-info h4 { font-size: 15px; margin-bottom: 4px; }
.recipe-meta { font-size: 12px; color: var(--text-light); }

/* ===== RTL SUPPORT ===== */
[dir="rtl"] .card-nav { flex-direction: row-reverse; }
[dir="rtl"] .category-row { border-left: none; border-right: 4px solid var(--cat-color, var(--primary)); }
[dir="rtl"] .cat-row-count { margin-left: 0; margin-right: auto; }

/* ===== RESPONSIVE ===== */
@media (min-width: 481px) {
    #app { box-shadow: var(--shadow-lg); }
    body { background: #E8E8E8; }
}

/* ===== GOOGLE FONT IMPORT ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
