/*
 * DPKProd Chat — Feuille de styles du widget web
 *
 * Utilisé par le shortcode [dpkprod_chat].
 * Toutes les règles sont préfixées ".dpkprod-chat" pour éviter
 * tout conflit avec le thème WordPress actif.
 *
 * Accessibilité :
 *   – Contraste WCAG AA respecté sur toutes les combinaisons texte/fond.
 *   – Focus visible sur tous les éléments interactifs.
 *   – Tailles de police en rem pour respecter les préférences utilisateur.
 */

/* ============================================================
   CONTENEUR PRINCIPAL
   ============================================================ */

.dpkprod-chat {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    color: #1a1a1a;
    max-width: 800px;
    margin: 1.5rem auto;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   EN-TÊTE
   ============================================================ */

.dpkprod-chat__entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.85rem 1.1rem;
    background: #1e3a5f;
    color: #fff;
}

.dpkprod-chat__titre {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.dpkprod-chat__utilisateurs {
    font-size: 0.8rem;
    opacity: 0.85;
    white-space: nowrap;
}

/* ============================================================
   LECTEUR AUDIO
   ============================================================ */

.dpkprod-chat__audio {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1.1rem;
    background: #f0f4f8;
    border-bottom: 1px solid #dce4ed;
}

.dpkprod-chat__audio[hidden] {
    display: none;
}

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

.dpkprod-chat__flux-nom {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e3a5f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dpkprod-chat__flux-description {
    display: block;
    font-size: 0.78rem;
    color: #666;
    margin-top: 0.1rem;
}

.dpkprod-chat__audio audio {
    height: 36px;
    max-width: 100%;
}

/* ============================================================
   CHAT FERMÉ
   ============================================================ */

.dpkprod-chat__ferme {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #555;
}

.dpkprod-chat__ferme[hidden] {
    display: none;
}

.dpkprod-chat__ferme-icone {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.dpkprod-chat__ferme-message {
    font-size: 1rem;
    margin: 0;
}

/* ============================================================
   CONNEXION REQUISE
   ============================================================ */

.dpkprod-chat__connexion {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #555;
}

.dpkprod-chat__connexion p {
    margin: 0 0 1rem;
}

.dpkprod-chat__connexion a {
    display: inline-block;
    padding: 0.55rem 1.25rem;
    background: #1e3a5f;
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.dpkprod-chat__connexion a:hover,
.dpkprod-chat__connexion a:focus {
    background: #2a5080;
    outline: 3px solid #5b9bd5;
    outline-offset: 2px;
}

/* ============================================================
   ZONE DE MESSAGES
   ============================================================ */

.dpkprod-chat__contenu[hidden] {
    display: none;
}

.dpkprod-chat__messages {
    height: var(--dpkprod-hauteur, 380px);
    overflow-y: auto;
    padding: 0.85rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    background: #fafafa;
    scroll-behavior: smooth;
}

.dpkprod-chat__vide {
    margin: auto;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

/* ============================================================
   MESSAGES INDIVIDUELS
   ============================================================ */

.dpkprod-message {
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
}

/* Message normal */
.dpkprod-type-message {
    background: #fff;
    border: 1px solid #e8e8e8;
}

/* Annonce d'arrivée / départ */
.dpkprod-type-entree,
.dpkprod-type-sortie {
    background: transparent;
    border: none;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
    padding: 0.2rem 0;
}

.dpkprod-message__heure {
    color: #999;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    margin-right: 0.35rem;
    user-select: none;
}

.dpkprod-message__auteur {
    font-weight: 600;
    color: #1e3a5f;
    margin-right: 0.2rem;
}

/* ============================================================
   ZONE DE SAISIE
   ============================================================ */

.dpkprod-chat__formulaire {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    border-top: 1px solid #ddd;
    background: #fff;
}

.dpkprod-chat__label-message {
    /* Masqué visuellement mais lisible par les lecteurs d'écran */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.dpkprod-chat__input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #1a1a1a;
    background: #f9f9f9;
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.dpkprod-chat__input:focus {
    outline: none;
    border-color: #5b9bd5;
    box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.25);
    background: #fff;
}

.dpkprod-chat__input::placeholder {
    color: #aaa;
}

.dpkprod-chat__bouton-envoyer {
    flex-shrink: 0;
    padding: 0.6rem 1.1rem;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.dpkprod-chat__bouton-envoyer:hover:not(:disabled) {
    background: #2a5080;
}

.dpkprod-chat__bouton-envoyer:focus {
    outline: 3px solid #5b9bd5;
    outline-offset: 2px;
}

.dpkprod-chat__bouton-envoyer:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ============================================================
   ERREUR D'ENVOI
   ============================================================ */

.dpkprod-chat__erreur {
    padding: 0.5rem 1.1rem;
    background: #fdf2f2;
    color: #9b1c1c;
    font-size: 0.85rem;
    border-top: 1px solid #fcd4d4;
}

.dpkprod-chat__erreur[hidden] {
    display: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 480px) {
    .dpkprod-chat {
        border-radius: 0;
        margin: 0;
        border-left: none;
        border-right: none;
    }

    .dpkprod-chat__bouton-envoyer {
        padding: 0.6rem 0.75rem;
    }
}
