﻿/* LokoScope — design sobre, responsive, sans framework. */

:root {
    --bg: #12161c;
    --surface: #1c232d;
    --surface-2: #242e3b;
    --text: #e8edf3;
    --text-dim: #93a1b3;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --speaking: #22c55e;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.hidden {
    display: none !important;
}

.hidden-players {
    display: none;
}

/* Crédit auteur, en bas de page (écrans d'accueil / entrée / attente) */
.site-credit {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    pointer-events: none;
}

.site-credit a {
    color: var(--accent);
    text-decoration: none;
    pointer-events: auto;
}

.site-credit a:hover {
    text-decoration: underline;
}

.site-credit .version-appli {
    opacity: 0.8;
    font-size: 0.75rem;
}

.screen {
    height: 100%;
}

/* ---------- Cartes centrées (accueil, entrée, attente) ---------- */

#request-screen,
#join-screen,
#waiting-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.card.center {
    text-align: center;
}

.card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.8rem;
}

.tagline {
    margin: 0 0 1.5rem;
    color: var(--text-dim);
    font-size: 0.95rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

form label,
.field-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
}

input[type="text"],
input[type="email"],
select,
textarea {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    outline: none;
    width: 100%;
}

textarea {
    resize: vertical;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

/* Autocomplétion des invités */

.autocomplete-wrap {
    position: relative;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    margin: 2px 0 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    max-height: 180px;
    overflow-y: auto;
}

.suggestions li {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.92rem;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestions li:hover,
.suggestions li.selected {
    background: var(--accent);
    color: #fff;
}

/* Avertissement de saisie : attire l'œil sans bloquer, à la différence de « .error ». */
.hint-warn {
    color: #fbbf24;
    font-size: 0.8rem;
    margin: 0.35rem 0 0;
}

.hint-warn button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    width: auto;
}

.hint-warn button:hover {
    color: var(--accent-hover);
}

.radio-row {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.35rem;
}

.radio {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    font-size: 0.95rem;
    margin-top: 0;
    cursor: pointer;
}

form button[type="submit"],
#btn-join {
    margin-top: 1.25rem;
}

.hint {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 1rem;
}

.notice {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: #bfdbfe;
    font-size: 0.85rem;
    margin-top: 1rem;
    padding: 0.6rem 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.error {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 0.85rem;
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    white-space: pre-wrap;
}

/* ---------- Salle d'attente ---------- */

.spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 1rem;
    border: 4px solid var(--surface-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#waiting-screen h2 {
    margin: 0.5rem 0;
}

#waiting-screen button {
    margin-top: 1.25rem;
}

/* Le rappel de la date est une phrase, pas une URL : la coupure agressive de
   « .notice » (pensée pour les liens) n'a pas lieu de s'y appliquer. */
#join-schedule {
    word-break: normal;
}

/* Réunion planifiée : rappel de l'heure de début, au-dessus de l'état de l'organisateur. */
.waiting-schedule {
    color: var(--text);
    font-size: 1.05rem;
    margin: 0.25rem 0 0.5rem;
}

/* ---------- Planification ---------- */

.checkbox-line {
    margin-top: 0.9rem;
}

.schedule-fields {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.schedule-fields .field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.schedule-fields .field:last-child {
    flex: 0 0 8rem;
}

.schedule-fields label {
    margin-top: 0;
}

input[type="datetime-local"] {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    outline: none;
    width: 100%;
    font-family: inherit;
}

input[type="datetime-local"]:focus {
    border-color: var(--accent);
}

/* Le sélecteur natif est sombre par défaut sous Chrome/Edge : on éclaircit l'icône. */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

button.full-width {
    width: 100%;
    margin-top: 1rem;
}

.reschedule-panel,
.organizer-panel {
    margin-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.5rem;
}

.organizer-panel h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    margin: 0.6rem 0 0.5rem;
}

.organizer-panel .hint {
    margin-top: 0.5rem;
}

/* Puces d'invités, partagées avec la console « Mes réunions ». */
.invitee-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.invitee-list li {
    background: var(--surface-2);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.85rem;
}

.reschedule-panel form {
    margin-top: 0.5rem;
}

/* ---------- Écran de réunion ---------- */

#meeting-screen {
    display: flex;
    flex-direction: column;
}

.meeting-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
}

.brand {
    font-weight: 600;
    font-size: 1.1rem;
}

#room-label {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Option « Avec son » (modérateur) : pousse le groupe de droite de l'en-tête */
.sound-option {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sound-option input {
    accent-color: var(--accent);
    cursor: pointer;
}

/* Notifications système refusées : mention discrète, le survol explique comment revenir en arrière. */
.notify-denied {
    color: var(--text-dim);
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: help;
}

#btn-copy-link {
    margin-left: auto;
}

/* Quand l'option son est visible (organisateur), elle occupe déjà le "auto" de droite. */
.sound-option:not(.hidden) ~ #btn-copy-link {
    margin-left: 0;
}

.meeting-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-width, 250px);
    flex-shrink: 0;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Poignée de redimensionnement de la colonne latérale */
.sidebar-resizer {
    flex: none;
    width: 6px;
    background: var(--surface-2);
    cursor: col-resize;
    transition: background 120ms ease;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
    background: var(--accent);
}

.sidebar-scroll {
    flex: 0 0 auto;
    max-height: 55%;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar h2 {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

/* Colonne latérale repliable (accordéon) */
.sidebar-toggle {
    position: relative;
    padding: 0.3rem 0.6rem;
    line-height: 1;
}

.sidebar-collapsed .sidebar-toggle-icon {
    display: inline-block;
    transform: rotate(180deg);
}

.sidebar-badge {
    position: absolute;
    top: -0.45rem;
    right: -0.45rem;
    min-width: 1.1rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1.1rem;
    text-align: center;
}

.sidebar-collapsed .sidebar,
.sidebar-collapsed .sidebar-resizer {
    display: none;
}

/* Fenêtres d'arrivée en salle d'attente : uniquement colonne repliée */
.admission-toasts {
    display: none;
    position: fixed;
    top: 3.6rem;
    left: 0.75rem;
    z-index: 50;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(22rem, calc(100vw - 1.5rem));
}

.sidebar-collapsed .admission-toasts {
    display: flex;
}

.admission-toast {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    animation: toast-in 180ms ease-out;
}

.admission-toast-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.admission-toast-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.admission-toast .admission-actions {
    display: flex;
    gap: 0.4rem;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* Panneau d'admissions (organisateur) */

.admissions {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.admissions h2 {
    margin-bottom: 0.5rem;
    color: #bfdbfe;
}

#admissions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admission {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.admission-name {
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admission-actions {
    display: flex;
    gap: 0.4rem;
}

#participants-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.participant {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    transition: border-color 120ms ease;
}

.participant-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.participant-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.participant.speaking {
    border-color: var(--speaking);
}

.participant.muted .participant-name::after {
    content: " 🔇";
}

/* Liaison WebRTC : statut affiché sous le nom.
   « en recherche » = discret (gris) ; « échec » = cadre rouge + texte rouge. */
.participant.conn-failed {
    border-color: var(--danger);
}

.conn-status {
    display: none;
    font-size: 0.75rem;
}

.participant.conn-pending .conn-status {
    display: block;
    color: var(--text-dim);
    font-style: italic;
}

.participant.conn-failed .conn-status {
    display: block;
    color: #fca5a5;
}

.speaking-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 120ms ease;
}

.participant.speaking .speaking-dot {
    background: var(--speaking);
    box-shadow: 0 0 8px var(--speaking);
}

.participant-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.participant-actions .kick,
.participant-actions .mute-toggle {
    flex: 1 1 auto;
    padding: 0.28rem 0.5rem;
    font-size: 0.78rem;
}

/* Chat public */

.chat-panel {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1rem;
    border-top: 1px solid var(--surface-2);
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    margin: 0 0 0.6rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-message {
    background: var(--surface-2);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    line-height: 1.35;
    overflow-wrap: break-word;
}

.chat-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.12rem;
}

.chat-author {
    color: var(--text-dim);
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-time {
    flex: none;
    color: var(--text-dim);
    font-size: 0.68rem;
    opacity: 0.85;
}

.chat-message.own {
    background: rgba(59, 130, 246, 0.18);
}

.chat-message.system {
    background: transparent;
    color: var(--text-dim);
    font-style: italic;
    padding: 0.1rem 0;
}

.chat-form {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
}

.chat-form input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
}

.chat-form button {
    flex-shrink: 0;
}

.chat-form .chat-send {
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.3rem 0.6rem;
}

/* Zone centrale : écran partagé */

.screen-area {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b0e12;
    min-width: 0;
}

#screen-placeholder {
    text-align: center;
    color: var(--text-dim);
}

#screen-video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Fenêtres Biloba diffusées par un agent de prise en main : même cadrage que la vidéo. */
#agent-screen {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Contrôle accordé : la souris et le clavier sur l'image partent vers Biloba. */
#agent-screen.controlling {
    outline: 3px solid #F39200;
    outline-offset: -3px;
    cursor: default;
}

#agent-screen.controlling:focus {
    outline-color: #BFCE01;
}

.screen-owner {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}

/* Mention « sans micro » dans l'en-tête : entrée en écoute seule (discret, non bloquant) */
.no-mic-note {
    color: #F39200;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: default;
}

/* Problème de micro en réunion : bandeau pleine largeur, impossible à rater */
.mic-alert {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: #7c2d12;
    border-bottom: 2px solid #F39200;
    font-weight: 600;
}

.mic-alert > span {
    flex: 1;
    min-width: 14rem;
}

/* Même avertissement en salle d'attente */
.mic-warning {
    margin: 1rem 0 0.5rem;
    padding: 0.6rem 0.9rem;
    background: #7c2d12;
    border: 1px solid #F39200;
    border-radius: 6px;
    text-align: left;
}

.mic-warning p {
    margin: 0 0 0.5rem;
}

#waiting-screen .card > button {
    margin-top: 0.6rem;
}

/* Réglages audio : fenêtre modale au-dessus de tout */
.audio-dialog {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.65);
}

.audio-dialog .card {
    width: 100%;
    max-width: 440px;
    max-height: 100%;
    overflow-y: auto;
}

.audio-dialog select {
    width: 100%;
}

.audio-dialog button {
    margin-top: 0.8rem;
}

.audio-dialog .card.diag-card {
    max-width: 640px;
}

.diag-list {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.diag-list li {
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.9rem;
}

.diag-list .diag-time {
    color: var(--text-dim);
    margin-right: 0.5rem;
}

.diag-list .diag-detail {
    display: block;
    color: var(--text-dim);
    font-size: 0.82rem;
}

.diag-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

.level-meter {
    height: 10px;
    margin-top: 0.6rem;
    background: var(--surface-2);
    border-radius: 5px;
    overflow: hidden;
}

.level-bar {
    width: 0;
    height: 100%;
    background: var(--speaking);
    transition: width 80ms linear;
}

/* Bandeau « Activer le son » : lecture automatique bloquée par le navigateur (Firefox…) */
.audio-unlock {
    position: fixed;
    top: 4.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    background: var(--accent);
    font-weight: 600;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}

/* Barre de contrôles */

.controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.9rem;
    background: var(--surface);
}

button {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    transition: background 120ms ease;
}

button:hover:not(:disabled) {
    background: var(--accent-hover);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button.small {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

button.ghost {
    background: transparent;
    outline: 1px solid var(--accent);
}

button.ghost:hover:not(:disabled) {
    background: var(--surface-2);
}

button.active {
    background: var(--surface-2);
    outline: 1px solid var(--accent);
}

button.danger {
    background: var(--danger);
}

button.danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
    .meeting-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
    }

    .sidebar-resizer {
        display: none;
    }

    /* Participants empilés verticalement (pleine largeur). */
    #participants-list {
        flex-direction: column;
    }

    .controls {
        flex-wrap: wrap;
    }

    /* Sur mobile : pas de partage d'écran (ni de capture, qui en dépend).
       Seuls restent « Couper le micro » et « Quitter ». */
    #btn-share,
    #btn-capture {
        display: none !important;
    }
}
