/* ── Variables ───────────────────────────────────────────── */
:root {
    --rouge:    #E8112D;
    --vert:     #008751;
    --jaune:    #FCD116;
    --fond:     #F8F9FB;
    --blanc:    #FFFFFF;
    --texte:    #0F1117;
    --texte2:   #6B7280;
    --bordure:  #E5E7EB;
    --shadow:   0 4px 24px rgba(0,0,0,.08);
    --radius:   18px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background: var(--fond);
    color: var(--texte);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: env(safe-area-inset-top, 16px) 20px env(safe-area-inset-bottom, 16px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── App container ───────────────────────────────────────── */
.app {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: flex-start;
    padding: 0 4px;
}

.header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.header-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-text h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .5px;
    color: var(--texte);
    line-height: 1.1;
}

.header-text p {
    font-size: 12px;
    color: var(--texte2);
    margin-top: 2px;
    letter-spacing: .3px;
}

/* ── Location card ───────────────────────────────────────── */
.location-card {
    width: 100%;
    background: var(--blanc);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--bordure);
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 76px;
}

.location-icon {
    width: 38px;
    height: 38px;
    background: #F0FDF4;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.location-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--vert);
}

.location-info {
    flex: 1;
    min-width: 0;
}

.commune {
    font-size: 17px;
    font-weight: 700;
    color: var(--texte);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.departement {
    font-size: 12px;
    color: var(--texte2);
    margin-top: 2px;
}

.nearest-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #FFF7ED;
    color: #C2410C;
    border: 1px solid #FED7AA;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    margin-top: 5px;
}

.statut {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--texte2);
}

.texte {
    font-size: 10px;
    color: var(--texte2);
    text-align: right;
    max-width: 80px;
    line-height: 1.3;
}

.statut.ok .dot       { background: #22C55E; }
.statut.error .dot    { background: var(--rouge); }
.statut.loading .dot  { background: var(--jaune); animation: pulse 1s infinite; }
.statut.ok .texte     { color: #16A34A; }
.statut.error .texte  { color: var(--rouge); }

/* ── Bouton urgence + anneaux Bénin ──────────────────────── */
.btn-urgence-container {
    position: relative;
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: ringPulse 2.4s ease-out infinite;
}

.ring-green {
    width: 240px;
    height: 240px;
    border-color: var(--vert);
    opacity: .5;
    animation-delay: 0s;
}

.ring-yellow {
    width: 218px;
    height: 218px;
    border-color: var(--jaune);
    opacity: .65;
    animation-delay: .15s;
}

.ring-red {
    width: 196px;
    height: 196px;
    border-color: var(--rouge);
    opacity: .55;
    animation-delay: .3s;
}

.btn-urgence {
    width: 172px;
    height: 172px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, #FF3350, var(--rouge), #C40020);
    box-shadow:
        0 0 0 6px rgba(232,17,45,.12),
        0 12px 40px rgba(232,17,45,.45),
        inset 0 2px 4px rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .12s, box-shadow .12s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 2;
}

.btn-urgence:active:not(.disabled) {
    transform: scale(.93);
    box-shadow:
        0 0 0 4px rgba(232,17,45,.15),
        0 6px 20px rgba(232,17,45,.35),
        inset 0 2px 4px rgba(255,255,255,.15);
}

.btn-urgence.disabled {
    background: linear-gradient(145deg, #D1D5DB, #9CA3AF);
    box-shadow: 0 8px 24px rgba(0,0,0,.12), inset 0 2px 4px rgba(255,255,255,.15);
    cursor: not-allowed;
}

.btn-urgence.disabled ~ .ring-green,
.btn-urgence.disabled ~ .ring-yellow,
.btn-urgence.disabled ~ .ring-red {
    opacity: .15;
    animation: none;
}

.btn-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.phone-icon {
    width: 44px;
    height: 44px;
    fill: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}

.btn-label {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* Anneaux désactivés quand bouton disabled */
.btn-urgence-container:has(.disabled) .ring {
    opacity: .12;
    animation: none;
}

/* ── Opérateur ───────────────────────────────────────────── */
.operateur-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.operateur-hint {
    font-size: 11px;
    color: var(--texte2);
    text-align: center;
    letter-spacing: .2px;
}

.operateur-btns {
    display: flex;
    gap: 6px;
    background: var(--blanc);
    padding: 5px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--bordure);
}

.op-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: transparent;
    color: var(--texte2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s;
    letter-spacing: .3px;
}

/* Actif : fond coloré selon l'opérateur */
.op-btn[data-op="moov"].actif {
    background: #EBF5FF;
    color: #0060B0;
    border-color: #0073CF;
}

.op-btn[data-op="mtn"].actif {
    background: #FFFBEB;
    color: #92400E;
    border-color: #FFC107;
}

.op-btn[data-op="celtiis"].actif {
    background: #FFF1F2;
    color: #9F1239;
    border-color: #E8112D;
}

.op-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.op-dot.moov    { background: #0073CF; }
.op-dot.mtn     { background: #FFC107; }
.op-dot.celtiis { background: #E8112D; }

/* ── Banner installation PWA ─────────────────────────────── */
.install-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    width: calc(100% - 32px);
    max-width: 420px;
    background: var(--blanc);
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    border: 1px solid var(--bordure);
    z-index: 90;
    transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}

.install-banner.visible {
    transform: translateX(-50%) translateY(0);
}

.install-banner .install-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.install-banner .install-icon img,
.ios-modal-header .install-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.install-text {
    flex: 1;
    min-width: 0;
}

.install-text strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--texte);
}

.install-text span {
    font-size: 12px;
    color: var(--texte2);
    margin-top: 1px;
    display: block;
}

.install-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.install-btn-yes {
    padding: 8px 16px;
    background: linear-gradient(135deg, #FF3350, var(--rouge));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(232,17,45,.3);
    white-space: nowrap;
}

.install-btn-no {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--fond);
    color: var(--texte2);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Modal iOS ───────────────────────────────────────────── */
.ios-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 95;
    padding: 0 12px 24px;
}

.ios-modal-inner {
    background: var(--blanc);
    border-radius: 22px;
    padding: 24px 22px;
    width: 100%;
    max-width: 420px;
}

.ios-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ios-modal-header h3 {
    flex: 1;
    font-size: 17px;
    font-weight: 700;
}

.ios-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--fond);
    color: var(--texte2);
    font-size: 14px;
    cursor: pointer;
}

.ios-modal-inner p {
    font-size: 14px;
    color: var(--texte2);
    margin-bottom: 14px;
    line-height: 1.5;
}

.ios-modal-inner ol {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.ios-modal-inner li {
    font-size: 14px;
    color: var(--texte);
    line-height: 1.5;
}

.ios-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #007AFF;
    color: white;
    border-radius: 5px;
    font-size: 12px;
    vertical-align: middle;
    margin: 0 2px;
}

.ios-ok-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #FF3350, var(--rouge));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: rgba(15,17,23,.9);
    backdrop-filter: blur(12px);
    color: white;
    padding: 12px 22px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
    z-index: 100;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* ── Écran permission ────────────────────────────────────── */
#ecran-permission {
    position: fixed;
    inset: 0;
    background: var(--blanc);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    text-align: center;
    z-index: 50;
    gap: 16px;
}

.perm-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.perm-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--vert);
    fill: none;
}

#ecran-permission h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--texte);
}

#ecran-permission p {
    font-size: 14px;
    color: var(--texte2);
    line-height: 1.65;
    max-width: 300px;
}

.btn-autoriser {
    margin-top: 8px;
    padding: 16px 48px;
    background: linear-gradient(135deg, #FF3350, var(--rouge));
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(232,17,45,.35);
    letter-spacing: .3px;
    transition: transform .1s, box-shadow .1s;
}

.btn-autoriser:active {
    transform: scale(.97);
    box-shadow: 0 4px 12px rgba(232,17,45,.25);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .4; transform: scale(.85); }
}

@keyframes ringPulse {
    0%   { transform: scale(1);    opacity: .55; }
    60%  { transform: scale(1.04); opacity: .3; }
    100% { transform: scale(1);    opacity: .55; }
}

/* ── Responsive petits écrans ────────────────────────────── */
@media (max-height: 680px) {
    .app { gap: 14px; }
    .btn-urgence-container { width: 200px; height: 200px; margin: 0; }
    .ring-green  { width: 200px; height: 200px; }
    .ring-yellow { width: 181px; height: 181px; }
    .ring-red    { width: 163px; height: 163px; }
    .btn-urgence { width: 144px; height: 144px; }
    .phone-icon  { width: 36px; height: 36px; }
    .btn-label   { font-size: 12px; }
}

@media (max-width: 360px) {
    body { padding: 12px 14px; }
    .op-btn { padding: 8px 12px; font-size: 12px; }
}
