.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 {
    position: relative;
    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: transparent;
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    z-index: 9999;
    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: 45px;
    height: 45px;
    border-radius: 50%;
    background: #2f3136;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px auto; /* centre horizontalement */
    cursor: pointer;
    transition: background 0.2s;
    font-size: 28px; /* augmente la taille du + */
    color: white;    /* assure qu'il est bien visible */
    line-height: 0;  /* évite qu'il soit décalé verticalement */
}

#server-plus-btn:hover {
    background: #3a3d42;
}

#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-item {
    display: flex;
    justify-content: center;
    align-items: center;
    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;
    pointer-events: auto;
    z-index: 999;
}

.popup.hidden {
    display: none !important;
    pointer-events: none !important;
}

.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;
}

.auth-container {
    width: 350px;
    margin: 100px auto;
    background: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.auth-container input {
    width: 90%;
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
    border: none;
}

.auth-container button {
    width: 100%;
    padding: 10px;
    background: #5865F2;
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.auth-container button:hover {
    background: #4752C4;
}

#auth-forms span {
    color: #5865F2;
    cursor: pointer;
}

#user-icon {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 60px;
    height: 60px;
    background-color: #4a4a4a;
    border-radius: 40px;
    cursor: pointer;

    padding: 5px; /* marge interne pour placer l’image */

    transition:
            width 0.35s ease,
            height 0.35s ease,
            border-radius 0.35s ease,
            background-color 0.35s ease,
            transform 0.15s ease;

    transform-origin: top right;
    user-select: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: hidden; /* <-- le texte reste DANS la bulle */
}

#user-icon.active {
    width: 320px;
    height: 300px;
    border-radius: 56px;
    background-color: #6a6a6a;
    transform: none;
}

/* Animation au survol */
#user-icon:hover {
    transform: scale(1.1);
    background-color: #6a6a6a;
}

/* Quand la bulle est ouverte → pas de hover */
#user-icon.active:hover {
    transform: none;
}

#user-icon.active #user-avatar {
    width: 110px;
    height: 110px;
}

#user-avatar {
    position: absolute;   /* <-- LA MAGIE */
    top: 5px;
    left: 5px;

    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;

    transition: width 0.3s ease, height 0.3s ease;
}

#username {
    position: absolute;
    left: 140px;
    top: 50px;

    width: 150px;
    text-align: center;

    color: white;
    font-size: 22px;
    font-weight: 600;

    opacity: 1; /* le texte est déjà là */
    pointer-events: none;
    white-space: nowrap;

    overflow: hidden; /* masque */
    clip-path: inset(0 100% 0 0); /* caché de droite à gauche */

    transition: clip-path 0.35s ease;
}

#user-icon.active #username {
    clip-path: inset(0 0 0 0); /* dévoile tout */
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 150px; /* même largeur que #username */
    }
}

#user-buttons {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    gap: 15px;

    opacity: 0;
    pointer-events: none;

    transition: opacity 0.35s ease;
}

.user-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.login-btn {
    background-color: #ffffff;
    color: #333;
}

.signup-btn {
    background-color: #4a90e2;
    color: white;
}

.user-btn:hover {
    transform: scale(1.05);
}

#user-icon.active #user-buttons {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.10s; /* après l’ouverture de la bulle */
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    background: #fff;
    color: #222;
    padding: 25px;
    border-radius: 12px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content input {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.modal-btn {
    padding: 10px;
    border: none;
    background: #4a90e2;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 26px;
    cursor: pointer;
    color: #555;
    transition: color 0.2s ease, transform 0.2s ease;
}

.close-modal:hover {
    color: #000;
    transform: scale(1.2);
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-field {
    width: 100%;
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    fill: #555;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-password:hover {
    fill: #000;
}

/* Par défaut : œil barré caché */
.eye-hidden {
    display: none;
}

.error-msg {
    color: #ff4d4d;
    font-size: 14px;
    margin-top: 5px;
}

@keyframes shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: shake 0.3s ease;
}