/* ============================================================
   Espace formation - Feuille de style globale
   Esthétique: éditoriale, refined, professionnelle
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --ink: #14161a;
    --ink-soft: #2a2d35;
    --ink-muted: #6b6f78;
    --paper: #faf8f4;
    --paper-warm: #f1ecdf;
    --line: #e3ddcd;
    --line-soft: #ece6d6;

    --accent: #b94e2a;          /* terracotta */
    --accent-soft: #fbe9e0;
    --admin-accent: #1f4b3f;    /* vert forêt */
    --admin-accent-soft: #e2efe8;

    --success: #2f7d5b;
    --warn: #c08725;
    --danger: #b1361e;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.04), 0 1px 1px rgba(20, 22, 26, 0.06);
    --shadow: 0 4px 16px rgba(20, 22, 26, 0.06), 0 2px 4px rgba(20, 22, 26, 0.04);
    --shadow-lg: 0 24px 60px rgba(20, 22, 26, 0.1), 0 4px 12px rgba(20, 22, 26, 0.06);

    --serif: 'Fraunces', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0 0 0.4em;
    font-variation-settings: "opsz" 144;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; }
h2 { font-size: 1.5rem; margin-top: 2.5rem; }
h3 { font-size: 1.1rem; font-family: var(--sans); font-weight: 600; }

p { margin: 0 0 1rem; }

.muted { color: var(--ink-muted); }

code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--paper-warm);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--ink-soft);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.link-muted { color: var(--ink-muted); }
.link-muted:hover { color: var(--ink); }

/* ============================================================
   AUTH (login pages)
   ============================================================ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at top left, var(--paper-warm) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, #f4ead4 0%, transparent 50%),
        var(--paper);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 48px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    position: relative;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 24px; right: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}

.auth-card--admin::before { background: var(--admin-accent); }

.auth-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-muted);
    margin-bottom: 32px;
}

.auth-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-dot--admin {
    background: var(--admin-accent);
    box-shadow: 0 0 0 3px var(--admin-accent-soft);
}

.auth-sub {
    color: var(--ink-muted);
    margin-bottom: 28px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
}

.auth-card input {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    background: var(--paper);
    transition: border 0.15s, box-shadow 0.15s;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(20, 22, 26, 0.08);
}

.btn-primary {
    margin-top: 8px;
    padding: 13px 20px;
    background: var(--ink);
    color: var(--paper);
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}

.btn-primary:hover { background: var(--ink-soft); }
.btn-primary:active { transform: translateY(1px); }

.auth-hint {
    margin-top: 28px;
    font-size: 13px;
    color: var(--ink-muted);
    text-align: center;
    padding-top: 20px;
    border-top: 1px dashed var(--line);
}

.alert {
    background: #fdecec;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 3px solid var(--danger);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar--admin { background: var(--ink); border-bottom-color: var(--ink-soft); }
.topbar--admin .brand,
.topbar--admin .topbar-user span { color: var(--paper); }
.topbar--admin .link-muted { color: rgba(250, 248, 244, 0.6); }
.topbar--admin .link-muted:hover { color: var(--paper); }

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.01em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 14px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 48px 28px 80px;
}

.container--wide { max-width: 1280px; }

/* ============================================================
   VIDEO GRID (liste client)
   ============================================================ */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.video-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--ink);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: block;
}

.video-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--ink-muted);
}

.video-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--paper-warm);
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.badge {
    position: absolute;
    top: 12px; right: 12px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    backdrop-filter: blur(8px);
}

.badge-new { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.badge-progress { background: rgba(185, 78, 42, 0.92); color: #fff; }
.badge-done { background: rgba(47, 125, 91, 0.92); color: #fff; }

.video-meta {
    padding: 18px;
}

.video-meta h3 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.15rem;
    margin: 0 0 6px;
}

.video-meta p {
    margin: 0 0 14px;
    font-size: 13.5px;
    color: var(--ink-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.progress-bar {
    height: 4px;
    background: var(--line-soft);
    border-radius: 2px;
    overflow: hidden;
}

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

/* ============================================================
   PLAYER PAGE (sécurisé)
   ============================================================ */
.player-shell {
    margin-top: 28px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16/9;
    box-shadow: var(--shadow-lg);
    position: relative;
    isolation: isolate;
}

.player-shell iframe,
.player-shell #ytplayer,
.player-shell #ytplayer iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

/* Overlay anti-clic : bloque les zones cliquables YouTube (logo, titre)
   sans empêcher les controls du lecteur (barre du bas) */
.player-overlay {
    position: absolute;
    z-index: 5;
    background: transparent;
    cursor: default;
}

/* Bande du haut : bloque le titre cliquable YouTube */
.player-overlay--title {
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    pointer-events: auto;
}

/* Coin bas droit : bloque le logo YouTube qui ouvre youtube.com */
.player-overlay--logo {
    bottom: 8px;
    right: 8px;
    width: 80px;
    height: 40px;
    pointer-events: auto;
}

/* Watermark : nom client + ID session, en surimpression */
.watermark {
    position: absolute;
    z-index: 6;
    font-family: var(--mono);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.32);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    background: rgba(0, 0, 0, 0.18);
    padding: 4px 10px;
    border-radius: 4px;
    backdrop-filter: blur(2px);
    pointer-events: none;
    user-select: none;
    transition: top 1.2s ease, left 1.2s ease, right 1.2s ease, bottom 1.2s ease;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Bloqueur affiché quand devtools détectés */
.player-blocker {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(20, 22, 26, 0.96);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--paper);
    padding: 40px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.player-blocker.active {
    opacity: 1;
    pointer-events: auto;
}

.player-blocker-content strong {
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 500;
    display: block;
    margin-bottom: 12px;
}

.player-blocker-content p {
    color: rgba(250, 248, 244, 0.7);
    margin: 0;
    max-width: 360px;
}

.player-notice {
    margin-top: 20px;
    font-size: 13px;
    padding: 12px 16px;
    background: var(--paper-warm);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

/* ============================================================
   MODE SWITCH (Vidéo / Audio)
   ============================================================ */
.mode-switch {
    display: inline-flex;
    gap: 4px;
    margin-top: 28px;
    padding: 4px;
    background: var(--paper-warm);
    border-radius: 100px;
    border: 1px solid var(--line);
}

.mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-muted);
    transition: all 0.18s;
}

.mode-btn:hover { text-decoration: none; color: var(--ink); }

.mode-btn.active {
    background: var(--ink);
    color: var(--paper);
    box-shadow: var(--shadow-sm);
}

.mode-icon { font-size: 13px; line-height: 1; }

/* ============================================================
   AUDIO PLAYER (balado)
   ============================================================ */
.audio-shell {
    margin-top: 24px;
    background: linear-gradient(160deg, var(--ink) 0%, #1d2027 100%);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.audio-cover {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 28px;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}

.audio-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(1.1);
}

.audio-cover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 45%);
}

.audio-badge {
    align-self: flex-start;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 100px;
    backdrop-filter: blur(6px);
    letter-spacing: 0.04em;
}

.audio-watermark {
    align-self: flex-end;
    font-family: var(--mono);
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    background: rgba(0,0,0,0.3);
    padding: 3px 8px;
    border-radius: 4px;
}

.audio-shell audio {
    width: 100%;
    display: block;
    border-radius: 100px;
    outline: none;
}

/* Style du lecteur audio natif (WebKit) */
.audio-shell audio::-webkit-media-controls-panel {
    background: var(--paper);
}

.audio-hint {
    color: rgba(250, 248, 244, 0.65);
    font-size: 13px;
    text-align: center;
    margin: 20px 0 0;
}

/* ============================================================
   CARD ACTIONS (boutons regarder / écouter)
   ============================================================ */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.card-btn {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    background: #fff;
    transition: all 0.15s;
}

.card-btn:hover {
    text-decoration: none;
    border-color: var(--ink-muted);
    background: var(--paper-warm);
}

.card-btn--primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.card-btn--primary:hover {
    background: var(--ink-soft);
    color: var(--paper);
}

.player-stats {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    flex: 1;
    min-width: 140px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-muted);
    font-weight: 500;
}

.stat-value {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--ink);
}

/* ============================================================
   ADMIN DASHBOARD
   ============================================================ */
.admin-body { background: var(--paper); }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 32px 0 40px;
}

.kpi {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--admin-accent);
}

.kpi--wide { grid-column: span 2; }
@media (max-width: 720px) { .kpi--wide { grid-column: span 1; } }

.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-muted);
    font-weight: 500;
}

.kpi-value {
    font-family: var(--serif);
    font-size: 2rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.02em;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 14px 18px;
    background: var(--paper-warm);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    font-weight: 600;
    white-space: nowrap;
}

.data-table th.num,
.data-table td.num { text-align: right; }

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-warm); }

.cell-video {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cell-video img {
    width: 60px;
    height: 34px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.btn-link {
    font-size: 13px;
    color: var(--admin-accent);
    font-weight: 500;
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pill-done { background: var(--admin-accent-soft); color: var(--admin-accent); }
.pill-progress { background: var(--accent-soft); color: var(--accent); }
.pill-new { background: var(--line-soft); color: var(--ink-muted); }
.pill-alert { background: #fde2dd; color: var(--danger); font-weight: 700; }
.pill-video { background: var(--accent-soft); color: var(--accent); }
.pill-audio { background: #e6eef5; color: #1d5a8a; }

/* ============================================================
   HEATMAP
   ============================================================ */
.heatmap-container {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin: 24px 0 40px;
    display: grid;
    grid-template-columns: 50px 1fr;
    gap: 12px;
}

.heatmap-axis-y {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 11px;
    color: var(--ink-muted);
    font-family: var(--mono);
    padding: 0 8px 0 0;
    border-right: 1px solid var(--line-soft);
    height: 200px;
}

.heatmap {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 1px;
    grid-column: 2;
    overflow-x: auto;
}

.heatmap-bar {
    flex: 1;
    min-width: 2px;
    background: var(--admin-accent);
    border-radius: 1px 1px 0 0;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
}

.heatmap-bar:hover {
    opacity: 1 !important;
    transform: scaleY(1.05);
    transform-origin: bottom;
}

.heatmap-axis-x {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-muted);
    font-family: var(--mono);
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .container { padding: 28px 18px 60px; }
    .auth-card { padding: 32px 24px; }
    h1 { font-size: 1.75rem; }
    .topbar-inner { padding: 14px 18px; }
}

/* ============================================================
   CARD HEADER - titre proéminent au-dessus de la miniature
   ============================================================ */
.video-card-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(180deg, var(--paper-warm) 0%, #fff 100%);
}

.video-card-number {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
}
