/* ==========================================================================
   Voice Chat Widget - Style Discord-like
   Widget flottant en bas à gauche, avec panneau déroulant vers le haut.
   ========================================================================== */

/* ---------- Widget Container ---------- */
.voice-widget {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

/* ---------- Toggle Button ---------- */
.voice-widget-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #2b2d31;
    color: #b5bac1;
    border-radius: 24px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.voice-widget-toggle:hover {
    background: #35373c;
    color: #fff;
}

.voice-widget-toggle.voice-active {
    background: #248046;
    color: #fff;
}

.voice-widget-toggle.voice-active:hover {
    background: #1a6334;
}

.voice-toggle-label {
    font-size: 13px;
    font-weight: 500;
}

.voice-toggle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #5865f2;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
}

/* ---------- Panel ---------- */
.voice-widget-panel {
    position: absolute;
    bottom: 48px;
    left: 0;
    width: 300px;
    max-height: 450px;
    background: #2b2d31;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: voice-slide-up 0.2s ease;
}

@keyframes voice-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Panel Header ---------- */
.voice-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #1e1f22;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.voice-panel-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.voice-panel-close {
    background: none;
    border: none;
    color: #b5bac1;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}

.voice-panel-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ---------- Panel Body ---------- */
.voice-panel-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    color: #b5bac1;
}

/* ---------- Status Message ---------- */
.voice-status-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    justify-content: center;
    color: #80848e;
    font-size: 13px;
}

.voice-empty-msg {
    text-align: center;
    padding: 12px;
    color: #80848e;
    font-size: 12px;
}

/* ---------- Create Room ---------- */
.voice-create-room {
    margin-bottom: 12px;
}

.voice-input-group {
    display: flex;
    gap: 6px;
}

.voice-input {
    flex: 1;
    padding: 8px 10px;
    background: #1e1f22;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.voice-input:focus {
    border-color: #5865f2;
}

.voice-input::placeholder {
    color: #80848e;
}

/* ---------- Buttons ---------- */
.voice-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.voice-btn-primary {
    background: #5865f2;
    color: #fff;
}

.voice-btn-primary:hover {
    background: #4752c4;
}

.voice-btn-secondary {
    background: #4e5058;
    color: #fff;
}

.voice-btn-secondary:hover {
    background: #6d6f78;
}

.voice-btn-danger {
    background: #da373c;
    color: #fff;
}

.voice-btn-danger:hover {
    background: #a12828;
}

.voice-btn-icon {
    background: none;
    border: none;
    color: #b5bac1;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    font-size: 14px;
}

.voice-btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ---------- Rooms List ---------- */
.voice-rooms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #80848e;
}

.voice-rooms-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.voice-room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.voice-room-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.voice-room-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b5bac1;
    font-size: 13px;
    min-width: 0;
}

.voice-room-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-room-item-count {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #80848e;
    font-size: 12px;
    flex-shrink: 0;
}

/* ---------- Room Header (in room) ---------- */
.voice-room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
}

.voice-room-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.voice-room-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-room-code {
    font-family: monospace;
    font-size: 11px;
    color: #80848e;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ---------- Participants ---------- */
.voice-participants-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 250px;
    overflow-y: auto;
}

.voice-participant,
.voice-self-participant {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.voice-participant:hover {
    background: rgba(255, 255, 255, 0.04);
}

.voice-self-participant {
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 4px;
}

/* ---------- Participant Avatar + Speaking Indicator ---------- */
.voice-participant-avatar {
    position: relative;
    font-size: 22px;
    color: #80848e;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-speaking-indicator {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
    pointer-events: none;
}

/* Animation "speaking" : bordure verte pulsante */
.voice-participant.speaking .voice-speaking-indicator,
.voice-self-participant.speaking .voice-speaking-indicator {
    border-color: #23a559;
    animation: voice-speaking-pulse 1.2s ease-in-out infinite;
}

.voice-participant.speaking .voice-participant-avatar,
.voice-self-participant.speaking .voice-participant-avatar {
    color: #23a559;
}

@keyframes voice-speaking-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(35, 165, 89, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(35, 165, 89, 0);
    }
}

/* Participant muted */
.voice-participant.muted .voice-participant-avatar {
    opacity: 0.5;
}

/* ---------- Participant Info ---------- */
.voice-participant-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.voice-participant-name {
    font-size: 13px;
    color: #dbdee1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-self-participant .voice-participant-name {
    font-weight: 600;
}

/* ---------- Volume Slider ---------- */
.voice-participant-volume {
    flex-shrink: 0;
    width: 60px;
}

.voice-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #4e5058;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.voice-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    transition: transform 0.1s;
}

.voice-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.voice-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

/* ---------- Controls ---------- */
.voice-controls {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: center;
}

.voice-controls .voice-btn {
    flex: 1;
    justify-content: center;
    padding: 10px;
    border-radius: 10px;
}

/* ---------- Error ---------- */
.voice-error {
    padding: 8px 12px;
    background: #da373c;
    color: #fff;
    font-size: 12px;
    text-align: center;
    border-radius: 0 0 12px 12px;
}

/* ---------- Permission Dialog ---------- */
.voice-permission-dialog {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    text-align: center;
}

.voice-permission-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}

.voice-permission-icon-prompt {
    background: rgba(88, 101, 242, 0.15);
    color: #5865f2;
}

.voice-permission-icon-denied {
    background: rgba(218, 55, 60, 0.15);
    color: #da373c;
}

.voice-permission-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px 0;
}

.voice-permission-text {
    font-size: 12px;
    color: #b5bac1;
    line-height: 1.5;
    margin: 0 0 6px 0;
}

.voice-permission-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    background: rgba(88, 101, 242, 0.1);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 4px;
    color: #cdd0f5;
}

.voice-permission-hint i {
    flex-shrink: 0;
    margin-top: 1px;
    color: #5865f2;
}

.voice-permission-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
}

.voice-btn-lg {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 10px;
}

.voice-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #80848e;
    cursor: pointer;
    font-size: 12px;
    border-radius: 8px;
    transition: all 0.15s;
}

.voice-btn-ghost:hover {
    color: #b5bac1;
    background: rgba(255, 255, 255, 0.06);
}

.voice-permission-instructions {
    text-align: left;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 8px;
}

.voice-permission-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: #dbdee1;
    margin: 0 0 8px 0;
}

.voice-permission-steps {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: #b5bac1;
    line-height: 1.6;
}

.voice-permission-steps li {
    margin-bottom: 4px;
}

.voice-permission-steps li:last-child {
    margin-bottom: 0;
}

.voice-permission-steps strong {
    color: #dbdee1;
}

.voice-permission-steps i {
    font-size: 11px;
    vertical-align: middle;
}

/* ---------- Scrollbar ---------- */
.voice-panel-body::-webkit-scrollbar,
.voice-participants-list::-webkit-scrollbar {
    width: 6px;
}

.voice-panel-body::-webkit-scrollbar-track,
.voice-participants-list::-webkit-scrollbar-track {
    background: transparent;
}

.voice-panel-body::-webkit-scrollbar-thumb,
.voice-participants-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.voice-panel-body::-webkit-scrollbar-thumb:hover,
.voice-participants-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---------- Responsive ---------- */
@media (max-width: 576px) {
    .voice-widget {
        bottom: 10px;
        left: 10px;
    }

    .voice-widget-panel {
        width: calc(100vw - 20px);
        max-height: 60vh;
    }

    .voice-toggle-label {
        display: none;
    }
}