.page {
    display: none;
}

.page.active {
    display: block;
}

/* --- PAGE MENU PRINCIPAL --- */

.menu-title {
    text-align: center;
    margin: 0;
    padding: 10px;
    border-bottom: 1px solid white; /* ← la ligne blanche */
    font-size: 2.2rem;
}

.menu-container {
    display: flex;
    flex-direction: row; /* ← AJOUT ESSENTIEL */
    gap: 10px;
    margin-top: 20px;
    height: 100%; /* ← pour que les colonnes puissent se partager l’espace */
}

.menu-column {
    flex: 1; /* ← chaque colonne prend 50% */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-items: center; /* ← centre tout le contenu horizontalement */
    width: 100%; /* ← garde la liste pleine largeur */
}

.menu-column:first-child {
    border-right: 1px solid white;
    padding-right: 10px; /* espace pour respirer */
    margin-right: 10px;  /* espace entre la ligne et l’autre colonne */
}

.menu-column h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4rem;
    text-align: center;
}

.menu-list {
    flex: 1; /* ← la liste remplit l’espace restant */
    flex-direction: column; /* ← vertical */
    gap: 10px;
    overflow-y: auto;
}

.menu-item {
    background: #333;
    border: none;
    padding: 12px;
    border-radius: 8px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    color: white;
    transition: 0.15s;
}

.menu-item:hover {
    background: #444;
}

.menu-empty {
    color: #888;
    text-align: center;
    padding: 20px 0;
}


/* --- STYLE GLOBAL --- */
body {
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #111;
    color: white;
    font-family: Arial, sans-serif;
    text-align: center;
}

/* Colonne gauche */
#sidebar {
    padding: 20px;
    width: 350px;
    min-width: 250px;
    max-width: 500px;
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#sidebar-resizer {
    width: 6px;
    cursor: ew-resize;
    background: #333;
    user-select: none;
}

#sidebar-resizer:hover {
    background: #555;
}

#sidebar-footer {
    padding: 6px 10px;
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 20px; /* monte le bouton */
}

#server-plus-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #2f2f2f;
    color: white;
    font-size: 20px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s, transform 0.1s;
}

#server-plus-btn:hover {
    background: #3a3a3a;
    transform: scale(1.05);
}

#server-plus-menu {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 6px;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#server-plus-menu.hidden {
    display: none;
}

#server-plus-menu .menu-item {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
}

#server-plus-menu .menu-item:hover {
    background: #2a2a2a;
}

#settings-btn {
    padding: 4px 8px; /* ← réduit fortement la hauteur */
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.8;
    border-radius: 4px;
}

#settings-btn:hover {
    opacity: 1;
    background: #2a2a2a;
    border-radius: 6px;
}

/* Zone de contenu */
#content {
    flex: 1;
    height: 100vh;
    background-color: #121212;
    overflow-y: auto;
    padding: 20px;
}

#main {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
}

#videos {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    place-items: center;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 70px; /* espace autour des caméras */
    box-sizing: border-box; /* IMPORTANT pour éviter que ça déborde */
}

button {
    padding: 10px 20px;
    margin: 5px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #333;
    color: white;
}

/* La vidéo */
.call-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    display: block;
    min-height: 0;
}

/* Caméra OFF */
.call-video.off {
    border-color: #FF7C7C !important;
}

/* Micro OFF */
.video-container.mic-off .call-video {
    border-color: #ff3b3b !important;
}

/* Glow vert quand tu parles */
.video-container .call-video.speaking {
    border-color: #7CFF7C !important;
    box-shadow: 0 0 15px #7CFF7C, 0 0 30px rgba(124, 255, 124, 0.6);
}

.video-container {
    position: relative;
    aspect-ratio: 16 / 9;
    width: fit-content;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;

    background: #111;
    overflow: hidden;

    display: flex;
    justify-content: center;
    align-items: center;

    border-radius: 10px;
    border: 4px solid #CCCCCC;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Glow autour du cadre */
.video-container.speaking {
    border-color: #7CFF7C !important;
    box-shadow: 0 0 15px #7CFF7C, 0 0 30px rgba(124, 255, 124, 0.6);
}

.avatar {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    object-fit: cover;
    display: none;
    z-index: 20;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Quand la caméra est OFF → on montre l’avatar */
.video-container.cam-off .avatar {
    display: block;
}

/* Et on cache la vidéo */
.video-container.cam-off .call-video {
    opacity: 0;
}

.camera-off-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    border-radius: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-container.cam-off .camera-off-overlay {
    opacity: 1;
}

.video-container.cam-off .avatar-placeholder {
    width: 100%;
    height: 100%;
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2rem;
}

.video-container.mic-off.speaking {
    border-color: #ff3b3b !important;
    box-shadow: none !important;
}

.video-container.mic-off {
    border: 4px solid #ff3b3b !important;
}

#controls {
    flex: 0 0 auto;
    padding-bottom: 30px;   /* espace visible sous les boutons */
    margin-bottom: 0;       /* évite les conflits */
    flex-shrink: 0;         /* empêche les boutons d'être écrasés */
}

#controls button {
    font-size: 1.2vw;
    padding: 10px 20px;
}

.placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    color: #aaa;
    font-size: 18px;
    font-weight: bold;
    z-index: 2;
}

/* --- APP WRAPPER AVEC SCALE AUTOMATIQUE --- */
#app {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Titre en haut, vidéos au centre, boutons en bas */
    margin: 0 auto;
    max-width: 1400px;
    width: 100%;


    transform: scale(var(--app-scale));
    transform-origin: top center;

    height: 100vh;        /* ← force l'app à remplir l'écran */
    overflow: visible;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Le titre s’adapte */
h1 {
    flex: 0 0 auto;
    padding-top: 50px;   /* espace avec le haut */
    margin-top: 0;       /* évite les conflits */
    flex-shrink: 0;      /* empêche le titre d'être écrasé */
}

.video-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-wrapper.speaking {
    border: 4px solid #7CFF7C;
    box-shadow: 0 0 15px #7CFF7C, 0 0 30px rgba(124, 255, 124, 0.6);
    border-radius: 10px;
}

/* --- PAGE SERVEUR VIEW --- */

.server-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 30px;
}

.server-column {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 12px;
    width: 300px;
    box-shadow: 0 0 10px #000;
}

.server-column h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3rem;
    text-align: center;
}

#server-list {
    display: flex;
    flex-direction: column; /* ← empile les serveurs */
    gap: 10px;              /* ← espace entre les serveurs */
}

.server-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Menu clic droit */
#server-context-menu {
    position: absolute;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 6px 0;
    width: 160px;
    z-index: 9999;
}

#server-context-menu.hidden {
    display: none;
}

#server-context-menu div {
    padding: 8px 12px;
    cursor: pointer;
}

#server-context-menu div:hover {
    background: #2a2a2a;
}

/* Popup confirmation */
#delete-server-confirm {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

#delete-server-confirm.hidden {
    display: none;
}

.confirm-box {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    text-align: center;
}

.confirm-box button {
    margin: 10px;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#confirm-delete-server {
    background: #d9534f;
    color: white;
}

#cancel-delete-server {
    background: #444;
    color: white;
}

.server-empty {
    color: #888;
    text-align: center;
    padding: 20px 0;
}

.back-btn {
    margin-top: 30px;
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.special-btn {
    background-color: #5865F2;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 8px;
    width: 100%;
    text-align: center;
}

.special-btn:hover {
    background-color: #4752C4;
}

.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.popup.hidden {
    display: none;
}

.popup-content {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    text-align: center;
}

.popup-content input {
    width: 90%;
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
    border: none;
}

.popup-buttons {
    display: flex;
    justify-content: space-between;
}
