/* AmbuResa — thème applicatif (surcharge Bootstrap 5.3) */

:root {
    --ar-primary: #0b5c6b;
    --ar-primary-rgb: 11, 92, 107;
    --ar-primary-dark: #08424d;
    --ar-accent: #e8573f;
    --ar-ink: #14232b;
    --ar-muted: #5b6b73;
    --ar-surface: #f4f6f5;
    --ar-border: #dfe5e3;
    --ar-radius: .65rem;

    --bs-primary: var(--ar-primary);
    --bs-primary-rgb: var(--ar-primary-rgb);
    --bs-link-color: var(--ar-primary);
    --bs-link-color-rgb: var(--ar-primary-rgb);
    --bs-link-hover-color: var(--ar-primary-dark);
    --bs-body-color: var(--ar-ink);
    --bs-body-bg: var(--ar-surface);
    --bs-border-color: var(--ar-border);
    --bs-font-sans-serif: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-border-radius: var(--ar-radius);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-feature-settings: "tnum" 1;
}

main { flex: 1; }

/* ------------------------------------------------------------------ Boutons */
.btn-primary {
    --bs-btn-bg: var(--ar-primary);
    --bs-btn-border-color: var(--ar-primary);
    --bs-btn-hover-bg: var(--ar-primary-dark);
    --bs-btn-hover-border-color: var(--ar-primary-dark);
    --bs-btn-active-bg: var(--ar-primary-dark);
    --bs-btn-active-border-color: var(--ar-primary-dark);
    --bs-btn-disabled-bg: var(--ar-primary);
    --bs-btn-disabled-border-color: var(--ar-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--ar-primary);
    --bs-btn-border-color: var(--ar-primary);
    --bs-btn-hover-bg: var(--ar-primary);
    --bs-btn-hover-border-color: var(--ar-primary);
    --bs-btn-active-bg: var(--ar-primary-dark);
}
.btn { font-weight: 500; }

/* ------------------------------------------------------------------ Navigation */
.ar-navbar {
    background: var(--ar-primary-dark);
    border-bottom: 3px solid var(--ar-accent);
}
.ar-navbar .navbar-brand {
    font-weight: 700;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.ar-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #fff;
    display: inline-grid;
    place-items: center;
}
.ar-navbar .nav-link { color: rgba(255, 255, 255, .78); font-weight: 500; }
.ar-navbar .nav-link:hover,
.ar-navbar .nav-link.active { color: #fff; }
.ar-navbar .nav-link.active { box-shadow: inset 0 -2px 0 #fff; }
.ar-navbar .badge { font-size: .7rem; }

.ar-urgence {
    background: #fff4f1;
    color: #8a2b1b;
    border-bottom: 1px solid #f6d3cb;
    font-size: .85rem;
}

/* ------------------------------------------------------------------ Cartes */
.card {
    border-color: var(--ar-border);
    box-shadow: 0 1px 2px rgba(20, 35, 43, .04);
}
.card-header {
    background: #fff;
    font-weight: 600;
}
.ar-section-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ar-muted);
    margin-bottom: .75rem;
}
.ar-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.75rem 0 1.25rem;
}
.ar-page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.ar-page-header .subtitle { color: var(--ar-muted); margin: .2rem 0 0; }

/* ------------------------------------------------------------------ Statuts */
.statut {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}
.statut-en-attente { background: #fff6e0; color: #8a5a00; border-color: #f5dfa6; }
.statut-acceptee   { background: #e7f1fb; color: #1a5594; border-color: #c4dbf2; }
.statut-planifiee  { background: #e5f4f1; color: #0b5c4f; border-color: #bfe3da; }
.statut-en-cours   { background: #ebe7fb; color: #4b329e; border-color: #d3caf3; }
.statut-terminee   { background: #eef1f0; color: #4a5a55; border-color: #dbe2df; }
.statut-refusee    { background: #fdecea; color: #a12a1a; border-color: #f6cbc4; }
.statut-annulee    { background: #f3f3f3; color: #6b6b6b; border-color: #e0e0e0; text-decoration: line-through; }

.ar-kpi {
    border-radius: var(--ar-radius);
    background: #fff;
    border: 1px solid var(--ar-border);
    padding: 1rem 1.15rem;
    height: 100%;
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}
a.ar-kpi:hover { border-color: var(--ar-primary); transform: translateY(-1px); }
.ar-kpi .value { font-size: 2rem; font-weight: 700; line-height: 1; }
.ar-kpi .label { color: var(--ar-muted); font-size: .85rem; margin-top: .35rem; }
.ar-kpi.attention { border-left: 4px solid #e5a100; }

/* ------------------------------------------------------------------ Listes de demandes */
.ar-table { --bs-table-bg: #fff; margin: 0; }
.ar-table th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ar-muted);
    font-weight: 600;
    background: #fafbfb;
    white-space: nowrap;
}
.ar-table td { vertical-align: middle; }
.ar-table tr[data-href] { cursor: pointer; }
.ar-table tr[data-href]:hover td { background: #f6faf9; }
.ar-ref { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85rem; font-weight: 600; }
.ar-time { font-weight: 700; font-size: 1.05rem; }
.ar-trajet { font-size: .88rem; line-height: 1.35; }
.ar-trajet .bi { color: var(--ar-muted); }

.ar-flag {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .1rem .45rem;
    border-radius: .35rem;
    background: #f0f3f2;
    color: var(--ar-ink);
}
.ar-flag.o2 { background: #e3f2fd; color: #0d4f8b; }
.ar-flag.iso { background: #fde8e4; color: #9c2b17; }

/* ------------------------------------------------------------------ Formulaire de demande */
.ar-form-section { margin-bottom: 1.5rem; }
.ar-form-section > .card-header {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.ar-step {
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--ar-primary);
    color: #fff;
    display: inline-grid;
    place-items: center;
    font-size: .85rem;
    font-weight: 700;
}
.ar-type-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.ar-type-choices .form-check { padding: 0; margin: 0; }
.ar-type-choices .form-check-input { position: absolute; opacity: 0; }
.ar-type-choices .form-check-label {
    display: block;
    border: 1.5px solid var(--ar-border);
    border-radius: var(--ar-radius);
    padding: .9rem 1rem;
    background: #fff;
    cursor: pointer;
    height: 100%;
    font-weight: 500;
}
.ar-type-choices .form-check-label .bi { font-size: 1.4rem; display: block; margin-bottom: .25rem; color: var(--ar-primary); }
.ar-type-choices .form-check-input:checked + .form-check-label {
    border-color: var(--ar-primary);
    background: #eef7f6;
    box-shadow: 0 0 0 3px rgba(var(--ar-primary-rgb), .15);
}
.ar-type-choices .form-check-input:focus-visible + .form-check-label { outline: 2px solid var(--ar-primary); outline-offset: 2px; }

.ar-sticky-actions {
    position: sticky;
    bottom: 0;
    background: rgba(244, 246, 245, .94);
    backdrop-filter: blur(4px);
    border-top: 1px solid var(--ar-border);
    padding: .9rem 0;
    margin-top: 1rem;
    z-index: 10;
}

/* ------------------------------------------------------------------ Fiche demande */
.ar-route {
    position: relative;
    padding-left: 1.75rem;
}
.ar-route::before {
    content: "";
    position: absolute;
    left: .55rem;
    top: .6rem;
    bottom: .6rem;
    border-left: 2px dashed var(--ar-border);
}
.ar-route .point { position: relative; margin-bottom: 1rem; }
.ar-route .point:last-child { margin-bottom: 0; }
.ar-route .point::before {
    content: "";
    position: absolute;
    left: -1.53rem;
    top: .3rem;
    width: .85rem;
    height: .85rem;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--ar-primary);
}
.ar-route .point.arrivee::before { background: var(--ar-accent); border-color: var(--ar-accent); }

.ar-dl dt { font-size: .78rem; color: var(--ar-muted); font-weight: 500; }
.ar-dl dd { margin-bottom: .7rem; font-weight: 500; }

.ar-timeline { list-style: none; padding: 0; margin: 0; }
.ar-timeline li {
    position: relative;
    padding: 0 0 1rem 1.5rem;
    border-left: 2px solid var(--ar-border);
    margin-left: .4rem;
}
.ar-timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.ar-timeline li::before {
    content: "";
    position: absolute;
    left: -.45rem;
    top: .2rem;
    width: .8rem;
    height: .8rem;
    border-radius: 50%;
    background: var(--ar-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--ar-primary);
}
.ar-timeline .quand { font-size: .78rem; color: var(--ar-muted); }

.ar-progress {
    display: flex;
    gap: .25rem;
    margin: 1rem 0 .25rem;
}
.ar-progress .etape {
    flex: 1;
    text-align: center;
    font-size: .74rem;
    font-weight: 600;
    color: var(--ar-muted);
}
.ar-progress .etape::before {
    content: "";
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--ar-border);
    margin-bottom: .4rem;
}
.ar-progress .etape.fait { color: var(--ar-primary); }
.ar-progress .etape.fait::before { background: var(--ar-primary); }
.ar-progress .etape.courant::before { background: linear-gradient(90deg, var(--ar-primary) 50%, var(--ar-border) 50%); }

/* ------------------------------------------------------------------ Planning */
.ar-planning { overflow-x: auto; }
.ar-planning-grid { min-width: 900px; }
.ar-planning-row {
    display: grid;
    grid-template-columns: 170px 1fr;
    border-bottom: 1px solid var(--ar-border);
    min-height: 58px;
}
.ar-planning-row .vehicule {
    padding: .55rem .75rem;
    font-weight: 600;
    font-size: .9rem;
    background: #fafbfb;
    border-right: 1px solid var(--ar-border);
}
.ar-planning-row .vehicule small { display: block; color: var(--ar-muted); font-weight: 400; font-size: .75rem; }
.ar-planning-row .piste {
    position: relative;
    background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% / 16 - 1px), #edf1f0 calc(100% / 16 - 1px), #edf1f0 calc(100% / 16));
}
.ar-planning-heures { display: grid; grid-template-columns: 170px 1fr; border-bottom: 1px solid var(--ar-border); }
.ar-planning-heures .graduations { display: grid; grid-template-columns: repeat(16, 1fr); }
.ar-planning-heures .graduations span { font-size: .72rem; color: var(--ar-muted); padding: .35rem 0 .35rem .25rem; }
.ar-bloc {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: .45rem;
    padding: .2rem .45rem;
    font-size: .72rem;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-decoration: none;
    color: var(--ar-ink);
    border: 1px solid;
}
.ar-bloc:hover { z-index: 2; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); }
.ar-bloc strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.ar-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--ar-accent);
    z-index: 3;
}

/* ------------------------------------------------------------------ Accueil */
.ar-hero {
    background: linear-gradient(135deg, var(--ar-primary-dark) 0%, var(--ar-primary) 100%);
    color: #fff;
    padding: 4rem 0 3.5rem;
}
.ar-hero h1 { font-weight: 800; letter-spacing: -.03em; font-size: clamp(1.9rem, 4vw, 2.8rem); }
.ar-hero .lead { color: rgba(255, 255, 255, .85); max-width: 38rem; }
.ar-feature .bi { font-size: 1.6rem; color: var(--ar-primary); }

.ar-auth-card { max-width: 440px; margin: 3rem auto; }

footer.ar-footer { font-size: .82rem; color: var(--ar-muted); border-top: 1px solid var(--ar-border); background: #fff; }

/* ------------------------------------------------------------------ Divers */
.form-label { font-weight: 500; font-size: .92rem; }
.form-text { font-size: .8rem; }
.invalid-feedback { font-size: .82rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ar-muted); }
.empty-state .bi { font-size: 2.4rem; display: block; margin-bottom: .5rem; opacity: .6; }

@media print {
    .ar-navbar, .ar-urgence, footer, .ar-no-print, .btn { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}

/* ------------------------------------------------------------------ Couleurs Bootstrap compilées à aligner sur le thème */
.nav-pills { --bs-nav-pills-link-active-bg: var(--ar-primary); --bs-nav-link-color: var(--ar-primary); --bs-nav-link-hover-color: var(--ar-primary-dark); }
.form-check-input:checked { background-color: var(--ar-primary); border-color: var(--ar-primary); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: rgba(var(--ar-primary-rgb), .6);
    box-shadow: 0 0 0 .2rem rgba(var(--ar-primary-rgb), .18);
}
.pagination { --bs-pagination-color: var(--ar-primary); --bs-pagination-active-bg: var(--ar-primary); --bs-pagination-active-border-color: var(--ar-primary); }
.form-label.required::after, .col-form-label.required::after { content: " *"; color: var(--ar-accent); }
.ar-ref { white-space: nowrap; }

/* Planning : frise plus lisible (défilement horizontal si nécessaire) */
.ar-planning-grid { min-width: 1500px; }
.ar-planning-row, .ar-planning-heures { grid-template-columns: 175px 1fr; }
.ar-planning-row .vehicule { position: sticky; left: 0; z-index: 4; }

@media (max-width: 767.98px) {
    .ar-page-header h1 { font-size: 1.35rem; }
    .ar-table td, .ar-table th { padding: .5rem .45rem; }
}
