* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f5f6fa;
    color: #222;
    margin: 0;
    padding: 0;
}

/* HEADER */
header.app-header {
    background: linear-gradient(90deg, #e6e9f5, #f0f2fa);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #3d63ff;
}

header.app-header h1 {
    font-size: 20px;
    margin: 0;
    color: #1a1a1a;
}

/* LIVE BADGE */
.live-badge {
    background: #e02424;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    letter-spacing: 1px;
    animation: pulse 1.5s infinite;
}

.live-badge.offline {
    background: #bbb;
    animation: none;
}

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

/* MAIN LAYOUT */
.main-layout {
    display: flex;
    height: calc(100vh - 62px);
}

/* VIDEO PANEL */
.video-panel {
    flex: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #ffffff;
}

.video-panel video,
.video-panel canvas {
    width: 100%;
    max-width: 1100px;
    max-height: 72vh;
    height: auto;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
    border: 1px solid #d0d4e4;
}

/* CONTROLS */
.controls {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.controls input[type="text"] {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
}

.control-row input[type="text"] {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fafafa;
    color: #222;
}

#recordingTitle {
    flex: none;
    width: 200px;
    min-width: 0;
}

#broadcasterName {
    width: 150px;
    flex: none;
}

.controls select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
    cursor: pointer;
}

/* TABS */
.source-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    border-bottom: 1px solid #d0d4e4;
    width: 100%;
    max-width: 1100px;
}

.tab-btn {
    background: transparent;
    color: #666;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
}

.tab-btn:hover {
    background: #f0f2fa;
    color: #222;
}

.tab-btn.active {
    color: #000;
    border-bottom-color: #3d63ff;
}

.tab-btn.locked {
    cursor: not-allowed;
    opacity: 0.5;
}

.tab-btn.locked:hover {
    background: transparent;
    color: #666;
}

.tab-btn.locked.active {
    color: #000;
    opacity: 1;
}

/* PANELS */
.tab-panel {
    width: 100%;
    max-width: 1100px;
    margin-bottom: 12px;
}

.tab-panel .viewer-count {
    margin: 0;
    text-align: left;
}

.main-tabs {
    margin-bottom: 16px;
}

.header-tabs {
    margin-bottom: 0;
    width: auto;
    max-width: none;
    border-bottom: none;
    gap: 2px;
}

.header-tabs .main-tab-btn {
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px 6px 0 0;
}

.header-tabs .main-tab-btn.active {
    border-bottom-width: 3px;
    background: rgba(0, 0, 0, 0.06);
}

.main-tab-panel {
    width: 100%;
    max-width: 1100px;
}

/* CONTROL CARDS */
.controls-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.control-card {
    background: #ffffff;
    border: 1px solid #d0d4e4;
    border-radius: 10px;
    padding: 18px 20px;
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-card h3 {
    margin: 0 0 14px 0;
    font-size: 15px;
    color: #000;
    padding-bottom: 10px;
    border-bottom: 1px solid #d0d4e4;
}

.control-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.control-row button,
.control-row label {
    flex-shrink: 0;
}

.control-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #222;
    font-size: 14px;
    cursor: pointer;
}

.control-hint {
    color: #777;
    font-size: 13px;
    margin: 0 0 12px 0;
}

/* BUTTONS */
button {
    cursor: pointer;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-weight: 600;
    background: #3d63ff;
    color: #fff;
    transition: background 0.15s ease-in-out;
}

button:hover {
    background: #2c4ad1;
}

button.stop {
    background: #e02424;
}

button.stop:hover {
    background: #b81c1c;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* CHAT PANEL */
.chat-panel {
    flex: 1;
    min-width: 300px;
    max-width: 360px;
    background: #ffffff;
    border-left: 1px solid #d0d4e4;
    display: flex;
    flex-direction: column;
}

.chat-panel h2 {
    font-size: 15px;
    padding: 12px 16px;
    margin: 0;
    border-bottom: 1px solid #d0d4e4;
    background: #f0f2fa;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
}

.chat-message {
    margin-bottom: 10px;
    line-height: 1.35;
    word-wrap: break-word;
}

.chat-message .author {
    font-weight: bold;
    color: #3d63ff;
}

.chat-message .time {
    font-size: 11px;
    color: #777;
    margin-left: 6px;
}

.chat-message.system {
    color: #c59b00;
    font-style: italic;
    font-size: 13px;
    text-align: center;
    border-top: 1px dashed #ccc;
    border-bottom: 1px dashed #ccc;
    padding: 6px 0;
}

/* TRADUCTION DU CHAT (Microsoft Translator) */
.chat-translate-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 14px;
    border-bottom: 1px solid #d0d4e4;
    background: #f7f8fc;
    font-size: 13px;
}

.chat-translate-bar select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
    font-size: 13px;
}

.chat-translate-bar select:disabled {
    background: #eee;
    color: #999;
    cursor: not-allowed;
}

.chat-message-translation {
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid #6fa8ff;
    color: #4a5578;
    font-size: 13px;
    font-style: italic;
}

.chat-input-area {
    display: flex;
    padding: 10px;
    gap: 8px;
    border-top: 1px solid #d0d4e4;
}

.chat-input-area input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
}

.chat-input-area button#btnSendChat {
    width: 42px;
    height: 40px;
    padding: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.viewer-count {
    font-size: 13px;
    color: #666;
}

/* ONGLETS PRINCIPAUX DE LA PAGE SPECTATEUR (Direct / Partager) */
.viewer-main-tab-panel {
    width: 100%;
}

.viewer-share-wrapper {
    display: flex;
    justify-content: center;
    padding: 24px;
    background: #ffffff;
    min-height: calc(100vh - 62px);
    box-sizing: border-box;
}

/* GRILLE DES FLUX PARTAGÉS PAR LES SPECTATEURS (Broadcast.aspx) */
.video-panel-top {
    justify-content: flex-start !important;
}
.viewer-streams-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 8px;
}

.viewer-stream-tile {
    width: 220px;
    background: #14151a;
    border: 1px solid #2b2f42;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, transform 0.1s ease-in-out;
}

.viewer-stream-tile:hover {
    border-color: #3d63ff;
    transform: translateY(-2px);
}

.viewer-stream-canvas {
    display: block;
    width: 100%;
    height: 124px;
    object-fit: contain;
    background: #000;
}

.viewer-stream-label {
    padding: 6px 8px;
    font-size: 12px;
    color: #ddd;
    background: #1a1c25;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* FENÊTRE MODALE : APERÇU AGRANDI D'UN FLUX SPECTATEUR (Broadcast.aspx) */
/* Reprend le même habillage que la vidéo/canvas du panneau Émetteur
   (.video-panel video / .video-panel canvas) pour un aperçu identique. */
.viewer-stream-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-stream-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.viewer-stream-modal-content {
    position: relative;
    z-index: 1001;
    background: #ffffff;
    border-radius: 10px;
    max-width: calc(1100px + 40px);
    width: 92vw;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.viewer-stream-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 600;
}

/* Le libellé (nom du spectateur) doit pouvoir rétrécir et se tronquer plutôt
   que de passer à la ligne et écraser les boutons plein écran / fermer contre
   la bordure (c'est ce qui causait leur superposition sur petit écran ou avec
   un nom de spectateur long). */
#viewerStreamModalLabel {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Les boutons (plein écran + fermer), eux, ne doivent jamais rétrécir. */
.viewer-stream-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.viewer-stream-modal-close {
    background: transparent;
    color: #666;
    padding: 2px 10px;
    font-size: 18px;
    border-radius: 6px;
}

.viewer-stream-modal-close:hover {
    background: #f0f2fa;
    color: #222;
}

/* Même rendu que .video-panel video / .video-panel canvas côté Aperçu Émetteur. */
#viewerStreamModalCanvas {
    display: block;
    width: 100%;
    max-width: 1100px;
    max-height: 72vh;
    height: auto;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
    border: 1px solid #d0d4e4;
    margin: 0 auto;
}

/* MODE PLEIN ÉCRAN DE L'APERÇU VIDÉO (Broadcast.aspx / Viewer.aspx) */
.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 1100px;
    display: flex;
    justify-content: center;
}

.btn-fullscreen {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    cursor: pointer;
    z-index: 5;
}

.btn-fullscreen:hover {
    background: rgba(0, 0, 0, 0.75);
}

/* Variante du bouton plein écran utilisée dans l'en-tête de la popup d'aperçu
   agrandi d'un flux spectateur : bouton "en ligne" au lieu d'être positionné
   en absolu par-dessus la vidéo (l'en-tête a un fond clair, pas la vidéo). */
.btn-fullscreen-inline {
    position: static;
    background: #eef0f8;
    color: #444;
    border: 1px solid #d0d4e4;
}

.btn-fullscreen-inline:hover {
    background: #e2e5f5;
}

/* Conteneur vidéo de la popup d'aperçu agrandi : mêmes règles que .video-wrapper
   mais sans forcer une largeur max, pour s'adapter à la largeur de la popup. */
#viewerStreamModalVideoWrapper {
    max-width: none;
}

/* En plein écran, le conteneur occupe tout l'écran ; la vidéo/le canvas s'y
   adapte sans dépasser (object-fit: contain déjà hérité de
   .video-panel video / .video-panel canvas). */
.video-wrapper:fullscreen,
.video-wrapper:-webkit-full-screen {
    max-width: none;
    width: 100vw;
    height: 100vh;
    background: #000;
    align-items: center;
}

.video-wrapper:fullscreen video,
.video-wrapper:fullscreen canvas,
.video-wrapper:-webkit-full-screen video,
.video-wrapper:-webkit-full-screen canvas {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    border-radius: 0;
}
