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

/* --- Unread badge & message highlight (previously missing) --- */
.unread-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    padding: 0 3px;
    margin-left: 6px;
    vertical-align: middle;
}

@keyframes highlight-pulse {
    0%, 100% { background: transparent; }
    50% { background: rgba(0, 170, 255, 0.2); }
}

.new-message-highlight {
    animation: highlight-pulse 1s ease 3;
    border-radius: 4px;
}

/* --- Disabled button state --- */
.connectsphere-controls button.disabled {
    opacity: 0.45;
    border-color: rgba(0, 170, 255, 0.3);
    cursor: not-allowed;
}

.connectsphere-controls button.disabled:hover {
    background: transparent;
    color: var(--text-light);
    box-shadow: none;
    transform: none;
}

/* --- Participant counter badge --- */
.cs-participant-count {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    padding: 0 5px;
    margin-left: 8px;
    vertical-align: middle;
}

/* --- Status row : pleine largeur sous les deux groupes de boutons --- */
.cs-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    order: 10;
    min-width: 0;
}

.cs-status-row .connectsphere-status-ticker {
    flex: 1;
    margin: 0;
}

/* --- Connection quality indicator --- */
.cs-quality {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 22px;
    padding: 0 4px;
    cursor: default;
    flex-shrink: 0;
}

.cs-quality-bar {
    width: 6px;
    border-radius: 2px 2px 0 0;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.4s ease;
}

.cs-quality-bar.cs-bar-1 { height: 35%; }
.cs-quality-bar.cs-bar-2 { height: 62%; }
.cs-quality-bar.cs-bar-3 { height: 90%; }

.cs-quality[data-level="0"] .cs-quality-bar { background: rgba(255, 255, 255, 0.1); }
.cs-quality[data-level="1"] .cs-quality-bar.active { background: #ff4d4d; }
.cs-quality[data-level="2"] .cs-quality-bar.active { background: #ffaa00; }
.cs-quality[data-level="3"] .cs-quality-bar.active { background: #44cc66; }

/* --- Leave button --- */
#leave-room {
    background: #b71c1c;
    border-color: #b71c1c;
    color: #fff !important;
}

#leave-room:hover {
    background: #d32f2f !important;
    border-color: #d32f2f !important;
    box-shadow: 0 0 14px rgba(183, 28, 28, 0.55) !important;
    color: #fff !important;
    transform: translateY(-2px);
}

.connectsphere-container[data-theme="light"] #leave-room {
    background: #c62828;
    border-color: #c62828;
}

.connectsphere-container[data-theme="light"] #leave-room:hover {
    background: #e53935 !important;
    border-color: #e53935 !important;
    box-shadow: 0 0 14px rgba(198, 40, 40, 0.35) !important;
}

/* --- Raise hand button & video overlay --- */
#raise-hand.hand-raised {
    background: #ffaa00;
    border-color: #ffaa00;
    color: #000;
    animation: pulse 1.5s ease-in-out infinite;
}

.connectsphere-video-wrapper.hand-raised::before {
    content: '✋';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 20px;
    z-index: 20;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.8));
}

/* ============================================================
   LIGHT THEME
   Applied when data-theme="light" on .connectsphere-container
   ============================================================ */
.connectsphere-container[data-theme="light"] {
    --primary: #0077cc;
    --secondary: #005fa3;
    --bg-dark: #f5f9ff;
    --text-light: #0d1f30;
    --local-video-bg: #ddeeff;
    --remote-video-bg: #e8f3ff;
    --screen-share-bg: #ede8f7;
    --ice-blue: #0077cc;
    --ice-glow: #3399dd;
    background: var(--bg-dark);
}

.connectsphere-container[data-theme="light"] .connectsphere-video-grid {
    background: #e2eef9;
    border-radius: 8px;
}

.connectsphere-container[data-theme="light"] .connectsphere-video-wrapper {
    box-shadow: 0 0 12px rgba(0, 119, 204, 0.25);
}

.connectsphere-container[data-theme="light"] .connectsphere-video-wrapper:hover {
    box-shadow: 0 0 22px rgba(0, 119, 204, 0.45);
}

.connectsphere-container[data-theme="light"] .connectsphere-chat {
    background: rgba(255, 255, 255, 0.97);
    border-color: var(--primary);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-message {
    background: rgba(0, 119, 204, 0.06);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-message.public .username {
    color: #005fa3;
}

.connectsphere-container[data-theme="light"] .connectsphere-message.private .username {
    color: #0077cc;
}

.connectsphere-container[data-theme="light"] .connectsphere-message .timestamp {
    color: #5a7a9a;
}

.connectsphere-container[data-theme="light"] .connectsphere-chat #chat-input {
    background: #fff;
    border-color: rgba(0, 119, 204, 0.4);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-chat #chat-input::placeholder {
    color: #7a9ab8;
    opacity: 1;
}

.connectsphere-container[data-theme="light"] .connectsphere-participants {
    background: #fff;
    border: 1px solid rgba(0, 119, 204, 0.2);
    border-radius: 8px;
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-participants li:hover {
    color: var(--primary);
}

.connectsphere-container[data-theme="light"] .connectsphere-controls {
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(0, 119, 204, 0.3);
}

.connectsphere-container[data-theme="light"] .connectsphere-controls button {
    border-color: var(--primary);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-controls button:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 119, 204, 0.35);
}

.connectsphere-container[data-theme="light"] #join-room,
.connectsphere-container[data-theme="light"] #create-room {
    background: var(--primary);
    color: #fff;
}

.connectsphere-container[data-theme="light"] .connectsphere-controls input {
    background: #fff;
    border-color: rgba(0, 119, 204, 0.3);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-controls p#user-display {
    color: #4a6a8a;
}

.connectsphere-container[data-theme="light"] .connectsphere-connection-settings {
    background: rgba(0, 119, 204, 0.06);
}

.connectsphere-container[data-theme="light"] .connectsphere-status-ticker {
    background: rgba(0, 119, 204, 0.08);
    border-left-color: var(--primary);
    color: #005fa3;
    text-shadow: none;
}

.connectsphere-container[data-theme="light"] .cs-quality[data-level="1"] .cs-quality-bar.active { background: #e53935; }
.connectsphere-container[data-theme="light"] .cs-quality[data-level="2"] .cs-quality-bar.active { background: #f57c00; }
.connectsphere-container[data-theme="light"] .cs-quality[data-level="3"] .cs-quality-bar.active { background: #2e7d32; }
.connectsphere-container[data-theme="light"] .cs-quality-bar { background: rgba(0, 0, 0, 0.12); }

.connectsphere-container[data-theme="light"] .connectsphere-private-chat {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 24px rgba(0, 119, 204, 0.18);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] .connectsphere-private-chat h3 {
    color: var(--primary);
}

.connectsphere-container[data-theme="light"] .connectsphere-private-chat-messages {
    background: rgba(0, 119, 204, 0.05);
}

.connectsphere-container[data-theme="light"] .connectsphere-private-chat input {
    background: #fff;
    border-color: rgba(0, 119, 204, 0.4);
    color: var(--text-light);
}

.connectsphere-container[data-theme="light"] #raise-hand.hand-raised {
    background: #e65100;
    border-color: #e65100;
    color: #fff;
}

.connectsphere-container[data-theme="light"] .cs-participant-count {
    background: var(--primary);
}
