:root {
    --navy: #04293a;
    --blue: #005776;
    --bg: #f5f4f5;
    --white: #ffffff;
    --black: #000000;
    --success: #16834a;
    --warning: #b86a00;
    --danger: #b42318;
    --muted: #667085;
    --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--navy);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

button {
    font: inherit;
    cursor: pointer;
    border: 0;
}

.page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--navy);
    color: var(--white);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-weight: 800;
    letter-spacing: .02em;
    font-size: clamp(18px, 2.5vw, 28px);
}

.zone-label {
    opacity: .9;
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 700;
}

.content {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 22px;
    flex: 1;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 7px 24px rgba(4, 41, 58, .08);
}

.title {
    margin: 0 0 8px;
    font-size: clamp(26px, 4vw, 42px);
    line-height: 1.1;
}

.subtitle {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: clamp(15px, 2vw, 19px);
}

.course-grid,
.choice-grid {
    display: grid;
    gap: 14px;
}

.course-btn,
.choice-btn,
.primary-btn,
.secondary-btn {
    min-height: 72px;
    border-radius: 18px;
    padding: 16px 20px;
    font-weight: 800;
    font-size: clamp(18px, 3vw, 27px);
    text-align: center;
    transition: transform .08s ease, opacity .2s ease;
}

.course-btn:active,
.choice-btn:active,
.primary-btn:active,
.secondary-btn:active {
    transform: scale(.985);
}

.course-btn,
.primary-btn {
    background: var(--blue);
    color: var(--white);
}

.secondary-btn {
    background: #e8eef1;
    color: var(--navy);
}

.choice-btn.free {
    background: var(--navy);
    color: var(--white);
}

.choice-btn.course {
    background: var(--blue);
    color: var(--white);
}

.choice-btn.both {
    background: #dcecef;
    color: var(--navy);
    border: 2px solid var(--blue);
}

.session-bar {
    display: flex;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 18px;
}

.session-main {
    flex: 1;
    background: var(--navy);
    color: var(--white);
    border-radius: 18px;
    padding: 16px 18px;
}

.session-course {
    font-size: clamp(21px, 3vw, 32px);
    font-weight: 900;
}

.session-meta {
    margin-top: 4px;
    opacity: .9;
}

.session-count {
    min-width: 145px;
    border-radius: 18px;
    background: var(--blue);
    color: var(--white);
    display: grid;
    place-items: center;
    padding: 14px;
    text-align: center;
}

.session-count strong {
    display: block;
    font-size: 34px;
}

.camera-card {
    overflow: hidden;
    padding: 0;
    position: relative;
    background: #061b25;
    min-height: 420px;
}

video {
    width: 100%;
    min-height: 420px;
    max-height: 68vh;
    object-fit: cover;
    display: block;
}

.scan-frame {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(62vw, 360px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 5px solid rgba(255,255,255,.9);
    border-radius: 28px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.2);
    pointer-events: none;
}

.scan-hint {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    background: rgba(4,41,58,.9);
    color: white;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 800;
    white-space: nowrap;
}

.action-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-row button { flex: 1; }

.feedback {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: white;
}

.feedback.show { display: flex; }
.feedback.success { background: rgba(22,131,74,.97); }
.feedback.warning { background: rgba(184,106,0,.97); }
.feedback.error { background: rgba(180,35,24,.97); }

.feedback-inner {
    max-width: 720px;
}

.feedback-icon {
    font-size: clamp(64px, 12vw, 120px);
    line-height: 1;
}

.feedback-title {
    font-size: clamp(34px, 7vw, 64px);
    font-weight: 900;
    margin-top: 12px;
}

.feedback-text {
    font-size: clamp(18px, 3vw, 28px);
    margin-top: 10px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 41, 58, .78);
}

.modal.show { display: flex; }

.modal-card {
    width: min(760px, 100%);
    max-height: 94vh;
    overflow: auto;
    background: var(--white);
    border-radius: 26px;
    padding: 24px;
}

.member-name {
    font-size: clamp(28px, 5vw, 46px);
    font-weight: 900;
    margin-bottom: 6px;
}

.countdown {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--white);
    font-weight: 900;
    font-size: 28px;
    margin-bottom: 14px;
}

.hidden { display: none !important; }

.empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--muted);
    font-size: 20px;
}

.status-line {
    margin-top: 12px;
    min-height: 24px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 640px) {
    .content { padding: 14px; }
    .topbar { padding: 14px 16px; }
    .card { padding: 18px; border-radius: 18px; }
    .session-bar { flex-direction: column; }
    .session-count { min-width: 0; }
    .camera-card, video { min-height: 54vh; }
    .action-row { flex-direction: column; }
}


/* ===== Design V1.3 ===== */

.topbar {
    min-height: 78px;
    padding: 10px 22px;
}

.club-brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.club-logo-box {
    height: 58px;
    min-width: 92px;
    max-width: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 13px;
    padding: 5px 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

.club-logo {
    display: block;
    max-height: 48px;
    max-width: 225px;
    width: auto;
    object-fit: contain;
}

.club-logo-fallback {
    display: none;
    font-weight: 900;
    color: var(--navy);
    letter-spacing: .04em;
    white-space: nowrap;
}

.zone-label {
    text-align: right;
    letter-spacing: .02em;
}

.home-zone-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.home-zone-card {
    text-decoration: none;
    color: inherit;
}

.home-zone-button {
    width: 100%;
    min-height: 132px;
    border-radius: 22px;
    padding: 18px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    text-align: left;
    box-shadow: 0 8px 22px rgba(4,41,58,.12);
}

.home-zone-button.fitness-zone {
    background: linear-gradient(135deg, #269194, #005776);
}

.home-zone-button.free-zone {
    background: linear-gradient(135deg, #04293a, #005776);
}

.home-zone-kicker {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .12em;
    opacity: .82;
    margin-bottom: 6px;
}

.home-zone-title {
    font-size: clamp(21px, 3vw, 30px);
    font-weight: 900;
    line-height: 1.05;
}

/* Interface coach Fitness : couleurs reprises du planning 2026-2027 */
.fitness-course-grid {
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
    gap: 12px;
}

.course-btn.fitness-course {
    min-height: 94px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
    gap: 4px;
    padding: 15px 18px;
    box-shadow: 0 5px 14px rgba(4,41,58,.10);
    border: 1px solid rgba(255,255,255,.32);
}

.course-btn.fitness-course .course-time {
    font-size: 15px;
    font-weight: 800;
    opacity: .86;
}

.course-btn.fitness-course .course-name {
    font-size: clamp(20px, 2.5vw, 27px);
    font-weight: 900;
    letter-spacing: .01em;
}

/* Palette du planning */
.course-gym-douces { background: #7cdad6 !important; color: #ffffff !important; }
.course-yoga       { background: #8e7cc2 !important; color: #ffffff !important; }
.course-pilates    { background: #269194 !important; color: #ffffff !important; }
.course-renfo      { background: #5299de !important; color: #ffffff !important; }
.course-caf        { background: #5299de !important; color: #ffffff !important; }
.course-flow       { background: #e2a8f1 !important; color: #ffffff !important; }
.course-freestyle  { background: #b8336a !important; color: #ffffff !important; }
.course-step       { background: #b8336a !important; color: #ffffff !important; }
.course-bodybarre  { background: #ef444d !important; color: #ffffff !important; }
.course-mobilite   { background: #6f9d87 !important; color: #ffffff !important; }
.course-stretching { background: #4da478 !important; color: #ffffff !important; }
.course-hiit       { background: #fbb137 !important; color: #ffffff !important; }
.course-abdos      { background: #12235c !important; color: #ffffff !important; }

.session-main.course-gym-douces,
.session-main.course-yoga,
.session-main.course-pilates,
.session-main.course-renfo,
.session-main.course-caf,
.session-main.course-flow,
.session-main.course-freestyle,
.session-main.course-step,
.session-main.course-bodybarre,
.session-main.course-mobilite,
.session-main.course-stretching,
.session-main.course-hiit,
.session-main.course-abdos {
    transition: background .2s ease;
}

.app-install-note {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #eef5f7;
    color: var(--navy);
    font-size: 14px;
    line-height: 1.45;
}

@media (max-width: 640px) {
    .topbar {
        min-height: 70px;
        padding: 8px 12px;
    }

    .club-logo-box {
        height: 50px;
        min-width: 78px;
        max-width: 180px;
        padding: 4px 7px;
    }

    .club-logo {
        max-height: 41px;
        max-width: 164px;
    }

    .zone-label {
        font-size: 12px;
        max-width: 48%;
    }

    .home-zone-grid {
        grid-template-columns: 1fr;
    }

    .fitness-course-grid {
        grid-template-columns: 1fr;
    }
}


/* ===== Correctif V1.3.1 ===== */
/* Tous les noms de cours Fitness restent blancs, quelle que soit la couleur du fond. */
.course-btn.fitness-course .course-name,
.session-main .session-course {
    color: #ffffff !important;
}

/* Les horaires restent également blancs pour une cohérence visuelle maximale. */
.course-btn.fitness-course .course-time,
.session-main .session-meta {
    color: #ffffff !important;
}


/* ===== Correctif V1.3.2 ===== */
/* Le logo fourni est blanc : il doit être affiché directement sur la barre bleu nuit. */
.club-logo-box {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
    max-width: 270px !important;
    height: 58px !important;
    justify-content: flex-start !important;
}

.club-logo {
    max-height: 52px !important;
    max-width: 255px !important;
    filter: none !important;
}

.club-logo-fallback {
    color: #ffffff !important;
}

@media (max-width: 640px) {
    .club-logo-box {
        height: 50px !important;
        max-width: 190px !important;
    }

    .club-logo {
        max-height: 44px !important;
        max-width: 180px !important;
    }
}


/* ===== Correctif V1.3.3 : logo PNG local ===== */
.club-logo-box {
    overflow: visible !important;
}

.club-logo {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    max-height: 54px !important;
    max-width: 280px !important;
    object-fit: contain !important;
}

@media (max-width: 640px) {
    .club-logo {
        max-height: 44px !important;
        max-width: 195px !important;
    }
}


/* ===== Recherche manuelle adhérent V1.4 ===== */
.manual-search-button {
    background: #ffffff;
    color: var(--navy);
    border: 2px solid #d9e3e8;
}

.manual-search-card {
    position: relative;
    width: min(680px, 100%);
}

.manual-close {
    position: absolute;
    right: 16px;
    top: 14px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #eef3f5;
    color: var(--navy);
    font-size: 28px;
}

.manual-field-label {
    display: block;
    margin: 12px 0 7px;
    font-weight: 800;
}

.manual-input {
    width: 100%;
    min-height: 60px;
    border: 2px solid #cbd5da;
    border-radius: 16px;
    padding: 12px 16px;
    font: inherit;
    font-size: 20px;
    color: var(--navy);
    background: #fff;
}

.manual-input:focus {
    outline: 3px solid rgba(0,87,118,.18);
    border-color: var(--blue);
}

.manual-error {
    min-height: 24px;
    margin-top: 8px;
    color: var(--danger);
    font-weight: 700;
}

.manual-results {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.manual-member-result {
    width: 100%;
    min-height: 64px;
    border-radius: 16px;
    padding: 12px 15px;
    background: #f4f7f8;
    border: 1px solid #d7e0e4;
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.manual-member-name {
    font-size: 19px;
    font-weight: 900;
}

.manual-member-action {
    color: var(--blue);
    font-size: 14px;
    font-weight: 800;
}

.manual-privacy-note {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}


/* ===== V1.4.1 Diagnostic + performances ===== */
.camera-card.scan-detected .scan-frame {
    border-color: #36d47b !important;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.13), 0 0 0 5px rgba(54,212,123,.18);
}

.camera-card.scan-detected .scan-hint {
    background: rgba(22,131,74,.96);
}

.speed-diagnostics {
    margin-top: 10px;
    border-top: 1px solid #dde5e8;
    padding-top: 8px;
}

.diag-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 7px 11px;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.diag-toggle::before { content: '⚡'; }

.diag-body {
    display: none;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef3f5;
    color: var(--navy);
}

.speed-diagnostics.open .diag-body { display: block; }

.diag-stage {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--blue);
}

.diag-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(4,41,58,.08);
    font-size: 13px;
}

.diag-row:last-child { border-bottom: 0; }
.diag-row span { color: var(--muted); }
.diag-row strong { text-align: right; }
