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

/* =====================================================================
   Design system — noir & rouge, moderne / elegant, mobile-first
   Syne (titres) + Plus Jakarta Sans (texte)
   ===================================================================== */
:root {
    --ink:        #0b0b0d;
    --surface:    #141417;
    --surface-2:  #1b1b20;
    --line:       #272730;
    --line-soft:  #1f1f26;
    --text:       #f5f5f7;
    --text-dim:   #a6a6b0;
    --muted:      #6f6f7a;

    --red:        #ff2d4d;
    --red-dim:    #ff5c73;
    --red-soft:   rgba(255,45,77,.12);
    --red-deep:   #7a0e1f;

    --green:      #34d399;
    --green-soft: rgba(52,211,153,.12);
    --amber:      #fbbf24;
    --amber-soft: rgba(251,191,36,.12);

    --radius:     16px;
    --radius-sm:  10px;
    --shadow:     0 10px 30px -10px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }

/* Filet de securite anti-overflow horizontal (mobile). Volontairement
   pas d'overflow-x sur body : ca casse position:fixed/sticky (header,
   menus) dans plusieurs navigateurs. */
img, canvas, svg, video, table, iframe { max-width: 100%; }
.card, .card-grid, .chart-wrap, .table-wrap, .form-row { min-width: 0; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--ink);
    background-image:
        radial-gradient(circle at 10% -10%, rgba(255,45,77,.10), transparent 40%),
        radial-gradient(circle at 90% 0%, rgba(255,45,77,.06), transparent 35%);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand, .kicker-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

a { color: var(--red-dim); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Topbar --- */
.topbar {
    background: rgba(11,11,13,.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    /* Doit rester au-dessus de .nav-backdrop (z-index 45) : .topbar cree
       son propre contexte d'empilement (position + z-index), et le panneau
       .nav glissant est imbrique dedans. S'il etait sous 45, le menu
       resterait visuellement "sous" le fond noir du backdrop. */
    z-index: 50;
}
.topbar-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-size: 19px;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 9px;
}
.brand-logo { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.nav-user { color: var(--text-dim); font-size: 13px; }
.nav-logout { color: var(--red-dim) !important; font-weight: 600; }

/* --- Menu hamburger : desactive sur mobile (< 840px), on garde seulement
   le menu en bas type app. Reste disponible en version bureau. --- */
@media (max-width: 839px) {
    .nav-toggle-check, .nav-burger, .nav-backdrop, header .nav { display: none !important; }
}

.nav-toggle-check { display: none; }
.nav-burger {
    display: flex; flex-direction: column; justify-content: center; align-items: flex-end;
    gap: 5px; width: 34px; height: 34px; cursor: pointer; margin-left: auto;
}
.nav-burger span { display: block; width: 21px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s ease, opacity .2s ease; }
#nav-toggle:checked ~ header .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav-toggle:checked ~ header .nav-burger span:nth-child(2) { opacity: 0; }
#nav-toggle:checked ~ header .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); z-index: 45; cursor: default; }
#nav-toggle:checked ~ .nav-backdrop { display: block; }

.nav {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 46;
    width: min(78vw, 300px);
    background-color: #141417;
    background-image: linear-gradient(180deg, var(--surface), var(--ink));
    border-left: 1px solid var(--line);
    box-shadow: -20px 0 40px -14px rgba(0,0,0,.6);
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 84px 22px 24px;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.3,.9,.4,1);
    font-size: 15px;
}
#nav-toggle:checked ~ header .nav { transform: translateX(0); }
.nav a { width: 100%; padding: 12px 0; color: var(--text-dim); border-bottom: 1px solid var(--line-soft); font-weight: 600; }
.nav a:hover, .nav a.active { color: var(--text); text-decoration: none; }
.nav .nav-user { order: 10; margin-top: 10px; padding-top: 0; }
.nav .nav-logout { border-bottom: none; }

@media (min-width: 840px) {
    .nav-burger, .nav-backdrop { display: none !important; }
    .nav {
        position: static; width: auto; background: none; border: none; box-shadow: none;
        flex-direction: row; align-items: center; gap: 22px; padding: 0;
        transform: none; transition: none; font-size: 14px;
    }
    .nav a { width: auto; padding: 0; border-bottom: none; }
    .nav .nav-user { order: 0; margin-top: 0; }
}

/* --- Bottom mobile nav (client) : barre flottante, pill actif --- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: center;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
    overflow: visible;
}
.bottom-nav-inner {
    pointer-events: auto;
    display: flex; align-items: center; justify-content: space-between; gap: 0;
    width: 100%; max-width: 420px;
    background: rgba(20,20,24,.92);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 22px;
    padding: 6px 4px;
    box-shadow: 0 16px 40px -12px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.04);
    overflow: visible;
}
.bottom-nav a {
    flex: 1 1 0; min-width: 0; text-align: center; color: var(--muted);
    font-size: 9.5px; font-weight: 600; letter-spacing: 0;
    padding: 7px 1px 6px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    border-radius: 16px;
    transition: color .18s ease, background .18s ease;
    white-space: nowrap;
}
.bottom-nav a .ic { width: 19px; height: 19px; flex-shrink: 0; transition: transform .18s ease; }
@media (max-width: 360px) {
    .bottom-nav a { font-size: 0; }
    .bottom-nav a .ic { width: 21px; height: 21px; }
}
.bottom-nav a:hover { text-decoration: none; color: var(--text-dim); }
.bottom-nav a.active {
    color: var(--red);
    background: linear-gradient(180deg, rgba(255,45,77,.16), rgba(255,45,77,.05));
}
.bottom-nav a.active .ic { transform: translateY(-1px); filter: drop-shadow(0 2px 8px rgba(255,45,77,.45)); }

@media (min-width: 840px) {
    .bottom-nav { display: none; }
}

/* --- Layout --- */
.page {
    max-width: 1140px;
    margin: 0 auto;
    padding: 26px 18px 48px;
}
@media (max-width: 839px) {
    body.has-bottom-nav .page { padding-bottom: 96px; }
}
.page-narrow { max-width: 460px; }

h1 { font-size: 25px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 30px 0 12px; }
h3 { font-size: 15px; margin: 0; }
.kicker {
    font-size: 11px; font-weight: 700; color: var(--red-dim);
    text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px;
}
.subtitle { color: var(--text-dim); margin-bottom: 20px; }

/* --- Cards --- */
.card {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    min-width: 0;
}
.card-grid.cols-2, .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.card-grid.cols-3, .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
    .card-grid.cols-2, .form-row.cols-2,
    .card-grid.cols-3, .form-row.cols-3 { grid-template-columns: 1fr; }
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; inset: 0; width: 3px;
    background: var(--red);
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; margin-top: 4px; }

/* --- Forms --- */
label { display: block; font-weight: 600; font-size: 13px; margin: 16px 0 6px; color: var(--text-dim); }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=time], select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
}
input[type=file] {
    width: 100%; padding: 10px; border: 1px dashed var(--line);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text-dim); font-size: 13px;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
select { appearance: none; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.help-text { font-size: 12px; color: var(--muted); margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin: 0 0 18px; }
legend { font-family: 'Syne', sans-serif; font-weight: 700; padding: 0 6px; color: var(--red-dim); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    border: none;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-decoration: none;
    transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 8px 20px -6px rgba(255,45,77,.55); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn-success { background: var(--green); color: #06201a; }
.btn-whatsapp { background: #25d366; color: #06301c; }
.btn-sm { padding: 8px 14px; font-size: 12.5px; }
.btn-danger { background: var(--red-soft); color: var(--red-dim); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--line); }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
table th {
    background: var(--surface-2); color: var(--text-dim);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
    text-align: left; padding: 12px 14px;
}
table td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
table tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.table-wrap table { border-radius: var(--radius); overflow: hidden; }

/* --- Tableaux "stack" : passent en liste de cartes sous 640px pour eviter
   tout debordement horizontal illisible sur mobile. Marquer la table avec
   class="stack-mobile" et chaque <td> avec data-label="..." --- */
@media (max-width: 640px) {
    .table-wrap { overflow-x: visible; border: none; }
    table.stack-mobile thead { display: none; }
    table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tr, table.stack-mobile td { display: block; width: 100%; }
    table.stack-mobile tr {
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
        margin-bottom: 12px; padding: 4px 14px;
    }
    table.stack-mobile td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        padding: 10px 0; border-bottom: 1px solid var(--line-soft); text-align: right;
    }
    table.stack-mobile td:last-child { border-bottom: none; }
    table.stack-mobile td::before {
        content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .04em; text-align: left; flex-shrink: 0;
    }
    table.stack-mobile td[data-label=""]::before,
    table.stack-mobile td:not([data-label])::before { content: none; }
}

/* --- Badges --- */
.badge {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red-dim); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* --- Session day cards (client dashboard) --- */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.session-card {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.session-card h3 { font-family: 'Syne', sans-serif; font-size: 17px; }
.session-card .muted { color: var(--muted); font-size: 12.5px; }
.session-card .day-tag {
    align-self: flex-start; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--red-dim); background: var(--red-soft);
    padding: 3px 10px; border-radius: 999px;
}

/* --- Exercise tracking rows --- */
.exercise-block {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; margin-bottom: 14px; background: var(--surface);
}
.exercise-block h4 { font-family: 'Syne', sans-serif; margin: 0 0 4px; font-size: 16px; }
.exercise-target { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.sets-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin-bottom: 10px; }
.set-field label { font-size: 11px; color: var(--muted); margin: 0 0 4px; }

.feeling-select { display: flex; gap: 8px; margin: 8px 0; }
.feeling-option { flex: 1; }
.feeling-option input { display: none; }
.feeling-option span {
    display: block; text-align: center; padding: 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); font-size: 13px; font-weight: 600; cursor: pointer;
    color: var(--text-dim); background: var(--surface);
}
.feeling-option input:checked + span.facile { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.feeling-option input:checked + span.normal { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.feeling-option input:checked + span.difficile { background: var(--red-soft); border-color: var(--red); color: var(--red-dim); }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; font-weight: 500; }
.alert-error { background: var(--red-soft); color: var(--red-dim); border: 1px solid rgba(255,45,77,.3); }
.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(52,211,153,.3); }

.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: var(--ink);
    background-image: radial-gradient(circle at 50% 0%, rgba(255,45,77,.18), transparent 45%);
}
.login-card {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--line); border-radius: 22px;
    padding: 36px 30px; width: 100%; max-width: 380px;
    box-shadow: var(--shadow);
}
.login-card h1 { text-align: center; margin-bottom: 4px; font-size: 26px; }
.login-card .login-sub { text-align: center; color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.login-logo-dot { width: 46px; height: 46px; border-radius: 14px; background: var(--red); margin: 0 auto 18px;
    display: flex; align-items: center; justify-content: center; font-family:'Syne',sans-serif; font-weight:800; font-size:20px; color:#fff;
    box-shadow: 0 10px 24px -6px rgba(255,45,77,.6); }
.login-logo-img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; margin: 0 auto 18px; display: block;
    box-shadow: 0 10px 28px -8px rgba(255,45,77,.55); }

.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.chart-wrap canvas { max-height: 260px; }
.chart-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; margin-bottom: 10px; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.tag { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12px; color: var(--text-dim); }

.photo-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.photo-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }

.progress-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.progress-steps .step { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.progress-steps .step.active, .progress-steps .step.done { background: var(--red); }

.timer-badge {
    font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 700;
    color: var(--red-dim); text-align: center; letter-spacing: .02em;
}

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .ic { font-size: 34px; margin-bottom: 10px; }

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .card { padding: 16px; border-radius: 14px; }
    .page { padding: 18px 14px 40px; }
    h1 { font-size: 22px; }
}
