/* ============================================================
   Pharmacies de garde — Côte d'Ivoire
   Design system moderne · mobile-first · light/dark · offline
   ============================================================ */

:root {
    --brand: #5b53d6;
    --brand-2: #7a6cf0;
    --brand-grad: linear-gradient(135deg, #5b53d6 0%, #7a6cf0 100%);
    --ink: #16182d;
    --ink-soft: #4a4d6a;
    --ink-faint: #888aa5;
    --paper: #f4f5fb;
    --card: #ffffff;
    --line: #e4e6f2;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --red: #dc2626;
    --amber: #d97706;
    --amber-soft: #fff3cd;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 30px rgba(22, 24, 45, 0.08);
    --shadow-lg: 0 16px 50px rgba(22, 24, 45, 0.14);
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand: #8b85f5;
        --brand-2: #a79ff8;
        --ink: #eef0fa;
        --ink-soft: #b6b8d0;
        --ink-faint: #82849e;
        --paper: #0c0f1c;
        --card: #161a2c;
        --line: #262b42;
        --green-soft: #0d2b1a;
        --amber-soft: #2b230c;
        --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.55);
    }
}

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

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

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

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--brand); color: #fff;
    padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; z-index: 999;
}
.skip-link:focus { left: 0; }

/* ---------- Coquille ---------- */
.app { max-width: 640px; margin: 0 auto; padding-bottom: 96px; }

/* ---------- En-tête ---------- */
.app-header {
    background: var(--brand-grad);
    color: #fff;
    padding: 26px 20px 22px;
    border-radius: 0 0 24px 24px;
    box-shadow: var(--shadow-lg);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
    display: grid; place-items: center;
    width: 52px; height: 52px; flex: none;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 16px;
}

.brand-text h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text p { font-size: 12.5px; opacity: 0.85; }

.header-chips {
    list-style: none;
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 16px;
}
.header-chips li {
    font-size: 11.5px; font-weight: 600;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 5px 11px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- Panneaux ---------- */
main { padding: 16px 16px 0; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    margin-bottom: 14px;
}

.panel-head { margin-bottom: 12px; }

.panel-title { display: flex; align-items: center; gap: 10px; }

.panel-title h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }

.step-badge {
    display: grid; place-items: center;
    width: 24px; height: 24px; flex: none;
    background: var(--brand-grad);
    color: #fff; font-size: 12.5px; font-weight: 700;
    border-radius: 8px;
}

.panel-hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: 14px;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    width: 100%;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 18px rgba(91, 83, 214, 0.35); }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-soft { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-primary:hover, .btn-ghost:hover { box-shadow: 0 8px 22px rgba(91, 83, 214, 0.3); }

.btn-icon { font-style: normal; }

.location-actions { display: grid; gap: 8px; }

/* ---------- Coordonnées manuelles ---------- */
.coords-details { margin-top: 12px; }
.coords-details summary {
    font-size: 13px; font-weight: 600; color: var(--brand);
    cursor: pointer; list-style: none;
}
.coords-details summary::before { content: '▸ '; }
.coords-details[open] summary::before { content: '▾ '; }

.manual-input-wrapper { display: flex; gap: 8px; margin-top: 10px; }
#manual-coords {
    flex: 1; font: inherit; font-size: 13.5px;
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink);
}
.btn-apply { width: auto; padding: 10px 16px; }

.location-status {
    margin-top: 10px; font-size: 12.5px; color: var(--ink-faint);
    text-align: center; font-style: italic;
}
.location-status.searching { color: var(--brand); animation: pulse 1.5s infinite; }
.location-status.success { color: var(--green); font-style: normal; font-weight: 600; }
.location-status.error { color: var(--red); font-style: normal; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- Champs / autocomplétion ---------- */
.field { margin-top: 6px; }

.section-label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--ink-soft); font-size: 13.5px; }

.autocomplete-wrapper { position: relative; }
.field-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--ink-faint); pointer-events: none;
    display: inline-flex;
}
#assurance-input {
    width: 100%; font: inherit; font-size: 14.5px;
    padding: 12px 14px 12px 40px;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#assurance-input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(91, 83, 214, 0.18);
}

.suggestions-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 220px; overflow-y: auto; z-index: 100;
    display: none;
}
.suggestions-dropdown.active { display: block; }

.suggestion-item {
    padding: 11px 13px; cursor: pointer;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    transition: background 0.15s;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item[aria-selected="true"] { background: var(--paper); }
.suggestion-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.suggestion-count {
    font-size: 11px; font-weight: 700; color: var(--brand);
    background: var(--paper); padding: 3px 8px; border-radius: 999px; flex: none;
}

/* ---------- Chips d'assurance ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; min-height: 6px; }
.assurance-chip {
    background: var(--paper); color: var(--brand);
    border: 1px solid var(--line);
    padding: 6px 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 7px;
}
.assurance-chip-close {
    background: none; border: none; color: var(--brand);
    cursor: pointer; font-weight: 700; font-size: 14px; padding: 0;
    line-height: 1;
}
.assurance-chip-close:hover { color: var(--red); }

/* ---------- Interrupteur ---------- */
.switch-row { margin-top: 14px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-track {
    width: 46px; height: 26px; flex: none;
    background: var(--line); border-radius: 999px;
    position: relative; transition: background 0.2s;
}
.switch-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-title { display: block; font-weight: 600; font-size: 13.5px; }
.switch-sub { display: block; font-size: 12px; color: var(--ink-faint); }

/* ---------- Résultats ---------- */
.results-section { margin-top: 4px; }

.results-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 4px 10px; flex-wrap: wrap; gap: 8px;
}
.results-head h2 { font-size: 15.5px; }

.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--ink-faint); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-indigo { background: var(--brand); }

.status {
    padding: 12px; text-align: center; font-size: 14px; color: var(--ink-soft);
}
.status.loading { color: var(--brand); animation: pulse 1.5s infinite; }
.status.error { color: var(--red); font-weight: 600; }

.progress-container {
    height: 5px; border-radius: 999px; overflow: hidden;
    background: var(--line);
    margin: 4px 4px 12px;
}
.progress-bar {
    height: 100%; width: 0%;
    background: var(--brand-grad);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Suggestions de recherche partielle */
.partial-suggestions {
    padding: 12px 14px; margin-bottom: 12px;
    background: var(--amber-soft);
    border: 1px solid rgba(217, 119, 6, 0.35);
    border-radius: var(--radius-sm);
}
.partial-suggestions h4 { font-size: 13.5px; color: var(--amber); margin-bottom: 8px; }
.partial-btn {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; padding: 10px 12px; margin-bottom: 6px;
    background: var(--card);
    border: 1px solid rgba(217, 119, 6, 0.45);
    border-radius: var(--radius-sm);
    color: var(--amber); font: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; text-align: left;
    transition: background 0.15s;
}
.partial-btn:last-child { margin-bottom: 0; }
.partial-btn:hover { background: var(--amber); color: #fff; }
.partial-btn .count {
    background: var(--amber); color: #fff;
    padding: 2px 8px; border-radius: 999px; font-size: 11px;
}
.partial-btn:hover .count { background: #fff; color: var(--amber); }

/* Cartes pharmacies */
.results { display: grid; gap: 10px; padding: 4px 0 0; }

.pharmacy-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    padding: 14px 14px 12px;
    box-shadow: var(--shadow);
    animation: cardIn 0.25s ease both;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pharmacy-name { font-weight: 700; font-size: 15px; color: var(--ink); flex: 1; text-transform: capitalize; }
.badge-duty {
    background: var(--green-soft); color: var(--green);
    font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
    padding: 4px 9px; border-radius: 999px;
    text-transform: uppercase; flex: none;
}
.pharmacy-info { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.distance { color: var(--brand); font-weight: 700; }

.assurances-container { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.assurance-tag {
    background: var(--paper); color: var(--brand);
    padding: 3px 9px; border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 4px;
}
.assurance-tag.matched { background: var(--green-soft); color: var(--green); border-color: transparent; }
.assurance-tag.matched::before { content: '✓'; font-weight: 800; }
.assurance-tag.unmatched { opacity: 0.6; }
.assurance-tag.unmatched::before { content: '✗'; }
.assurance-tag.more, .more-assurances {
    background: transparent; border: 1px dashed var(--line);
    color: var(--ink-faint); font-size: 10.5px; font-style: italic;
}
.no-assurance { color: var(--ink-faint); font-style: italic; font-size: 11px; }

.card-actions {
    margin-top: 12px; border-top: 1px solid var(--line);
    padding-top: 10px; display: flex; gap: 8px; flex-wrap: wrap;
}
.btn-nav, .btn-copy {
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; font: inherit;
    background: transparent; border: 1.5px solid var(--brand);
    color: var(--brand);
    padding: 7px 13px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 700; cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-nav:hover, .btn-copy:hover { background: var(--brand); color: #fff; }
.btn-copy.copied { background: var(--green); border-color: var(--green); color: #fff; }

.no-results { text-align: center; padding: 40px 20px; color: var(--ink-faint); }

/* ---------- Barre d'actions fixe ---------- */
.sticky-bar {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 640px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 30px rgba(22, 24, 45, 0.10);
    display: grid; gap: 8px;
    z-index: 50;
}

.actions-container { display: flex; gap: 8px; }

.search-btn {
    flex: 2; font: inherit;
    padding: 15px; font-size: 16px; font-weight: 700;
    color: #fff; background: var(--brand-grad);
    border: none; border-radius: var(--radius-sm);
    cursor: pointer; box-shadow: 0 6px 18px rgba(91, 83, 214, 0.35);
    transition: opacity 0.15s;
}
.search-btn:active { transform: scale(0.98); }
.search-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-reset {
    flex: 1; font: inherit;
    padding: 15px; font-size: 15px; font-weight: 600;
    color: var(--ink-soft); background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer;
}
.btn-reset:active { transform: scale(0.98); }

.install-btn {
    font: inherit;
    width: 100%; padding: 13px; font-size: 14.5px; font-weight: 700;
    color: #fff; background: var(--green);
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    display: none;
}

/* ---------- Pied de page ---------- */
.app-footer {
    padding: 20px 20px 8px; text-align: center;
    font-size: 12px; color: var(--ink-faint);
}
.app-footer strong { color: var(--ink-soft); }
.footer-note { margin-top: 4px; }

/* ---------- Accessibilité / préférences ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; }

/* Lien croisé vers TIKOKITCEDU */
.footer-cross {
    padding: 10px 20px 4px; text-align: center;
    font-size: 12.5px; color: var(--ink-faint);
}
.footer-cross a {
    color: var(--brand); font-weight: 600;
    text-decoration: none;
}
.footer-cross a:hover { text-decoration: underline; }
