:root {
    --primary: #00aaff;
    --secondary: #66ccff;
    --bg-dark: #0a1c2b;
    --text-light: #e6f3ff;
    --local-video-bg: #1e3a5f;
    --remote-video-bg: #0a1c2b;
    --screen-share-bg: #3a2a4e;
    --ice-blue: #b3e5fc;
    --ice-glow: #4fc3f7;
}

/* Conteneur Principal */
.connectsphere-container {
    display: flex !important;
    flex-direction: column !important; /* Mobile : Vertical par défaut */
    gap: 20px;
    padding: 15px; /* Plus petit sur mobile */
    background: var(--bg-dark);
    width: 100% !important; /* Reste dans son parent */
    max-width: 100% !important;
    position: relative;
    box-sizing: border-box;
    z-index: 10; /* Beaucoup plus bas pour laisser passer le menu WP */
}

.connectsphere-main {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Réduit un peu le gap pour gagner de la place */
    flex: 1 1 auto; /* Force l'étirement */
    width: 100%;
    min-width: 0; /* Empêche le chat de tout casser */
}

/* Grille Vidéo */
.connectsphere-video-grid {
    position: relative;
    width: 100%;
    height: 55vh; /* On réduit la hauteur pour que tout tienne sans scroller */
    overflow: hidden;
    background: var(--bg-dark);
}

.connectsphere-video-wrapper {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 15px var(--ice-glow);
    cursor: move;
    animation: float 6s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.connectsphere-video-wrapper:hover {
    box-shadow: 0 0 25px var(--ice-blue);
}

.connectsphere-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.connectsphere-video-wrapper.local-video {
    border: 2px solid var(--primary);
    background: var(--local-video-bg);
}

.connectsphere-video-wrapper.remote-video {
    border: 2px solid var(--secondary);
    background: var(--remote-video-bg);
}

.connectsphere-video-wrapper.screen-share {
    border: 2px dashed var(--secondary);
    background: var(--screen-share-bg);
}

.connectsphere-video-wrapper::after {
    content: attr(data-label);
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-light);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 10;
}

/* Chat Public */
.connectsphere-chat {
    height: 200px; /* <--- Réduit à 200px au lieu de 300px */
    overflow-y: auto;
    background: rgba(10, 28, 43, 0.9);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 10px;
    position: relative;
    display: none;
    color: var(--text-light);
}

.connectsphere-chat.active {
    display: block;
}

.connectsphere-chat-messages {
    margin-bottom: 10px;
}

.connectsphere-message {
    margin: 5px 0;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: var(--text-light);
    font-size: 14px;
}

.connectsphere-message.public .username {
    color: var(--primary);
    font-weight: bold;
}

.connectsphere-message.private .username {
    color: var(--secondary);
    font-weight: bold;
}

.connectsphere-message .timestamp {
    color: var(--ice-blue);
    font-size: 12px;
    margin-left: 5px;
}

.connectsphere-chat #chat-input,
.connectsphere-chat-defaut {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--primary);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 14px;
}

.connectsphere-chat #chat-input::placeholder {
    color: var(--ice-blue);
    opacity: 0.7;
}

.connectsphere-chat #chat-input:focus {
    outline: none;
    box-shadow: 0 0 8px var(--ice-glow);
}

/* Participants */
.connectsphere-participants {
    width: 250px;
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-light);
    display: none;
}

.connectsphere-participants.active {
    display: block;
}

.connectsphere-participants h3 {
    margin-top: 0;
}

.connectsphere-participants ul {
    list-style: none;
    padding: 0;
}

.connectsphere-participants li {
    padding: 5px 0;
    cursor: pointer;
}

.connectsphere-participants li:hover {
    color: var(--primary);
}

.connectsphere-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    background: rgba(10, 28, 43, 0.98);
    border-top: 1px solid var(--primary);
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap; /* <--- CHANGEMENT ICI : Autorise le retour à la ligne */
}

/* Ligne des Actions (Audio, Vidéo, Écran) - TOUT DROIT */
.connectsphere-control-actions {
    display: flex;
    flex-direction: row; /* Force l'alignement horizontal */
    gap: 8px;            /* Un peu moins d'espace pour que ça rentre */
    justify-content: flex-end; /* Colle les boutons à droite de la barre */
    flex-wrap: nowrap;   /* INTERDIT de sauter à la ligne */
}

.connectsphere-controls button {
    min-width: 120px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--text-light);
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Boutons de connexion (plus voyants) */
#join-room, #create-room {
    background: var(--primary);
    color: #fff;
    border: none;
    min-width: 100px;
}

.connectsphere-controls button:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--ice-glow);
    transform: translateY(-2px);
}

/* Ligne des Réglages (Inputs et Pseudo) - FORCE L'HORIZONTAL */
.connectsphere-connection-settings {
    display: flex;
    flex-direction: row; /* Aligne tout sur une ligne */
    gap: 8px;            /* Espace réduit entre les éléments */
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 15px;   /* Moins de hauteur */
    border-radius: 30px;
    align-items: center;
    flex-wrap: nowrap;   /* INTERDIT de sauter à la ligne */
    justify-content: flex-start;
}

.connectsphere-controls input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 170, 255, 0.3);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: 20px;
    outline: none;
    font-size: 13px;
    width: 130px;
}

.connectsphere-controls p#user-display {
    font-size: 12px;
    color: var(--ice-blue);
    margin: 0;
    font-weight: normal;
}

/* Chat Privé (Popup) */
.connectsphere-private-chat {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-dark);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 15px;
    width: 400px;
    max-height: 500px;
    overflow: hidden;
    color: var(--text-light);
    z-index: 1001;
    box-shadow: 0 0 15px var(--ice-glow);
    animation: fadeIn 0.5s ease;
}

.connectsphere-private-chat h3 {
    margin: 0 0 10px;
    color: var(--ice-blue);
    text-align: center;
}

.connectsphere-private-chat-messages {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.connectsphere-private-chat input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--primary);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 14px;
}

.connectsphere-private-chat button {
    background: var(--primary);
    color: var(--text-light);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Éléments Marketing (Cachés temporairement) */
.connectsphere-popup,
.connectsphere-banner,
.connectsphere-toast {
    display: none;
}

/* Animations */
@keyframes slideIn {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(100px); opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

/* --- Journal d'Activité Central (Look Terminal) --- */
.connectsphere-status-ticker {
    flex: 1;
    margin: 0 20px;
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.4);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #00ffcc; /* Vert Cyber */
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
    font-weight: bold;
    text-transform: uppercase;
    
    display: flex;
    align-items: center;
    overflow: hidden; /* Important pour cacher le texte qui défile */
    position: relative;
    height: 30px; /* Fixe la hauteur pour l'alignement */
    transition: opacity 0.2s ease-in-out;
}

/* Animation du texte à l'intérieur */
.connectsphere-status-ticker span {
    white-space: nowrap;
    position: absolute;
    animation: scroll-text 12s linear infinite;
}

@keyframes scroll-text {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* Empêche les boutons de s'écraser */
.connectsphere-connection-settings, 
.connectsphere-control-actions {
    flex-shrink: 0;
}

/* --- ADAPTATIONS RESPONSIVE --- */

/* Écrans Larges (Desktop) */
@media (min-width: 1024px) {
    .connectsphere-container {
        flex-direction: row !important; /* Horizontal sur PC */
        width: 100vw !important;
        max-width: 100vw !important;
        left: 50%;
        margin-left: -50vw !important;
        padding: 30px;
    }
}

/* Écrans Mobiles (Tablettes et Téléphones) */
@media (max-width: 1023px) {
    .connectsphere-video-grid {
        height: 40vh !important; /* On réduit la vidéo pour voir le chat/boutons */
    }

    .connectsphere-connection-settings, 
    .connectsphere-control-actions {
        width: 100% !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        background: transparent !important;
    }

    .connectsphere-status-ticker {
        width: 100%;
        margin: 10px 0 !important;
        order: -1; /* Place le log au dessus des boutons sur mobile */
    }

    .connectsphere-controls button {
        flex: 1; /* Les boutons prennent la largeur disponible */
        min-width: 100px;
        font-size: 10px;
    }

    /* FIX MENU WORDPRESS : On s'assure que le header du thème est au dessus */
    .wp-site-blocks header {
        position: relative;
        z-index: 9999 !important;
    }
}
