/**
 * QCM Standalone - PWA App Shell
 * Noir & blanc, premium, moderne
 * Light theme par défaut + toggle dark
 */

/* Dark theme (default) */
:root,
body.app-theme-dark {
    --app-bg: #0a0a0a;
    --app-bg-alt: #111111;
    --app-surface: #161616;
    --app-surface-elevated: #1c1c1c;
    --app-border: rgba(255, 255, 255, 0.08);
    --app-border-strong: rgba(255, 255, 255, 0.12);
    --app-text: #fafafa;
    --app-text-muted: #a1a1aa;
    --app-text-subtle: #71717a;
    --app-accent: #ffffff;
    --app-accent-soft: rgba(255, 255, 255, 0.06);
    --app-radius: 16px;
    --app-radius-sm: 12px;
    --app-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --app-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Light theme : fond clair unifié */
body.app-theme-light {
    --app-bg: #e5e7eb;
    --app-bg-alt: #e5e7eb;
    --app-page-inner: #e5e7eb;
    --app-surface: #ffffff;
    --app-surface-elevated: #f8fafc;
    --app-border: rgba(0, 0, 0, 0.12);
    --app-border-strong: rgba(0, 0, 0, 0.2);
    --app-text: #0f172a;
    --app-text-muted: #475569;
    --app-text-subtle: #64748b;
    --app-accent: #0f172a;
    --app-accent-soft: rgba(0, 0, 0, 0.08);
    --app-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

body.app-theme-light main {
    background: var(--app-page-inner) !important;
    min-height: calc(100vh - 60px);
}

body.app-theme-light .app-section {
    background: var(--app-page-inner) !important;
}

body.app-theme-light .app-hero {
    background: var(--app-page-inner) !important;
}

body.app-theme-light .app-hero::before {
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 0, 0, 0.06) 0%, transparent 70%);
}

body.app-theme-light .app-header {
    background: rgba(229, 231, 235, 0.95) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12) !important;
}

body.app-theme-light .app-header__logo,
body.app-theme-light .app-header__link {
    color: #0f172a !important;
}

body.app-theme-light .app-header__link:hover,
body.app-theme-light .app-header__link.is-active {
    color: #0f172a !important;
    background: rgba(0, 0, 0, 0.08) !important;
}

body.app-theme-light .app-theme-toggle {
    background: rgba(0, 0, 0, 0.08) !important;
    color: #475569 !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
}

body.app-theme-light .app-theme-toggle:hover {
    color: #0f172a !important;
}

body.app-theme-light .app-hero__badge,
body.app-theme-light .app-hero__title,
body.app-theme-light .app-hero__subtitle {
    color: #0f172a !important;
}

body.app-theme-light .app-hero__badge {
    color: #475569 !important;
}

body.app-theme-light .app-hero__subtitle {
    color: #475569 !important;
}

body.app-theme-light .qcm-choice-btn {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.app-theme-light .qcm-choice-btn:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

body.app-theme-light .qcm-choice-btn__icon {
    background: rgba(30, 64, 175, 0.08) !important;
}

body.app-theme-light .qcm-choice-btn:hover .qcm-choice-btn__arrow {
    color: #1e40af !important;
}

body.app-theme-light .qcm-choice-btn__meta {
    color: #475569 !important;
}

body.app-theme-light .qcm-back-btn {
    color: #0f172a !important;
}

body.app-theme-light .qcm-back-btn:hover {
    color: #1e40af !important;
}

body.app-theme-light .fiche-card {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.app-theme-light .fiche-card:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

body.app-theme-light .fiche-card__icon {
    background: rgba(30, 64, 175, 0.08) !important;
}

body.app-theme-light .fiche-card:hover .fiche-card__arrow {
    color: #1e40af !important;
}

body.app-theme-light .app-empty {
    color: #475569 !important;
}

body.app-theme-light .historique-list .historique-item {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

body.app-theme-light .historique-item:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--app-font);
    background: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   HEADER — Sticky, glassmorphism
   ======================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1100;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--app-border);
}

.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.app-header__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    background: var(--app-accent-soft);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    color: var(--app-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1200;
    pointer-events: auto;
}

.app-theme-toggle:hover {
    color: var(--app-text);
}

.app-theme-toggle:focus-visible {
    outline: 2px solid var(--app-border-strong);
    outline-offset: 2px;
}

.app-header__logo {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
    color: var(--app-text);
    text-decoration: none;
}

.app-header__nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.app-header__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text-muted);
    text-decoration: none;
    border-radius: var(--app-radius-sm);
    transition: all 0.2s ease;
}

.app-header__link:hover {
    color: var(--app-text);
    background: var(--app-accent-soft);
}

.app-header__link.is-active {
    color: var(--app-text);
    background: var(--app-accent-soft);
}

.app-header__link-icon {
    font-size: 1rem;
    opacity: 0.9;
}

/* Mobile nav */
@media (max-width: 768px) {
    .app-header__inner {
        flex-direction: column;
        align-items: stretch;
    }
    .app-header__nav {
        justify-content: center;
    }
    .app-header__link {
        flex: 1;
        justify-content: center;
    }
}

/* ========================================
   HERO SECTIONS — Premium
   ======================================== */
.app-hero {
    padding: 4rem 1.5rem 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.app-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.app-hero__content {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
}

.app-hero__badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--app-text-muted);
    margin-bottom: 1rem;
}

.app-hero__title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin: 0 0 0.75rem;
    color: var(--app-text);
}

.app-hero__subtitle {
    font-size: 1.0625rem;
    color: var(--app-text-muted);
    line-height: 1.6;
    margin: 0;
}

/* ========================================
   SECTIONS — Conteneurs
   ======================================== */
.app-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.app-section__content {
    padding: 0 0 2rem;
}

.app-section.is-hidden {
    display: none;
}

.app-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 2rem;
    box-shadow: var(--app-shadow);
}

/* ========================================
   FICHES — Grille premium SaaS PWA
   ======================================== */
.fiches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.fiche-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.fiche-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--app-accent, #6366f1), rgba(99, 102, 241, 0.5));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.fiche-card:hover {
    border-color: var(--app-border-strong);
    background: var(--app-surface-elevated);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.fiche-card:hover::before {
    opacity: 1;
}

.fiche-card:active {
    transform: translateY(0);
}

.fiche-card__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    color: var(--app-accent, #6366f1);
}

.fiche-card__content {
    flex: 1;
    min-width: 0;
}

.fiche-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--app-text);
    letter-spacing: -0.01em;
    line-height: 1.35;
}

.fiche-card__meta {
    font-size: 0.8125rem;
    color: var(--app-text-muted);
    margin: 0;
    line-height: 1.4;
}

.fiche-card__arrow {
    flex-shrink: 0;
    font-size: 1.25rem;
    color: var(--app-text-muted);
    opacity: 0.5;
    transition: all 0.25s ease;
}

.fiche-card:hover .fiche-card__arrow {
    opacity: 1;
    color: var(--app-accent, #6366f1);
    transform: translateX(4px);
}

/* ========================================
   HISTORIQUE — Liste
   ======================================== */
.historique-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.historique-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.historique-item:hover {
    border-color: var(--app-border-strong);
    background: var(--app-surface-elevated);
}

.historique-item:focus-visible {
    outline: 2px solid var(--app-border-strong);
    outline-offset: 2px;
}

.historique-item__icon {
    font-size: 1.25rem;
    opacity: 0.8;
}

.historique-item__content {
    flex: 1;
    min-width: 0;
}

.historique-item__title {
    font-size: 0.9375rem;
    font-weight: 500;
    margin: 0 0 0.25rem;
}

.historique-item__meta {
    font-size: 0.8125rem;
    color: var(--app-text-muted);
}

.historique-item__arrow {
    flex-shrink: 0;
    font-size: 1.125rem;
    color: var(--app-text-muted);
    opacity: 0.5;
    transition: all 0.2s ease;
}

.historique-item:hover .historique-item__arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* Empty state */
.app-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--app-text-muted);
}

.app-empty__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.app-empty__text {
    font-size: 0.9375rem;
}

/* ========================================
   QCM HOME — Menu de choix
   ======================================== */
.qcm-home {
    padding: 0 0 2rem;
}

.qcm-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.qcm-choice-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    font-family: inherit;
    color: var(--app-text);
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.qcm-choice-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--app-accent, #6366f1), rgba(99, 102, 241, 0.5));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.qcm-choice-btn:hover {
    border-color: var(--app-border-strong);
    background: var(--app-surface-elevated);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.qcm-choice-btn:hover::before {
    opacity: 1;
}

.qcm-choice-btn:active {
    transform: translateY(0);
}

.qcm-choice-btn__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    color: var(--app-accent, #6366f1);
}

.qcm-choice-btn__content {
    flex: 1;
    min-width: 0;
}

.qcm-choice-btn__title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
    line-height: 1.35;
}

.qcm-choice-btn__meta {
    display: block;
    font-size: 0.8125rem;
    color: var(--app-text-muted);
    margin: 0;
    line-height: 1.4;
}

.qcm-choice-btn__arrow {
    flex-shrink: 0;
    font-size: 1.25rem;
    color: var(--app-text-muted);
    opacity: 0.5;
    transition: all 0.25s ease;
}

.qcm-choice-btn:hover .qcm-choice-btn__arrow {
    opacity: 1;
    color: var(--app-accent, #6366f1);
    transform: translateX(4px);
}

.qcm-home.is-hidden,
.qcm-runner-wrap.is-hidden {
    display: none !important;
}

.qcm-runner-wrap .qcm-back-btn {
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--app-accent-soft);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    color: var(--app-text-muted);
    cursor: pointer;
    font-family: inherit;
}

.qcm-runner-wrap .qcm-back-btn:hover {
    color: var(--app-text);
}

/* Réduire hauteur QCM sur PC */
@media (min-width: 769px) {
    .qcm-start-card { padding: 2rem 2.5rem !important; }
    .qcm-start-header { margin-bottom: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .qcm-mode-selection .qcm-mode-card { padding: 0.875rem 1rem !important; min-height: 90px !important; }
    .qcm-mode-selection .qcm-modes-grid { margin-top: 0.75rem !important; gap: 0.5rem !important; }
    .qcm-topbar { padding: 0.875rem 1.25rem !important; margin-bottom: 1.25rem !important; }
    .qcm-question-card { padding: 1.5rem 2rem !important; }
    .qcm-option { padding: 0.75rem 1rem !important; }
    .app-hero { padding: 2.5rem 1.5rem 2rem !important; }
    .qcm-runner { padding: 0 1.5rem !important; }
}
