/* ==========================================================================
   Connection guard — résilience des pages Blazor Server sur mobile
   --------------------------------------------------------------------------
   Blazor Server repose sur un circuit SignalR/WebSocket permanent navigateur↔
   serveur. Sur certains navigateurs/WebView embarqués (lien ouvert depuis un
   scanner QR, navigateur in-app…) ce circuit ne tient pas : l'écran « se
   recharge en boucle » sans issue. Deux garde-fous ici :

   1. #components-reconnect-modal : modal de reconnexion PERSONNALISÉ. Blazor le
      détecte par son id et y applique lui-même ses classes d'état
      (components-reconnect-show / -failed / -rejected) — sa logique de
      reconnexion par défaut reste intacte. On remplace juste l'overlay muet par
      un message actionnable quand ça boucle.
   2. #drivr-webview-warning : bandeau proactif affiché par connection-guard.js
      quand un WebView in-app est détecté, invitant à ouvrir dans le navigateur.
   ========================================================================== */

/* ── 1. Modal de reconnexion ─────────────────────────────────────────────── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.55);
    padding: 20px;
}

/* Blazor pose l'une de ces classes selon l'état du circuit. */
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

.cg-reconnect-box {
    background: #fff;
    border-radius: 14px;
    max-width: 420px;
    width: 100%;
    padding: 24px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    font-family: 'Inter', system-ui, sans-serif;
}

.cg-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid #e5e7eb;
    border-top-color: #186EB6;
    border-radius: 50%;
    animation: cg-spin 0.9s linear infinite;
}

@keyframes cg-spin { to { transform: rotate(360deg); } }

.cg-reconnect-box p { margin: 6px 0; color: #374151; font-size: 0.95rem; line-height: 1.5; }
.cg-reconnect-box .cg-hint { color: #6b7280; font-size: 0.85rem; }

/* Contenu « perdu » (reconnexion échouée/rejetée) : masqué pendant les tentatives. */
.cg-lost { display: none; }

#components-reconnect-modal.components-reconnect-failed .cg-trying,
#components-reconnect-modal.components-reconnect-rejected .cg-trying { display: none; }

#components-reconnect-modal.components-reconnect-failed .cg-lost,
#components-reconnect-modal.components-reconnect-rejected .cg-lost { display: block; }

/* Lien affiché dans le modal : lisible, cliquable, coupe les longues URL. */
.cg-link {
    display: block;
    margin: 12px 0 4px;
    padding: 10px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #186EB6;
    font-size: 0.82rem;
    word-break: break-all;
    text-align: left;
    text-decoration: none;
}

.cg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
}

.cg-btn {
    appearance: none;
    border: 1px solid #186EB6;
    background: #186EB6;
    color: #fff;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.cg-btn--ghost { background: #fff; color: #186EB6; }

/* ── 2. Bandeau WebView in-app ───────────────────────────────────────────── */
#drivr-webview-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 19000;
    background: #fff4e5;
    border-bottom: 1px solid #f0c47a;
    color: #7a4a00;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    padding: 10px 14px;
    align-items: center;
    gap: 10px;
}

#drivr-webview-warning .cg-wv-text { flex: 1; min-width: 0; line-height: 1.4; }
#drivr-webview-warning .cg-wv-text strong { font-weight: 700; }

#drivr-webview-warning .cg-btn {
    border-color: #b7791f;
    background: #b7791f;
    padding: 7px 12px;
    font-size: 0.82rem;
    flex-shrink: 0;
}

#drivr-webview-warning .cg-wv-close {
    background: transparent;
    border: none;
    color: #7a4a00;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0 4px;
    line-height: 1;
}
