:root {
    --charcoal: #14171a;
    --charcoal-light: #262b31;
    --orange: #e0621c;
    --orange-dark: #b84c12;
    --orange-light: #ff8a4c;
    --paper: #f6f5f2;
    --line: #e3e1db;
    --text: #1c1e21;
    --text-muted: #6b6f76;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(20,23,26,.08);
    --shadow-hover: 0 16px 40px rgba(20,23,26,.14);
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Barlow', -apple-system, Segoe UI, sans-serif;
    color: var(--text);
    background: var(--paper);
    line-height: 1.55;
}

h1, h2, h3, h4 {
    font-family: 'Barlow Condensed', 'Barlow', sans-serif;
    font-weight: 700;
    letter-spacing: .01em;
    margin: 0 0 .5em;
}

a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--charcoal);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 14px rgba(0,0,0,.2);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    flex: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: uppercase;
    white-space: nowrap;
}
.brand-text small { color: #b9bcc2; font-size: .78rem; letter-spacing: .02em; }

.main-nav { display: flex; gap: 26px; flex-wrap: wrap; }
.main-nav a {
    color: #e9e9ea;
    font-weight: 600;
    font-size: .96rem;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover, .main-nav a.active {
    color: #fff;
    border-color: var(--orange);
    text-decoration: none;
}

.btn-call {
    background: var(--orange);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    flex: none;
}
.btn-call:hover { background: var(--orange-dark); text-decoration: none; }

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px;
    width: 42px; height: 42px;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    flex: none;
}

/* ---------- Hero ---------- */
.hero {
    background:
        radial-gradient(circle at 85% 20%, rgba(224,98,28,.25), transparent 45%),
        linear-gradient(135deg, var(--charcoal), var(--charcoal-light));
    color: #fff;
    padding: 76px 0 64px;
}
.hero h1 {
    font-size: clamp(2.1rem, 5vw, 3.4rem);
    color: #fff;
    line-height: 1.08;
}
.hero .lead {
    color: #cfd2d7;
    font-size: 1.18rem;
    max-width: 640px;
    margin: 0 0 22px;
}
.hero .tag { color: var(--orange-light); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .85rem; }

.hero-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

.hero-banner {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 14px 0 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); text-decoration: none; }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn-outline:hover { border-color: #fff; text-decoration: none; }
.btn-dark { background: var(--charcoal); color: #fff; }
.btn-dark:hover { background: #000; text-decoration: none; }
.btn-danger { background: #b3261e; color: #fff; }
.btn-danger:hover { background: #8f1e18; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--orange); text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* ---------- Sections / cards ---------- */
section { padding: 56px 0; }
.section-title { text-align: center; margin-bottom: 8px; font-size: clamp(1.7rem, 3vw, 2.2rem); }
.section-sub { text-align: center; color: var(--text-muted); margin-bottom: 38px; }

.usp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 22px;
}
.usp-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s;
}
.usp-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.usp-card .icon { font-size: 1.7rem; margin-bottom: 10px; display: block; }

.annonces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 24px;
}

.annonce-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s;
}
.annonce-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }

.annonce-card .photo-wrap {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #e9e7e2;
    overflow: hidden;
}
.annonce-card .photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.annonce-card:hover .photo-wrap img { transform: scale(1.04); }
.annonce-card .no-photo {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: .9rem;
}
.badge-vendu {
    position: absolute; top: 10px; left: 10px;
    background: var(--charcoal); color: #fff;
    padding: 4px 10px; border-radius: 4px;
    font-weight: 700; font-size: .75rem; letter-spacing: .04em;
}

.annonce-card .body { padding: 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.annonce-card h3 { font-size: 1.15rem; margin: 0; }
.annonce-card .prix { color: var(--orange-dark); font-weight: 700; font-size: 1.25rem; }
.annonce-card .meta { color: var(--text-muted); font-size: .87rem; }
.annonce-card .desc-preview { color: var(--text-muted); font-size: .87rem; flex: 1; }
.annonce-card .card-footer { margin-top: 10px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

/* ---------- Fiche annonce ---------- */
.annonce-detail { padding: 40px 0 64px; }
.annonce-detail .breadcrumb { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; color: var(--text-muted); font-size: .9rem; margin-bottom: 18px; }
.annonce-detail-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 40px;
}

.gallery-main {
    aspect-ratio: 4/3;
    background: #e9e7e2;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumbs img {
    width: 80px; height: 60px; object-fit: cover;
    border-radius: var(--radius-sm); cursor: pointer; border: 2px solid transparent;
}
.gallery-thumbs img.active { border-color: var(--orange); }

.spec-table { width: 100%; border-collapse: collapse; margin: 18px 0; }
.spec-table td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.spec-table td:first-child { color: var(--text-muted); width: 45%; }

.price-box {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.price-box .prix { font-size: 2.1rem; color: var(--orange-dark); font-weight: 700; }

.description-block { white-space: pre-line; line-height: 1.75; }

/* ---------- Galerie ---------- */
.gallery-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.gallery-wall a, .gallery-wall .gallery-item { display: block; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.gallery-wall img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.gallery-wall a:hover img { transform: scale(1.06); }

/* ---------- Forms ---------- */
.form-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 30px; max-width: 640px; box-shadow: var(--shadow);
}
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=password], textarea, select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .95rem; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
textarea { min-height: 120px; resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: auto; }
.field-hint { color: var(--text-muted); font-size: .82rem; margin-top: 4px; }
.text-danger { color: #b3261e; font-size: .85rem; }
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .92rem; }
.alert-success { background: #e6f4ea; color: #1e6b34; border: 1px solid #b7e0c3; }
.alert-danger { background: #fbe9e7; color: #99281f; border: 1px solid #f2bcb6; }
.alert-info { background: #eef3fb; color: #2a4d8f; border: 1px solid #cdddf6; }

/* ---------- Admin ---------- */
.admin-shell { padding: 32px 0 64px; }
.admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.admin-table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.admin-table th, .admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; vertical-align: middle; }
.admin-table th { background: #f0efeb; font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase; font-size: .78rem; letter-spacing: .05em; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 4px; background: #e9e7e2; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill-vendu { background: var(--charcoal); color: #fff; }
.pill-brouillon { background: #f0efeb; color: var(--text-muted); }
.pill-en-ligne { background: #e6f4ea; color: #1e6b34; }
.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-nav-pills { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-nav-pills a { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: .88rem; font-weight: 600; color: var(--text); }
.admin-nav-pills a.active, .admin-nav-pills a:hover { background: var(--charcoal); color: #fff; border-color: var(--charcoal); text-decoration: none; }

.photo-manager { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.photo-manager .photo-item { position: relative; width: 130px; }
.photo-manager img { width: 130px; height: 98px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.photo-manager .photo-item form { position: absolute; top: 4px; right: 4px; }
.photo-manager .del-btn {
    background: rgba(0,0,0,.65); color: #fff; border: none; border-radius: 4px;
    width: 24px; height: 24px; cursor: pointer; font-size: .8rem; line-height: 1;
}
.photo-item .main-badge {
    position: absolute; bottom: 4px; left: 4px;
    background: var(--orange); color: #fff; font-size: .68rem; padding: 2px 6px; border-radius: 3px;
}

.login-shell { display: flex; justify-content: center; padding: 90px 20px; }

footer.site-footer { background: var(--charcoal); color: #d9dade; padding: 48px 0 20px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 26px; margin-bottom: 26px; }
.footer-grid strong { color: #fff; font-size: 1.05rem; }
.footer-grid p { margin: 4px 0; font-size: .9rem; color: #b9bcc2; }
.footer-bottom {
    border-top: 1px solid #33383f; padding-top: 16px;
    display: flex; justify-content: space-between; font-size: .82rem; color: #8b8f97;
    flex-wrap: wrap; gap: 8px;
}
.footer-bottom a { color: #8b8f97; }
.footer-credit { color: #6f737b; }
.footer-credit a { color: #9a9ea5; font-weight: 600; }

/* ---------- Bouton PDF ---------- */
.btn-pdf { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .annonce-detail-grid { grid-template-columns: 1fr; }
    .header-bar { flex-wrap: wrap; }
}

@media (max-width: 760px) {
    .nav-toggle { display: inline-flex; align-items:center; justify-content:center; }
    .main-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 4px;
        padding-top: 12px;
        border-top: 1px solid rgba(255,255,255,.12);
        margin-top: 12px;
    }
    .main-nav.open { display: flex; }
    .header-bar { align-items: center; }
    .btn-call { font-size: .82rem; padding: 8px 12px; }
    .brand-text strong { font-size: 1.25rem; }
    .brand-mark { width: 40px; height: 40px; font-size: 1.1rem; }
    .hero { padding: 46px 0 40px; }
    section { padding: 40px 0; }
    .form-card { padding: 20px; }
    .admin-topbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .annonces-grid { grid-template-columns: 1fr; }
    .usp-grid { grid-template-columns: 1fr; }
    .gallery-wall { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Impression / PDF ---------- */
@media print {
    .site-header, .site-footer, .no-print { display: none !important; }
    body { background: #fff; }
    .container { max-width: 100%; padding: 0; }
    a[href]::after { content: ""; }
    @page { margin: 12mm; }

    /* Catalogue imprimable de la liste des annonces : 4 vignettes par page (2 colonnes x 2 lignes),
       en occupant bien l'espace de la page. On évite volontairement "display: grid/flex" ici : la
       plupart des navigateurs paginent mal ces mises en page à l'impression. Un flux "inline-block"
       classique est beaucoup plus fiable. */
    .catalogue-impression {
        display: block !important;
        font-size: 0; /* évite les espaces blancs indésirables entre inline-block */
    }
    .catalogue-impression .annonce-card {
        display: inline-block !important;
        vertical-align: top;
        width: 47%;
        margin: 0 1.5% 22px;
        font-size: 1rem; /* on réinitialise la taille de police annulée ci-dessus */
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    /* Saut de page toutes les 4 vignettes, sauf si c'est aussi la toute dernière (sinon ça
       laisse une page blanche en trop à la fin). */
    .catalogue-impression .annonce-card:nth-of-type(4n):not(:last-of-type) {
        break-after: page;
        page-break-after: always;
    }
    .catalogue-impression .photo-wrap {
        aspect-ratio: auto;
        height: 260px;
        background: #f0efeb;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .catalogue-impression .photo-wrap img {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    .catalogue-impression .body { padding: 16px; }
    .catalogue-impression h3 { font-size: 1.15rem; margin: 0; }
    .catalogue-impression .prix { font-size: 1.3rem; }
    .catalogue-impression .meta { font-size: .88rem; }
}
