/* ==========================================================
   Voiture — feuille de style commune
   ========================================================== */
:root {
    --navy: #0b1729;
    --navy-2: #132239;
    --navy-3: #1c3050;
    --mint: #02c39a;
    --mint-dark: #00a884;
    --mint-soft: rgba(2, 195, 154, .12);
    --amber: #f7a325;
    --red: #ef476f;
    --blue: #3a86ff;
    --texte: #17202e;
    --texte-doux: #5c6b81;
    --texte-clair: #93a1b5;
    --fond: #f4f6fa;
    --blanc: #ffffff;
    --bord: #e3e8f0;
    --radius: 16px;
    --radius-sm: 10px;
    --ombre: 0 2px 8px rgba(11, 23, 41, .06);
    --ombre-haut: 0 12px 32px rgba(11, 23, 41, .12);
    --header-h: 62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--fond);
    color: var(--texte);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }

/* ---------- Layout ---------- */
.page { min-height: 100vh; padding-bottom: 84px; }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 18px; }
.section { padding: 2.4rem 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.section-title p { color: var(--texte-doux); font-size: .9rem; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 90;
    background: var(--navy);
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: var(--ombre);
}
.topbar-inner {
    display: flex; align-items: center; gap: 1rem;
    height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1.15rem; }
.brand svg { flex: 0 0 auto; }
.brand small { display: block; font-weight: 500; font-size: .68rem; color: var(--mint); letter-spacing: .06em; text-transform: uppercase; }
.topnav { display: none; gap: 1.4rem; margin-left: auto; }
.topnav a { color: #b8c4d6; font-size: .9rem; font-weight: 500; transition: color .18s; }
.topnav a:hover, .topnav a.active { color: var(--mint); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .72rem 1.25rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
    transition: transform .15s, box-shadow .18s, background .18s, color .18s;
    white-space: nowrap; border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--mint); color: #05221b; }
.btn-primary:hover { background: var(--mint-dark); box-shadow: 0 6px 18px rgba(2, 195, 154, .32); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-3); }
.btn-ghost { background: transparent; color: #dfe7f2; border-color: rgba(255,255,255,.28); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--bord); }
.btn-outline:hover { border-color: var(--navy); }
.btn-danger { background: #fdeaee; color: #c22246; }
.btn-danger:hover { background: #f9d3dc; }
.btn-sm { padding: .5rem .9rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- Hero (accueil public) ---------- */
.hero {
    position: relative; color: #fff; overflow: hidden;
    background: linear-gradient(120deg, rgba(11,23,41,.92), rgba(11,23,41,.62)),
                url('https://images.unsplash.com/photo-1449965408869-eaa3f722e40d?w=1600') center/cover no-repeat;
    padding: 3.4rem 0 3rem;
}
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); margin-bottom: .8rem; }
.hero p.lead { color: #cfd9e8; max-width: 620px; margin-bottom: 1.8rem; font-size: 1.02rem; }
.hero .badge-live {
    display: inline-flex; align-items: center; gap: .45rem; background: var(--mint-soft);
    border: 1px solid rgba(2,195,154,.35); color: var(--mint); padding: .35rem .85rem;
    border-radius: 999px; font-size: .78rem; font-weight: 700; margin-bottom: 1.1rem; letter-spacing: .04em;
}
.hero-stats { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 2.2rem; }
.hero-stat { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: var(--radius-sm); padding: 1rem 1.15rem; }
.hero-stat strong { display: block; font-size: 1.6rem; color: var(--mint); }
.hero-stat span { font-size: .82rem; color: #c3cfe0; }

/* ---------- Recherche ---------- */
.search-panel {
    background: #fff; border-radius: var(--radius); box-shadow: var(--ombre-haut);
    padding: 1.2rem; margin-top: -2.2rem; position: relative; z-index: 10;
}
.search-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .78rem; font-weight: 600; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
    padding: .7rem .85rem; border: 1px solid var(--bord); border-radius: var(--radius-sm);
    background: #fbfcfe; transition: border-color .18s, box-shadow .18s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); background: #fff;
}
.field textarea { min-height: 90px; resize: vertical; }

/* ---------- Grille voitures ---------- */
.cars-grid { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
.car-card {
    background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--ombre);
    display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s;
    border: 1px solid var(--bord);
}
.car-card:hover { transform: translateY(-4px); box-shadow: var(--ombre-haut); }
.car-media { position: relative; aspect-ratio: 16/10; background: var(--navy-2); overflow: hidden; }
.car-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.car-card:hover .car-media img { transform: scale(1.06); }
.car-media .tag {
    position: absolute; top: .7rem; left: .7rem; background: rgba(11,23,41,.85); color: #fff;
    font-size: .72rem; font-weight: 700; padding: .28rem .7rem; border-radius: 999px; backdrop-filter: blur(6px);
}
.car-price {
    position: absolute; bottom: .7rem; right: .7rem; background: var(--mint); color: #05221b;
    font-weight: 800; padding: .32rem .75rem; border-radius: 999px; font-size: .85rem;
}
.car-body { padding: 1.05rem 1.15rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; flex: 1; }
.car-body h3 { font-size: 1.08rem; }
.car-body .sub { color: var(--texte-doux); font-size: .84rem; }
.car-specs { display: flex; flex-wrap: wrap; gap: .45rem; }
.spec {
    display: inline-flex; align-items: center; gap: .3rem; background: var(--fond); border: 1px solid var(--bord);
    padding: .25rem .6rem; border-radius: 999px; font-size: .74rem; color: var(--texte-doux); font-weight: 600;
}
.car-body .btn { margin-top: auto; }

/* ---------- Statuts ---------- */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .24rem .68rem; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-disponible, .pill-confirmee, .pill-actif, .pill-terminee { background: #e3f9f2; color: #058a6c; }
.pill-en_attente { background: #fef3e0; color: #a86b06; }
.pill-louee { background: #e8f0ff; color: #1f5fd0; }
.pill-maintenance, .pill-annulee, .pill-suspendu { background: #fdeaee; color: #c22246; }

/* ---------- Cards génériques / tableau ---------- */
.card { background: #fff; border: 1px solid var(--bord); border-radius: var(--radius); box-shadow: var(--ombre); }
.card-head { padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--bord); display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.card-body { padding: 1.2rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-clair); padding: .8rem 1rem; border-bottom: 1px solid var(--bord); font-weight: 700; white-space: nowrap; }
td { padding: .85rem 1rem; border-bottom: 1px solid var(--bord); font-size: .88rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: .78rem; color: var(--texte-doux); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.icon-btn { display: inline-flex; align-items: center; gap: .3rem; padding: .4rem .7rem; border-radius: 8px; background: var(--fond); font-size: .78rem; font-weight: 600; color: var(--texte-doux); border: 1px solid var(--bord); }
.icon-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.icon-btn.danger:hover { background: #c22246; border-color: #c22246; }

/* ---------- Stats ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; }
.kpi { background: #fff; border: 1px solid var(--bord); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--ombre); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.kpi .kpi-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--mint-soft); color: var(--mint-dark); }
.kpi strong { display: block; font-size: 1.55rem; font-weight: 800; }
.kpi span.kpi-label { font-size: .78rem; color: var(--texte-doux); }
.kpi .kpi-trend { font-size: .74rem; font-weight: 700; }

/* ---------- Formulaires / auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-side { display: none; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 2rem 1.2rem 6rem; }
.auth-card { width: 100%; max-width: 430px; background: #fff; border: 1px solid var(--bord); border-radius: var(--radius); box-shadow: var(--ombre-haut); padding: 1.8rem; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: .35rem; }
.auth-card .sub { color: var(--texte-doux); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: .95rem; }
.form-row { display: grid; grid-template-columns: 1fr; gap: .95rem; }
.auth-switch { text-align: center; margin-top: 1.2rem; font-size: .88rem; color: var(--texte-doux); }
.auth-switch a { color: var(--mint-dark); font-weight: 700; }

/* ---------- Alertes ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .86rem; margin-bottom: .9rem; border: 1px solid transparent; }
.alert-error { background: #fdeaee; color: #a51b3d; border-color: #f7ccd6; }
.alert-success { background: #e3f9f2; color: #058a6c; border-color: #b8ecdc; }
.alert-info { background: #eef4ff; color: #1f5fd0; border-color: #d5e3ff; }

/* ---------- Fiche voiture ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 1.4rem; }
.detail-hero img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); }
.detail-specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin: 1.2rem 0; }
.detail-spec { background: #fff; border: 1px solid var(--bord); border-radius: var(--radius-sm); padding: .8rem; }
.detail-spec span { font-size: .74rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .04em; }
.detail-spec strong { display: block; font-size: .96rem; }
.booking-box { background: #fff; border: 1px solid var(--bord); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--ombre); position: sticky; top: calc(var(--header-h) + 14px); }
.booking-box .price-line { display: flex; align-items: baseline; gap: .4rem; margin-bottom: 1rem; }
.booking-box .price-line strong { font-size: 1.7rem; color: var(--navy); }
.booking-box .price-line span { color: var(--texte-doux); font-size: .85rem; }
.recap { background: var(--fond); border-radius: var(--radius-sm); padding: .8rem 1rem; font-size: .86rem; margin-bottom: .9rem; }
.recap div { display: flex; justify-content: space-between; padding: .22rem 0; }
.recap div.total { border-top: 1px dashed var(--bord); margin-top: .4rem; padding-top: .5rem; font-weight: 800; }

/* ---------- Filtres ---------- */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; -webkit-overflow-scrolling: touch; }
.chip { padding: .42rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--bord); font-size: .82rem; font-weight: 600; color: var(--texte-doux); white-space: nowrap; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Nav basse (application + admin) ---------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
    border-top: 1px solid var(--bord);
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .18rem;
    padding: .55rem .15rem .5rem; font-size: .64rem; font-weight: 600; color: var(--texte-clair);
    transition: color .18s; position: relative; text-align: center; line-height: 1.15;
}
.bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--mint-dark); }
.bottom-nav a.active::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--mint); }

/* ---------- Modale ---------- */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(11,23,41,.6); display: flex; align-items: flex-end; justify-content: center; padding: 0; backdrop-filter: blur(3px); }
.modal-box { background: #fff; border-radius: var(--radius) var(--radius) 0 0; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; padding: 1.4rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom, 0px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.modal-head h3 { font-size: 1.15rem; }
.modal-close { width: 34px; height: 34px; border-radius: 50%; background: var(--fond); display: grid; place-items: center; color: var(--texte-doux); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: .85rem; }

/* ---------- Footer ---------- */
.footer { background: var(--navy); color: #a9b7cb; padding: 2.4rem 0 2rem; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 1.6rem; }
.footer h4 { color: #fff; font-size: .95rem; margin-bottom: .7rem; }
.footer a { font-size: .88rem; display: block; padding: .2rem 0; }
.footer a:hover { color: var(--mint); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 1.8rem; padding-top: 1.2rem; font-size: .8rem; text-align: center; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 2.6rem 1rem; color: var(--texte-doux); }
.empty svg { margin: 0 auto 1rem; color: var(--texte-clair); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--bord); border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-wrap { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: .5rem; width: calc(100% - 24px); max-width: 420px; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .86rem; box-shadow: var(--ombre-haut); animation: toastIn .25s ease; }
.toast.success { background: var(--mint-dark); color: #fff; }
.toast.error { background: #c22246; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: none; }
.muted { color: var(--texte-doux); }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.6rem; }
.mb-2 { margin-bottom: 1rem; }
.tc { text-align: center; }
.hero-cta { display: flex; gap: .7rem; flex-wrap: wrap; }

/* ---------- Barre d'installation PWA ---------- */
.install-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 110; width: calc(100% - 24px); max-width: 420px; }
.install-bar .btn { width: 100%; background: var(--navy); color: #fff; box-shadow: var(--ombre-haut); }
.install-bar .btn:hover { background: var(--navy-3); }

/* ---------- Réglages admin ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
.domain-box { background: linear-gradient(135deg, var(--navy), var(--navy-3)); color: #fff; border-radius: var(--radius); padding: 1.4rem; }
.domain-box h3 { color: #fff; margin-bottom: .5rem; }
.domain-box p { color: #c3cfe0; font-size: .88rem; margin-bottom: 1rem; }
.domain-box .btn { background: var(--mint); color: #05221a; }

/* ==========================================================
   RESPONSIVE — mobile first, on ouvre les colonnes >= 768px
   ========================================================== */
@media (min-width: 641px) {
    .search-grid { grid-template-columns: repeat(4, 1fr); }
    .form-row { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .full { grid-column: 1 / -1; }
    .detail-specs { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
    body { font-size: 16px; }
    .topnav { display: flex; }
    .topbar-actions { margin-left: 0; }
    .cars-grid { grid-template-columns: repeat(2, 1fr); }
    .hero { padding: 5rem 0 4rem; }
    .hero-stats { grid-template-columns: repeat(3, 1fr); }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
    .detail-grid { grid-template-columns: 1.6fr 1fr; }
    .settings-grid { grid-template-columns: 1fr 1fr; }
    .modal { align-items: center; padding: 1.5rem; }
    .modal-box { border-radius: var(--radius); }
    .bottom-nav { display: none; }
    .page { padding-bottom: 0; }
    .install-bar { display: none; }
}

@media (min-width: 1024px) {
    .cars-grid { grid-template-columns: repeat(3, 1fr); }
    .auth-wrap { grid-template-columns: 1.1fr 1fr; }
    .auth-side {
        display: flex; flex-direction: column; justify-content: center; gap: 1.4rem; color: #fff;
        padding: 3rem;
        background: linear-gradient(150deg, rgba(11,23,41,.94), rgba(2,195,154,.35)),
                    url('https://images.unsplash.com/photo-1503376780353-7e6692767b70?w=1200') center/cover no-repeat;
    }
    .auth-side h2 { font-size: 2rem; }
    .auth-side p { color: #d6e0ee; max-width: 420px; }
    .auth-form-side { padding: 2rem; }
}

@media (max-width: 767px) {
    h1 { font-size: 1.55rem; }
    .card-body { padding: 1rem; }
    .kpi strong { font-size: 1.35rem; }
    /* L'en-tete reste sur une seule ligne : on n'affiche que l'essentiel. */
    .topbar .brand { font-size: 1.02rem; gap: .45rem; }
    .topbar .brand small { display: none; }
    .topbar-actions { gap: .35rem; }
    .topbar-actions .btn-register { display: none; }
    .topbar-actions .btn { padding: .45rem .75rem; font-size: .78rem; }
}

@media (max-width: 420px) {
    .topbar .brand svg { width: 26px; height: 26px; }
    .bottom-nav a { font-size: .6rem; }
    .bottom-nav a svg { width: 20px; height: 20px; }
}
