/* ── Reset & variables ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary:       #1565c0;
    --primary-dark:  #003c8f;
    --primary-light: #e3f2fd;
    --surface:       #ffffff;
    --bg:            #f0f4f8;
    --text:          #1a202c;
    --text-muted:    #6b7280;
    --border:        #e2e8f0;

    --red:           #c62828;
    --red-light:     #ffebee;
    --red-border:    #ef9a9a;
    --orange:        #e65100;
    --orange-light:  #fff3e0;
    --orange-border: #ffcc80;
    --green:         #2e7d32;
    --green-light:   #e8f5e9;

    --shadow:        0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --shadow-md:     0 4px 12px rgba(0,0,0,.10);
    --radius:        10px;
    --radius-sm:     6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 20;
}

.header-logo {
    font-size: 2rem;
    line-height: 1;
}

header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.subtitle {
    font-size: .85rem;
    opacity: .82;
    margin-top: .1rem;
}

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-wrapper {
    background: var(--surface);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10;
}

.search-row {
    display: flex;
    gap: .5rem;
    max-width: 760px;
}

#search-input {
    flex: 1;
    padding: .7rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--bg);
    color: var(--text);
    transition: border-color .2s, background .2s;
}

#search-input:focus {
    border-color: var(--primary);
    background: var(--surface);
}

#search-btn {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .7rem 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
}

#search-btn:hover,
#search-btn:focus-visible {
    background: var(--primary-dark);
    outline: none;
}

/* Google Autocomplete dropdown above the map */
.pac-container {
    z-index: 9999 !important;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-family: inherit;
}

/* ── Map ────────────────────────────────────────────────────────────────────── */
#map {
    width: 100%;
    height: 450px;
    background: #e8eaf0;
}

/* ── Content area ───────────────────────────────────────────────────────────── */
.content {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1.5rem 2rem;
}

/* ── Loading ────────────────────────────────────────────────────────────────── */
.loading-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 2.5rem;
    color: var(--text-muted);
    font-size: .95rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Error banner ───────────────────────────────────────────────────────────── */
.error-banner {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: .75rem;
}

/* ── Results header ─────────────────────────────────────────────────────────── */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--border);
}

.count-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: .85rem;
    padding: .2rem .6rem;
    border-radius: 20px;
}

.results-label {
    font-size: .95rem;
    color: var(--text-muted);
}

/* ── Map legend ─────────────────────────────────────────────────────────────── */
.legend {
    display: flex;
    align-items: center;
    font-size: .8rem;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: .35rem;
    vertical-align: middle;
}

.dot-red    { background: #e53935; }
.dot-orange { background: #fb8c00; }

/* ── Pannes grid ────────────────────────────────────────────────────────────── */
.pannes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.no-results-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
}

/* ── Panne card ─────────────────────────────────────────────────────────────── */
.panne-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}

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

.panne-card.en-cours {
    border-top: 4px solid var(--red);
}

.panne-card.terminee {
    border-top: 4px solid var(--orange);
}

.card-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .78rem;
    font-weight: 700;
    padding: .25rem .6rem;
    border-radius: 20px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.badge-red {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid var(--red-border);
}

.badge-orange {
    background: var(--orange-light);
    color: var(--orange);
    border: 1px solid var(--orange-border);
}

.type-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: .8rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 20px;
    margin-left: auto;
}

.card-body {
    padding: .85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    font-size: .9rem;
}

.card-row .label {
    color: var(--text-muted);
    font-size: .82rem;
    flex-shrink: 0;
}

.card-row .value {
    font-weight: 500;
    text-align: right;
}

.card-row .value em {
    color: var(--red);
    font-style: normal;
    font-weight: 600;
}

/* ── Info window in the map ─────────────────────────────────────────────────── */
.gm-info-window {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: .88rem;
    line-height: 1.6;
    min-width: 170px;
}

.gm-info-window .iw-title {
    font-weight: 700;
    font-size: .9rem;
    margin-bottom: .35rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    header {
        padding: .85rem 1rem;
    }

    .search-wrapper {
        padding: .75rem 1rem;
    }

    .search-row {
        flex-direction: column;
    }

    #map {
        height: 300px;
    }

    .content {
        padding: 0 .75rem 1.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
