/* =========================================================
   Videochat — design sombre style Bazoocam
   ========================================================= */

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

:root {
    --bg-page:      #000;
    --bg-surface:   #111;
    --bg-elevated:  #1c1c1c;
    --border:       #2e2e2e;
    --border-dark:  #333;
    --text-primary: #fff;
    --text-muted:   #888;
    --accent:       #4f8ef7;
    --accent-hover: #3a7ae0;
    --danger:       #e05454;
    --danger-hover: #c43c3c;
    --success:      #4caf7d;
    --radius:       6px;
    --font:         'Segoe UI', system-ui, sans-serif;
}

html, body {
    height: 100%;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

/* Layout ------------------------------------------------- */

.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Topbar compact ----------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    height: 40px;
    background: #0a0a0a;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
}

.logo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin-right: auto;
}

.user-info {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Barre utilisateurs en ligne (style Bazoocam) ----------- */

.online-users-bar {
    height: 40px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 12px;
    overflow-x: auto;
    flex-shrink: 0;
    white-space: nowrap;
    scrollbar-width: none;
}
.online-users-bar::-webkit-scrollbar { display: none; }

/* Items injectés par JS */
.online-users-bar .online-user {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #333;
}
.online-users-bar .icon-male   { color: #4da6ff; }
.online-users-bar .icon-female { color: #ff69b4; }

/* Zone principale --------------------------------------- */

.content-area {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Colonne vidéos (gauche, 320 px fixe) ------------------- */

.video-col {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #000;
    border-right: 1px solid #222;
}

/* Labels "Stranger" / "Vous" au-dessus de chaque vidéo */
.video-label {
    font-size: 0.72rem;
    color: #888;
    padding: 5px 0 3px 4px;
    background: #000;
    display: block;
    flex-shrink: 0;
}

#remoteVideo {
    width: 320px;
    height: 240px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
    border: 1px solid #444;
}

#localVideo {
    width: 320px;
    height: 240px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
    border: 1px solid #444;
}

/* Wrapper relatif pour positionner le bouton fullscreen -- */

.video-wrapper {
    position: relative;
    flex-shrink: 0;
}

/* Bouton toggle plein écran ------------------------------ */

.btn-fullscreen {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 18px;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    line-height: 1;
    z-index: 2;
    transition: background 0.15s;
}
.btn-fullscreen:hover { background: rgba(0, 0, 0, 0.7); }

/* État plein écran --------------------------------------- */

#remoteVideo.fullscreen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    object-fit: cover;
}

#localVideo.fullscreen-pip {
    position: fixed;
    bottom: 80px;
    right: 10px;
    width: 160px;
    height: 120px;
    z-index: 11;
    border-radius: 8px;
    border: 2px solid #fff;
    object-fit: cover;
}

/* Le bouton suit la vidéo en plein écran */
.btn-fullscreen.is-fullscreen {
    position: fixed;
    top: 5px;
    right: 5px;
    z-index: 12;
}

/* Colonne droite (flexible) ------------------------------ */

.side-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Boutons d'action (haut de la colonne droite) ----------- */

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: #0a0a0a;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
}

.controls-divider {
    width: 1px;
    height: 26px;
    background: #333;
    margin: 0 2px;
}

/* Bouton Suivant / Signaler — style Bazoocam (#ddd / #000) */
.btn-action {
    background: #ddd;
    color: #000;
    border: none;
    border-radius: var(--radius);
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    height: 36px;
}
.btn-action:not(:disabled):hover   { background: #c6c6c6; }
.btn-action:disabled                { opacity: 0.45; cursor: not-allowed; }

/* Signaler ajouté dynamiquement par videochat.js avec .btn-danger —
   override pour le forcer en #ddd/#000 comme Suivant */
#btnReport {
    background: #ddd !important;
    color: #000 !important;
}
#btnReport:not(:disabled):hover { background: #c6c6c6 !important; }

/* Info partenaire ---------------------------------------- */

.partner-info {
    padding: 7px 12px;
    font-size: 0.85rem;
    color: #fff;
    background: transparent;
    border-bottom: 1px solid #1a1a1a;
    flex-shrink: 0;
    min-height: 34px;
}

/* Chat panel --------------------------------------------- */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #111;
    border-top: 1px solid var(--border-dark);
}

.chat-panel__header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.chat-messages::-webkit-scrollbar       { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 90%;
    align-self: flex-start;
}

.chat-msg--self {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg--system {
    align-self: center;
    max-width: 100%;
}

.chat-msg__meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0 4px;
}

.chat-msg__bubble {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg--self .chat-msg__bubble {
    background: var(--accent);
    color: #fff;
}

.chat-msg--system .chat-msg__bubble {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: italic;
    padding: 2px 0;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.chat-input-row input {
    flex: 1;
    padding: 7px 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.chat-input-row input::placeholder { color: #444; }
.chat-input-row input:focus        { border-color: var(--accent); }
.chat-input-row input:disabled     { opacity: 0.35; cursor: not-allowed; }

.btn-send {
    padding: 7px 12px;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

/* Status bar (bas de la colonne droite) ------------------ */

.status-bar {
    padding: 6px 14px;
    background: #0a0a0a;
    border-top: 1px solid #222;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

.status-bar.connecting { color: var(--accent); }
.status-bar.connected  { color: var(--success); }
.status-bar.error      { color: var(--danger); }

/* Barre badge en ligne ------------------------------------ */

.online-bar {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    border-top: 1px solid #1a1a1a;
    background: #0a0a0a;
    flex-shrink: 0;
}

/* Badge en ligne ----------------------------------------- */

.badge-online {
    font-size: 0.75rem;
    color: var(--success);
    background: rgba(76, 175, 125, 0.12);
    border: 1px solid rgba(76, 175, 125, 0.3);
    padding: 2px 9px;
    border-radius: 20px;
}

/* Boutons mobile-only — masqués sur desktop -------------- */

.btn-mobile-chat { display: none; }

.btn-close-chat {
    display: none;
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.btn-close-chat:hover { color: var(--text-primary); }

/* Buttons ------------------------------------------------ */

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid #333;
}
.btn-secondary:not(:disabled):hover { background: #252525; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:not(:disabled):hover { background: var(--danger-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #333;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
}
.btn-ghost:hover { color: var(--text-primary); border-color: #555; }

/* Bouton muted (micro/cam OFF) --------------------------- */

.btn-muted {
    background: var(--bg-elevated);
    color: var(--danger);
    border: 1px solid rgba(224, 84, 84, 0.4);
}
.btn-muted:not(:disabled):hover {
    background: rgba(224, 84, 84, 0.1);
}

/* =========================================================
   Mobile (≤ 768 px) — inchangé
   ========================================================= */

@media (max-width: 768px) {

    /* Cacher la topbar et online-users-bar */
    .topbar            { display: none; }
    .online-users-bar  { display: none; }

    /* Réduire content-area à 0 ; les enfants fixed restent visibles */
    .content-area {
        flex: 0 0 0;
        min-height: 0;
        overflow: visible;
    }

    /* Colonne vidéos : collapse, les vidéos passent en fixed */
    .video-col {
        width: 0;
        height: 0;
        overflow: visible;
        border: none;
    }

    .video-label    { display: none; }
    .btn-fullscreen { display: none; }

    /* Vidéo distante : plein écran */
    #remoteVideo {
        position: fixed;
        top: 0; left: 0;
        width: 100vw;
        height: 100vh;
        object-fit: cover;
        z-index: 1;
        border: none;
    }

    /* Vidéo locale : incrustation bas-droite */
    #localVideo {
        position: fixed;
        bottom: 80px;
        right: 10px;
        width: 120px;
        height: 90px;
        object-fit: cover;
        border-radius: 8px;
        border: 2px solid #fff;
        z-index: 3;
    }

    /* Colonne droite : collapse, enfants fixed restent visibles */
    .side-col {
        width: 0;
        height: 0;
        overflow: visible;
        border: none;
    }

    /* Status bar, badge et partner-info masqués sur mobile */
    #status-bar    { display: none; }
    .online-bar    { display: none; }
    .partner-info  { display: none; }

    /* Micro / Caméra masqués dans la barre mobile */
    #btnMic, #btnCam { display: none; }

    /* Barre de contrôles fixe en bas */
    .controls {
        position: fixed;
        bottom: 0; left: 0;
        width: 100%;
        min-height: 50px;
        height: auto;
        z-index: 4;
        background: rgba(0, 0, 0, 0.85);
        border: none;
        padding: 8px 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .controls .btn,
    .controls .btn-action {
        padding: 10px 14px;
        font-size: 0.85rem;
        height: auto;
    }

    .controls-divider { display: none; }

    /* Panel chat : overlay fixe, masqué par défaut */
    .chat-panel {
        position: fixed;
        bottom: 60px; left: 0;
        width: 100%;
        height: 40vh;
        z-index: 5;
        background: rgba(0, 0, 0, 0.85);
        display: none;
        flex-direction: column;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .chat-panel.open { display: flex; }

    /* Boutons mobile-only visibles */
    .btn-mobile-chat {
        display: inline-flex;
        align-items: center;
    }

    .btn-close-chat { display: inline-flex; }
}

/* =========================================================
   Page d'authentification
   ========================================================= */

body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-wrap {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 36px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    letter-spacing: -0.5px;
}

/* Onglets ------------------------------------------------ */

.auth-tabs {
    display: flex;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 3px;
}

.tab-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
    background: #1a1a1a;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.tab-btn:not(.active):hover {
    color: var(--text-primary);
}

/* Alerte ------------------------------------------------- */

.auth-alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.4;
}

.auth-alert--error {
    background: rgba(224, 84, 84, 0.12);
    border: 1px solid rgba(224, 84, 84, 0.35);
    color: #f08080;
}

.auth-alert--success {
    background: rgba(76, 175, 125, 0.12);
    border: 1px solid rgba(76, 175, 125, 0.35);
    color: #7ecfa0;
}

/* Formulaire --------------------------------------------- */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form--hidden {
    display: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.field input {
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.field input::placeholder {
    color: #555;
}

.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.15);
}

.field input:invalid:not(:placeholder-shown) {
    border-color: var(--danger);
}

/* Bouton pleine largeur ---------------------------------- */

.btn-full {
    width: 100%;
    padding: 11px;
    margin-top: 4px;
}

/* Auth responsive --------------------------------------- */

@media (max-width: 440px) {
    .auth-card { padding: 28px 20px 24px; }
}
