/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--color-accent);
    color: white;
}
.btn-primary:hover { background: var(--color-accent-dark); }

.btn-secondary {
    background: var(--color-primary);
    color: white;
}
.btn-secondary:hover { background: var(--color-primary-light); }

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-border);
}
.btn-outline:hover { background: var(--color-bg); }

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: transparent;
}
.btn-danger:hover { background: var(--color-danger); color: white; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-field {
    margin-bottom: var(--space-4);
}

.form-field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.form-field .hint {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.form-field .error {
    display: block;
    font-size: 0.82rem;
    color: var(--color-danger);
    margin-top: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 53, 87, 0.12);
}

textarea { min-height: 140px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
}

.checkbox-field input { width: auto; margin-top: 3px; }

.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    max-width: 480px;
    margin: 0 auto;
}

.form-card--wide { max-width: 720px; }

/* ---------- Alerts / flash ---------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: 0.92rem;
}

.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-neutral { background: var(--color-bg); color: var(--color-text-muted); }
.badge-accent { background: rgba(255, 122, 48, 0.14); color: var(--color-accent-dark); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }

/* ---------- Cards / listings ---------- */
.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-5);
}

.listing-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
    position: relative;
}

.listing-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.listing-card__photo {
    aspect-ratio: 4 / 3;
    background: var(--color-bg) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.listing-card__body {
    padding: var(--space-4);
}

.listing-card__price {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    margin-bottom: 2px;
}

.listing-card__title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: var(--space-1);
    color: var(--color-text);
}

.listing-card__meta {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.listing-card__fav {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* ---------- Category quick links ---------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}

.category-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    text-align: center;
    font-weight: 600;
    color: var(--color-text);
}

.category-card:hover {
    border-color: var(--color-accent);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.category-card__icon { font-size: 1.8rem; margin-bottom: var(--space-2); }

/* ---------- Hero / search ---------- */
.hero {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: var(--space-7) 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-bottom: var(--space-6);
}

.hero h1 { color: white; font-size: 2.3rem; }
.hero p { color: rgba(255,255,255,0.85); font-size: 1.05rem; }

.search-panel {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-lg);
    color: var(--color-text);
    margin-top: var(--space-5);
}

/* ---------- Filter sidebar ---------- */
.filter-sidebar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.filter-sidebar h3 { font-size: 1rem; margin-bottom: var(--space-3); }

/* ---------- Map ---------- */
.region-map {
    height: 380px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.region-map-leaflet-region { transition: fill 0.15s ease; cursor: pointer; }

/* ---------- Galerie photo (fiche annonce) ---------- */
.gallery__main {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.gallery__main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.55);
    color: white;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery__arrow:hover { background: rgba(15, 23, 42, 0.8); }
.gallery__arrow--prev { left: var(--space-3); }
.gallery__arrow--next { right: var(--space-3); }

.gallery__counter {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 0.78rem;
    padding: 2px 10px;
    border-radius: 999px;
}

.gallery__thumbs {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    overflow-x: auto;
    padding-bottom: 2px;
}

.gallery__thumb {
    flex: 0 0 auto;
    width: 68px;
    height: 68px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    overflow: hidden;
    cursor: pointer;
    background: var(--color-bg);
    opacity: 0.7;
}

.gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery__thumb:hover { opacity: 1; }

.gallery__thumb.active {
    border-color: var(--color-accent);
    opacity: 1;
}

/* ---------- Visionneuse plein écran (lightbox) ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 22, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox.open { display: flex; }

.lightbox__img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.lightbox__close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: white;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox__close:hover { background: rgba(255,255,255,0.22); }

.lightbox__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: white;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox__arrow:hover { background: rgba(255,255,255,0.22); }
.lightbox__arrow--prev { left: var(--space-4); }
.lightbox__arrow--next { right: var(--space-4); }

.lightbox__counter {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    background: rgba(255,255,255,0.12);
    padding: 4px 14px;
    border-radius: 999px;
}

@media (max-width: 600px) {
    .lightbox__arrow { width: 40px; height: 40px; font-size: 1.5rem; }
}

/* ---------- Description repliable (fiche annonce) ---------- */
.description-text {
    position: relative;
    overflow: hidden;
}

.description-text.collapsed {
    max-height: 160px;
}

.description-text.collapsed::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 56px;
    background: linear-gradient(to bottom, rgba(246, 247, 249, 0), var(--color-bg));
    pointer-events: none;
}

.description-toggle-btn {
    display: block;
    background: none;
    border: none;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    margin-top: var(--space-2);
    margin-bottom: var(--space-4);
}

.description-toggle-btn:hover { text-decoration: underline; }

/* ---------- Liste de caractéristiques (fiche annonce) ---------- */
.specs-list { display: flex; flex-direction: column; gap: var(--space-3); }

.specs-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-border);
}

.specs-list li:last-child { border-bottom: none; padding-bottom: 0; }

.specs-list span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.specs-list strong {
    font-size: 0.95rem;
    color: var(--color-text);
}

/* ---------- Étoiles (lecture seule) ---------- */
.rating-stars-readonly {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.rating-stars-readonly .star {
    color: var(--color-border);
    font-size: 1.2rem;
    line-height: 1;
}

.rating-stars-readonly .star.filled { color: #f5b301; }

.rating-stars-readonly .rating-value {
    font-weight: 700;
    margin-left: var(--space-2);
    margin-right: 4px;
}

/* ---------- Widget de notation interactif (CSS only) ---------- */
.star-rating-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    border: none;
    padding: 0;
    margin: 0;
    width: fit-content;
}

.star-rating-input input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.star-rating-input label {
    cursor: pointer;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--color-border);
    padding: 0 2px;
}

.star-rating-input input:checked ~ label,
.star-rating-input input:checked ~ label ~ label,
.star-rating-input label:hover,
.star-rating-input label:hover ~ label {
    color: #f5b301;
}

/* ---------- Signalement (annonce / profil) ---------- */
.report-details summary {
    cursor: pointer;
    color: var(--color-danger);
    font-weight: 600;
    font-size: 0.9rem;
    list-style: none;
}

.report-details summary::-webkit-details-marker { display: none; }
.report-details summary:hover { text-decoration: underline; }

/* ---------- Autocomplétion de ville ---------- */
.city-suggestions {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
}

.city-suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text);
}

.city-suggestion-item:last-child { border-bottom: none; }
.city-suggestion-item:hover { background: var(--color-bg); }

.listing-location-map {
    height: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

/* ---------- Avatar (photo de profil) ---------- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.85rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 2.2rem; }

.avatar-placeholder { text-transform: uppercase; }

.avatar-edit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.avatar-edit__controls { width: 100%; max-width: 260px; }

.seller-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

/* ---------- Téléphone flouté (visiteurs non connectés) ---------- */
.phone-blurred {
    filter: blur(5px);
    user-select: none;
    display: inline-block;
}

.phone-blurred-cta {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ---------- Cloche de notifications ---------- */
.notif-bell-link {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notif-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--color-accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------- Statistiques d'annonce (Mes annonces) ---------- */
.listing-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

/* ---------- Panel Administrateur ---------- */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--space-5);
    align-items: start;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    position: sticky;
    top: 80px;
}

.admin-nav-link {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-weight: 500;
    font-size: 0.9rem;
}

.admin-nav-link:hover {
    background: var(--color-bg);
    text-decoration: none;
}

.admin-content { min-width: 0; }

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.admin-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.admin-stat-card .value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-primary-dark);
}

.admin-stat-card .label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.admin-table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th, .admin-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.admin-table th {
    background: var(--color-bg);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table td.wrap { white-space: normal; max-width: 320px; }

.admin-search {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    max-width: 420px;
}

@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; flex-direction: row; overflow-x: auto; }
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin-top: var(--space-6);
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 0.9rem;
}

.pagination .active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ---------- Photo upload preview ---------- */
.photo-upload {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    text-align: center;
    color: var(--color-text-muted);
}

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.photo-preview-grid img,
.photo-preview-grid .photo-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.photo-thumb-wrap { position: relative; }
.photo-thumb-remove {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
}

.photo-thumb-canvas-wrap { position: relative; }

.plate-blur-canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.plate-blur-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: 4px;
}

.plate-blur-status {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.plate-blur-status.detected {
    color: var(--color-success);
}

.plate-blur-status.warn {
    color: var(--color-warning);
    font-weight: 600;
}

.btn-add-zone {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
}

.btn-add-zone.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

/* ---------- Messaging ---------- */
.conversation-list { display: flex; flex-direction: column; gap: var(--space-2); }

.conversation-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.conversation-item.unread { border-color: var(--color-accent); background: #fff9f4; }

.message-thread {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    max-height: 460px;
    overflow-y: auto;
}

.message-bubble {
    max-width: 70%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.message-bubble.mine {
    align-self: flex-end;
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.message-bubble__image {
    max-width: 220px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    display: block;
}

.message-bubble .meta {
    display: block;
    font-size: 0.72rem;
    opacity: 0.7;
    margin-top: 4px;
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: var(--space-7) var(--space-4);
    color: var(--color-text-muted);
}

.empty-state .icon { font-size: 2.4rem; margin-bottom: var(--space-3); }

@media (max-width: 900px) {
    .form-row { grid-template-columns: 1fr; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
}
