/* ============================================================
   Jetons de l'application : valeurs claires par défaut,
   surchargées quand Fluent pose data-theme="dark".
   Les couleurs de marque viennent des jetons Fluent
   (--colorBrandBackground…) générés par ThemeInitializer.
   ============================================================ */
:root {
    --app-page-bg: #fafafa;
    --app-text: #1a1a1a;
    --app-muted: #777;
    --app-line: #d5d5d5;
    --app-surface: #ffffff;
    --app-header-bg: #17181d;
    --app-header-bg2: #22242b;
    --app-green-bg: #e8f5e9;
    --app-green-bg-hover: #c8e6c9;
    --app-green-text: #2e7d32;
    --app-green-border: #4caf50;
    --app-orange-bg: #fff3e0;
    --app-orange-bg-hover: #ffe0b2;
    --app-orange-text: #e65100;
    --app-orange-border: #ff9800;
    --app-overlay: rgba(255, 255, 255, .85);
}

html[data-theme="dark"],
body[data-theme="dark"] {
    --app-page-bg: #141519;
    --app-text: #e8e8e8;
    --app-muted: #9c9ca3;
    --app-line: #3a3b41;
    --app-surface: #1f2026;
    --app-header-bg: #0d0e12;
    --app-header-bg2: #17181d;
    --app-green-bg: #16351c;
    --app-green-bg-hover: #1d4a26;
    --app-green-text: #8bd690;
    --app-green-border: #3d8c43;
    --app-orange-bg: #3a2a12;
    --app-orange-bg-hover: #4d3717;
    --app-orange-text: #ffa94d;
    --app-orange-border: #b96b00;
    --app-overlay: rgba(0, 0, 0, .65);
}

h1:focus {
    outline: none;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 4px;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* Structure du layout */
html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--app-page-bg);
    color: var(--app-text);
}

/* default-fuib.css (Fluent UI) fige body à 100dvh avec overflow hidden, ce qui
   empêche la page de défiler quand le contenu dépasse l'écran. */
html body {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
}

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

/* ============================================================
   Header : bande sombre « racing » commune aux trois marques —
   chevron skewé à la couleur de la marque, logo Tyremasters à
   droite, bascule clair/sombre. Remplace l'ancien bandeau gris.
   ============================================================ */
main > header.header {
    position: relative;
    background: linear-gradient(100deg, var(--app-header-bg) 60%, var(--app-header-bg2) 60%);
    overflow: hidden;
}

main > header.header::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 18%;
    width: 60px;
    background: var(--colorBrandBackground, #CF112D);
    transform: skewX(-20deg);
    opacity: .85;
}

main > header.header::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: calc(18% + 72px);
    width: 14px;
    background: var(--colorBrandBackground, #CF112D);
    transform: skewX(-20deg);
    opacity: .4;
}

.header-inner {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 1rem;
}

main > header h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-left: 4px solid var(--colorBrandBackground, #CF112D);
    padding-left: 12px;
}

/* Les états couvrent les tokens lien de Fluent (a:visited gagnerait sinon) */
main > header h1 > a,
main > header h1 > a:visited,
main > header h1 > a:hover,
main > header h1 > a:active {
    color: #ffffff;
    text-decoration: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Logo Tyremasters sur plaque blanche : identité principale du header */
.header-tm {
    height: 48px;
    background: #ffffff;
    border-radius: 6px;
    padding: 4px 12px;
    box-sizing: border-box;
}

/* Logo cliquable vers le site de la société : pas d'espace de ligne de base sous l'image */
.website-link {
    display: inline-flex;
    line-height: 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .6);
}

.theme-toggle:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Bandeau logo partenaire (.headerd) : reste clair, les logos de marque
   (JPEG sur fond blanc) ne supportent pas un fond sombre. */
.headerd {
    box-sizing: border-box;
}

.content {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
}

/* Formulaires du wizard : champs sur toute la largeur.
   La largeur par défaut (400px) vient de la feuille de style du shadow root :
   on étend l'hôte, puis l'intérieur via les shadow parts exposés (root/control). */
.content fluent-text-input,
.content fluent-text-area,
.content fluent-field {
    width: 100% !important;
    box-sizing: border-box;
}

.content fluent-text-input::part(root),
.content fluent-text-area::part(root) {
    width: 100%;
    box-sizing: border-box;
}

.content fluent-text-input::part(control),
.content fluent-text-area::part(control) {
    width: 100%;
    box-sizing: border-box;
}

/* Conteneur de formulaire pleine largeur (les FluentStack verticaux
   s'ajustent au contenu, ce qui bridait les champs). */
.wizard-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* Rangée d'actions : Annuler / bouton de validation côte à côte,
   grands et sur toute la largeur — comme les btn-lg col-5 du legacy. */
.wizard-actions {
    display: flex;
    gap: 16px;
    margin-top: 1.5rem;
}

.wizard-actions fluent-button {
    flex: 1;
    min-height: 48px;
    font-size: 1.05rem;
}

.wizard-actions fluent-button button {
    width: 100%;
    height: 100%;
    min-height: 48px;
    font-size: 1.05rem;
}

@media screen and (max-width: 500px) {
    .wizard-actions {
        flex-direction: column;
    }
}

/* Fil d'Ariane du wizard : 6 étapes, l'étape courante en couleur de marque */
.wizard-progress {
    margin: 0 0 1.25rem;
}

.wizard-progress ol {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.wizard-progress__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    min-width: 0;
}

/* Trait de liaison entre les pastilles */
.wizard-progress__step + .wizard-progress__step::before {
    content: "";
    position: absolute;
    top: 13px;
    right: calc(50% + 18px);
    left: calc(-50% + 18px);
    height: 2px;
    background: var(--app-line);
}

.wizard-progress__step.done + .wizard-progress__step::before,
.wizard-progress__step.done + .wizard-progress__step.current::before {
    background: var(--colorBrandBackground, #1976D2);
}

.wizard-progress__dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    background: var(--app-surface);
    border: 2px solid var(--app-line);
    color: var(--app-muted);
    box-sizing: border-box;
    z-index: 1;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.wizard-progress__step.done .wizard-progress__dot {
    background: var(--colorBrandBackground, #1976D2);
    border-color: var(--colorBrandBackground, #1976D2);
    color: #fff;
}

.wizard-progress__step.current .wizard-progress__dot {
    border-color: var(--colorBrandBackground, #1976D2);
    color: var(--colorBrandBackground, #1976D2);
}

.wizard-progress__label {
    font-size: .75rem;
    color: var(--app-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.wizard-progress__step.current .wizard-progress__label {
    color: var(--colorBrandBackground, #1976D2);
    font-weight: 600;
}

@media screen and (max-width: 500px) {
    /* Mobile : seules les pastilles + le libellé de l'étape courante */
    .wizard-progress__label {
        display: none;
    }

    .wizard-progress__step.current .wizard-progress__label {
        display: block;
    }
}

/* Voile de confirmation (étape Validation) : patienter sans fermer la page */
.submit-overlay {
    position: fixed;
    inset: 0;
    background: var(--app-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.submit-overlay__box {
    text-align: center;
    padding: 2rem 2.5rem;
    background: var(--app-surface);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
    max-width: 90vw;
}

.submit-overlay__box fluent-progress-ring {
    margin: 0 auto;
}

.submit-overlay__box h3 {
    margin: 1rem 0 .25rem;
}

.submit-overlay__box p {
    margin: 0;
    color: var(--app-muted);
}

/* Bannière de succès (étape Complete) */
.complete-banner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.complete-banner__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-green-bg);
    color: var(--app-green-text);
}

.complete-banner p {
    margin: 0;
    font-size: 1.05rem;
}

.wizard-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.wizard-logo img {
    max-width: 80vw;
    max-height: 250px;
}

/* Étape Choice : cartes de type d'intervention */
.choice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.item-choice {
    flex: 1 1 150px;
    max-width: 220px;
    border: 2px solid transparent;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12);
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
    text-align: center;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.item-choice:hover {
    border-color: var(--colorBrandStroke1, #777);
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, .16);
    transform: translateY(-2px);
}

.item-choice.selected {
    border-color: var(--colorBrandBackground, #1976D2);
}

/* Les visuels pneus sont des JPEG sur fond blanc : plaque blanche permanente
   pour un rendu identique en mode sombre. */
.item-choice img {
    max-width: 100%;
    background: #ffffff;
    border-radius: 4px;
}

.item-choice h3 {
    font-size: 1rem;
    margin: 8px 0 4px;
}

/* Étape TyreChoice : 4 positions autour de la voiture */
.tyre-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
}

.tyre-car img {
    max-height: 130px;
}

html[data-theme="dark"] .tyre-car img,
body[data-theme="dark"] .tyre-car img {
    /* Dessin au trait noir sur fond transparent : inversé en sombre */
    filter: invert(1) opacity(.85);
}

.tyre-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tyre-select label {
    display: block;
    margin-bottom: 4px;
}

.tyre-select select,
.leasing-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--app-line);
    border-radius: 4px;
    background: var(--app-surface);
    color: var(--app-text);
}

.leasing-label {
    display: block;
    margin-bottom: 4px;
}

@media screen and (max-width: 700px) {
    .tyre-grid {
        grid-template-columns: 1fr;
    }

    .tyre-car {
        display: none;
    }
}

/* Étape DateHour : calendrier de disponibilités + créneaux */
.datehour-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.availability-calendar {
    max-width: 360px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calendar-title {
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-dayname {
    text-align: center;
    font-size: .8rem;
    color: var(--app-muted);
}

.calendar-day {
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--app-line);
    cursor: default;
    transition: background-color .15s ease, color .15s ease;
}

/* Clavier : anneau de focus visible sur tous les contrôles custom */
.calendar-day:focus-visible,
.slot-chip:focus-visible,
.item-choice:focus-visible {
    outline: 2px solid var(--colorBrandBackground, #1976D2);
    outline-offset: 2px;
}

/* Jour disponible (5 créneaux libres ou plus) : vert */
.calendar-day.available {
    background: var(--app-green-bg);
    color: var(--app-green-text);
    border-color: var(--app-green-border);
    cursor: pointer;
    font-weight: 600;
}

.calendar-day.available:hover {
    background: var(--app-green-bg-hover);
}

.calendar-day.available.selected {
    background: #4CAF50;
    border-color: #43A047;
    color: white;
}

/* Faible disponibilité (moins de 5 créneaux libres) : orange */
.calendar-day.low {
    background: var(--app-orange-bg);
    color: var(--app-orange-text);
    border-color: var(--app-orange-border);
    cursor: pointer;
    font-weight: 600;
}

.calendar-day.low:hover {
    background: var(--app-orange-bg-hover);
}

.calendar-day.low.selected {
    background: #FF9800;
    border-color: #F57C00;
    color: white;
}

.slot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* Zone scrollable : 40 créneaux de 15 min ne doivent pas pousser la page */
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Créneaux horaires en vert (meilleure affordance que la couleur de marque) */
.slot-chip {
    padding: 6px 12px;
    border: 1px solid var(--app-green-border);
    border-radius: 4px;
    background: var(--app-surface);
    color: var(--app-green-text);
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
    transition: background-color .15s ease, color .15s ease;
}

.slot-chip:hover {
    background: var(--app-green-bg);
}

.slot-chip.selected {
    background: #4CAF50;
    border-color: #43A047;
    color: white;
}

@media screen and (max-width: 700px) {
    .datehour-layout {
        grid-template-columns: 1fr;
    }

    .availability-calendar {
        max-width: 100%;
    }

    /* Sur mobile la liste des heures suit le calendrier : hauteur bornée
       à l'écran et chips élargis pour le tactile */
    .slot-grid {
        max-height: 45vh;
    }

    .slot-chip {
        flex: 1 1 40%;
        min-height: 44px;
    }
}

/* Respect de la préférence utilisateur : pas d'animation imposée */
@media (prefers-reduced-motion: reduce) {
    .item-choice,
    .item-choice:hover,
    .calendar-day,
    .slot-chip,
    .theme-toggle,
    .wizard-progress__dot {
        transition: none;
        transform: none;
    }
}

/* Administration */
.admin-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    flex: 1;
}

.admin-nav {
    border-right: 1px solid var(--app-line);
    padding: 16px 8px;
}

.admin-content {
    max-width: none;
}

.admin-filter {
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-content fluent-data-grid {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

@media screen and (max-width: 700px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-nav {
        border-right: none;
        border-bottom: 1px solid var(--app-line);
    }
}

/* Mobile : header et logo d'accueil adaptés aux petits écrans */
@media screen and (max-width: 700px) {
    .header-inner {
        padding: 8px .75rem;
    }

    main > header h1 {
        font-size: .85rem;
        letter-spacing: .05em;
    }

    .header-tm {
        height: 34px;
        padding: 2px 8px;
    }

    .headerd {
        padding: 6px 1rem !important;
    }

    .headerd > img {
        max-width: 100%;
        max-height: 26px !important;
    }

    .wizard-logo img {
        max-height: 160px;
    }

    .content {
        padding: 1rem 0.75rem;
    }

    .content h1 {
        font-size: 1.4rem;
    }
}
