/* MDA — interface concue pour le telephone d'abord.
   La couleur --store est injectee par magasin, le reste ne bouge pas. */

:root {
    /* Couleurs officielles MDA, relevées sur mda-electromenager.com. */
    --brand-red: #e30613;
    --brand-yellow: #fde513;
    --brand-ink: #020203;

    /* Le corps reste sombre : c'est ce qui fait ressortir le jaune et le rouge,
       et ce qui fatigue le moins en réserve ou en magasin peu éclairé. */
    --bg: #101013;
    --surface: #1a1a1f;
    --surface-2: #23232a;
    --border: #33333d;
    --text: #f5f5f7;
    --muted: #9a9aa5;
    --danger: #ff5f56;
    --success: #35c46b;
    --radius: 14px;

    /* Accent du magasin : rouge MDA par défaut, modifiable magasin par magasin. */
    --store: var(--brand-red);

    /* Encoche et barre gestuelle : sans ces marges, le contenu passe dessous. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

/* Les elements masques le restent, meme quand une regle leur donne un display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    /* Empeche le rebond elastique iOS qui laisse voir le fond du navigateur. */
    overscroll-behavior-y: none;
}

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.app__main {
    flex: 1;
    padding: 16px 16px 96px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

.body--centered .app__main { display: flex; align-items: center; justify-content: center; padding-bottom: 32px; }

/* --- Barre haute ------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(var(--safe-top) + 12px) 16px 12px;
    /* Noir sous l'encoche, jaune MDA en dessous : le texte blanc de la barre d'état
       reste lisible, et l'en-tête porte la couleur de l'enseigne. */
    background: linear-gradient(
        180deg,
        var(--brand-ink) 0,
        var(--brand-ink) var(--safe-top),
        var(--brand-yellow) var(--safe-top)
    );
    color: var(--brand-ink);
    border-bottom: 3px solid var(--brand-red);
}

.topbar__store { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__badge {
    width: 40px; height: 40px;
    border-radius: 11px;
    flex: none;
    object-fit: cover;
}
.topbar__name { margin: 0; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Sur le jaune, le gris clair ne passe pas : on descend vers le noir de la charte. */
.topbar__user { margin: 0; color: #6b5f00; font-size: 13px; }
.topbar .btn--ghost { border-color: rgba(2, 2, 3, .3); color: var(--brand-ink); }
.topbar .btn--ghost:active { background: rgba(2, 2, 3, .08); }

.switcher { position: relative; }
.switcher summary { list-style: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--brand-ink); padding: 8px; }
.switcher summary::-webkit-details-marker { display: none; }
.switcher ul {
    position: absolute; right: 0; top: 100%;
    margin: 4px 0 0; padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    list-style: none;
    min-width: 200px;
    z-index: 10;
}
.switcher a { display: block; padding: 10px 12px; color: var(--text); text-decoration: none; border-radius: 10px; }
.switcher a:active { background: var(--surface); }

/* --- Sections et tuiles ------------------------------------------------ */

.section { margin: 24px 0; }
.section__title {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    /* Un filet jaune rappelle l'enseigne sans alourdir la page. */
    border-left: 3px solid var(--brand-yellow);
    padding-left: 8px;
}

.cards { display: grid; gap: 12px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    color: var(--text);
    text-decoration: none;
    /* Cible tactile confortable, meme avec des gants en hiver. */
    min-height: 60px;
}
.card__head:active { background: var(--surface-2); }

.card__icon {
    display: grid; place-items: center;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--surface-2);
    /* Un liseré jaune plutôt qu'un fond teinté : le mélange avec le fond sombre virait au kaki. */
    border: 1px solid color-mix(in srgb, var(--brand-yellow) 28%, transparent);
    font-size: 22px;
    flex: none;
}
.card__icon img { width: 32px; height: 32px; object-fit: contain; }
.card__text { display: flex; flex-direction: column; min-width: 0; }
.card__text strong { font-weight: 600; }
.card__text small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__go { margin-left: auto; color: var(--muted); font-size: 18px; }

/* Les comptes se déplient sous la vignette : le hub reste lisible d'un coup d'oeil. */
.card__accounts summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}
.card__accounts summary::-webkit-details-marker { display: none; }
.card__accounts summary::before { content: '▸'; font-size: 11px; }
.card__accounts[open] summary::before { content: '▾'; }
.card__accounts[open] summary { color: var(--text); }

/* --- Comptes ----------------------------------------------------------- */

.account { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.card__accounts .account:first-of-type { border-top: 0; }
.account__label { margin: 0; font-size: 13px; color: var(--muted); }
.account__note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.account__row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.account__field {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    /* Selection possible au doigt : certains preferent copier a la main. */
    user-select: all;
}
.account__field--secret {
    letter-spacing: .12em;
    /* Un mot de passe doit se lire en entier : on le laisse passer a la ligne. */
    white-space: normal;
    overflow-wrap: anywhere;
}
.account__open { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* --- Boutons ----------------------------------------------------------- */

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-2);
    cursor: pointer;
    min-height: 40px;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
    /* Supprime le surlignage bleu au tap sur iOS. */
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--brand-red); color: #ffffff; }
.btn--yellow { background: var(--brand-yellow); color: var(--brand-ink); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn--block { width: 100%; margin-top: 10px; }
.btn--bio { width: 100%; background: var(--surface-2); border-color: var(--border); margin-bottom: 14px; }

/* --- Barre de verrouillage --------------------------------------------- */

.lockbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--success) 18%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
    font-size: 14px;
}
.lockbar__action { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }

/* --- Feuille de deverrouillage ----------------------------------------- */

.sheet {
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    color: var(--text);
    padding: 20px 20px calc(20px + var(--safe-bottom));
    width: 100%;
    max-width: 520px;
    margin: auto auto 0;
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet__close { position: absolute; top: 10px; right: 10px; }
.sheet__close button { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.sheet__title { margin: 0 0 6px; font-size: 20px; }
.sheet__hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.sheet__error { margin: 12px 0 0; color: var(--danger); font-size: 14px; }

.pin {
    width: 100%;
    padding: 14px;
    font-size: 24px;
    letter-spacing: .4em;
    text-align: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

/* --- Formulaires ------------------------------------------------------- */

.stack { display: grid; gap: 12px; margin-top: 12px; }
.field { display: grid; gap: 6px; font-size: 14px; }
.field span { color: var(--muted); }
.field input, .field select, .field textarea {
    padding: 12px;
    /* 16px minimum : en dessous, iOS zoome automatiquement sur le champ. */
    font-size: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    width: 100%;
}
.field small { color: var(--muted); font-size: 12px; }

/* Formulaires generes par Symfony (back-office) : meme allure que les champs ecrits a la main. */
.stack > div { display: grid; gap: 6px; }
.stack > div > label { color: var(--muted); font-size: 14px; }
.stack input[type="text"], .stack input[type="email"], .stack input[type="password"],
.stack input[type="url"], .stack input[type="number"], .stack input[type="color"],
.stack select, .stack textarea {
    padding: 12px;
    font-size: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    width: 100%;
}
.stack input[type="color"] { padding: 4px; height: 46px; }
.stack .help-text, .stack .form-help { color: var(--muted); font-size: 12px; margin: 0; }
.stack ul { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: 13px; }
/* Cases a cocher : la case garde sa taille, seul le libelle passe a cote. */
.stack input[type="checkbox"], .stack input[type="radio"] { width: auto; margin-right: 8px; }
.stack > div > div { display: grid; gap: 6px; }
.stack fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stack legend { color: var(--muted); font-size: 13px; padding: 0 6px; }

.table small { display: block; color: var(--muted); font-size: 12px; }

.login { width: 100%; max-width: 380px; display: grid; gap: 14px; text-align: center; }
.login__badge { justify-self: center; width: 84px; height: 84px; border-radius: 20px; object-fit: cover; }
.login__title { margin: 0; font-size: 22px; }
.login__subtitle { margin: -8px 0 8px; color: var(--muted); font-size: 14px; }
.login .field { text-align: left; }
.login__note { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --- Divers ------------------------------------------------------------ */

.flash { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 0 0 12px; }
.flash--success { background: color-mix(in srgb, var(--success) 20%, var(--surface)); }
.flash--error { background: color-mix(in srgb, var(--danger) 20%, var(--surface)); }

.lead { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; }
.glyph { font-size: 16px; }
.steps { padding-left: 20px; display: grid; gap: 8px; }
.steps li { padding-left: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.badge-installed { background: color-mix(in srgb, var(--success) 20%, var(--surface)); padding: 12px; border-radius: 12px; }

.preview { display: flex; align-items: center; gap: 14px; }
.preview__icon { border-radius: 18px; }
.preview__name { margin: 0; font-weight: 600; }

.list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.list__item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.list__item small { display: block; color: var(--muted); font-size: 12px; }

/* Sur fond sombre, le rouge pur manque de contraste : on l'éclaircit pour les liens. */
a { color: color-mix(in srgb, var(--brand-red) 45%, #ffffff); }

/* --- Équipe et abonnement ---------------------------------------------- */

.seatbar {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.seatbar strong { display: block; }
.seatbar small { color: var(--muted); font-size: 13px; }

/* Prénom et nom côte à côte : deux champs courts n'ont pas besoin de toute la largeur. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.checkline { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--muted); }
.checkline input { margin-top: 3px; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input[type="month"], .inline-form input[type="text"] {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.overdue { color: var(--danger) !important; }

/* Enregistrement DNS : lisible et copiable tel quel, sans risque de confusion. */
.dns-record {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 10px;
}
.dns-record > div { display: flex; align-items: baseline; gap: 12px; }
.dns-record span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; min-width: 62px; }
.dns-record strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; overflow-wrap: anywhere; user-select: all; }

/* --- Barre d'onglets --------------------------------------------------- */

.tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    z-index: 20;
}
.tabbar__item {
    flex: 1;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 10px 4px;
    font-size: 11px;
    color: var(--muted);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.tabbar__item.is-active { color: var(--brand-yellow); }
.tabbar__item.is-active .tabbar__icon { color: var(--brand-yellow); }
.tabbar__icon { font-size: 18px; }

/* --- Back-office ------------------------------------------------------- */

.admin-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat strong { display: block; font-size: 24px; }
.stat small { color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.table-wrap { overflow-x: auto; }

.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.warn { border-left: 3px solid var(--danger); padding-left: 12px; color: var(--muted); font-size: 13px; }

@media (min-width: 700px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .btn:active { transform: none; }
}
