/* ============================================
   VOICE ROOMS - Dark Modern Discord-Style UI
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1f2940;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #6c6f75;
    --accent-primary: #5865f2;
    --accent-green: #3ba55d;
    --accent-red: #ed4245;
    --accent-yellow: #faa61a;
    --speaking-glow: rgba(88, 101, 242, 0.6);
    --border-color: #2d2d3f;
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==================== APP LAYOUT ==================== */
.voice-app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================== SIDEBAR ==================== */
.voice-sidebar {
    width: 360px;
    min-width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

.sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 i {
    color: var(--accent-primary);
    font-size: 22px;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Sidebar Actions */
.sidebar-actions {
    padding: 16px 20px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.btn-create,
.btn-join,
.btn-refresh,
.btn-create-full,
.btn-join-full {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-family: inherit;
}

.btn-create {
    background: var(--accent-primary);
    color: white;
    flex: 1;
}

.btn-create:hover {
    background: #4752c4;
    transform: translateY(-1px);
}

.btn-join {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    flex: 1;
    border: 1px solid var(--border-color);
}

.btn-join:hover {
    background: var(--bg-hover);
}

.btn-refresh {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

.btn-refresh:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Room List */
.room-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.list-title {
    padding: 8px 20px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-badge {
    background: var(--accent-red);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

.room-card {
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
}

.room-card:hover {
    background: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.room-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent-green);
    flex-shrink: 0;
}

.room-card.private .room-card-icon {
    color: var(--accent-yellow);
}

.room-card-info {
    flex: 1;
    min-width: 0;
}

.room-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-card-meta i {
    font-size: 10px;
}

.room-card-lock {
    color: var(--accent-yellow);
    font-size: 12px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-footer i {
    margin-right: 6px;
    color: var(--accent-green);
}

/* ==================== MAIN AREA ==================== */
.voice-main {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-y: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
}

.empty-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 40px;
    color: var(--accent-primary);
}

.empty-state h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.empty-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-join-outline {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-join-outline:hover {
    background: var(--bg-hover);
}

/* Active Voice Room */
.voice-room-active {
    width: 100%;
    max-width: 800px;
    padding: 24px;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
}

.room-info h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.room-code-badge {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--accent-primary);
    font-weight: 600;
    letter-spacing: 1px;
}

.participant-count {
    margin-left: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.participant-count i {
    color: var(--accent-green);
    margin-right: 4px;
}

.room-controls-top {
    display: flex;
    gap: 8px;
}

.btn-control {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-family: inherit;
}

.btn-control:hover {
    background: var(--bg-hover);
}

.btn-control.muted {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.btn-leave {
    padding: 10px 20px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-family: inherit;
}

.btn-leave:hover {
    background: #c03537;
}

/* Participants Grid */
.participants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.participant-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
}

.participant-card:hover {
    border-color: var(--border-color);
}

.participant-card.speaking {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--speaking-glow);
    animation: speakPulse 0.5s infinite alternate;
}

@keyframes speakPulse {
    from { box-shadow: 0 0 10px var(--speaking-glow); }
    to { box-shadow: 0 0 30px var(--speaking-glow); }
}

.participant-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
}

.participant-card.speaking .participant-avatar {
    animation: avatarGlow 0.5s infinite alternate;
}

@keyframes avatarGlow {
    from { box-shadow: 0 0 15px var(--speaking-glow); }
    to { box-shadow: 0 0 35px var(--speaking-glow); }
}

.participant-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.participant-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.participant-status.muted {
    color: var(--accent-red);
}

.participant-status.speaking {
    color: var(--accent-green);
}

.participant-card.self {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

/* Room Footer */
.room-footer-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

.push-to-talk-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.push-to-talk-hint kbd {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 11px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 90%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.btn-create-full {
    width: 100%;
    background: var(--accent-primary);
    color: white;
    justify-content: center;
    padding: 12px;
    margin-top: 8px;
}

.btn-create-full:hover {
    background: #4752c4;
}

.btn-join-full {
    width: 100%;
    background: var(--accent-green);
    color: white;
    justify-content: center;
    padding: 12px;
    margin-top: 8px;
}

.btn-join-full:hover {
    background: #2d8a47;
}

.modal-error {
    color: var(--accent-red);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    min-height: 20px;
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
    .voice-sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .voice-sidebar.open {
        transform: translateX(0);
    }

    .voice-main {
        padding: 16px;
    }

    .voice-room-active {
        padding: 16px;
    }

    .room-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .participants-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }

    .participant-card {
        padding: 16px;
    }

    .participant-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .modal {
        width: 95%;
        max-width: none;
        margin: 16px;
    }

    /* Mobile sidebar toggle */
    .mobile-toggle {
        display: flex !important;
    }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 30;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* iPhone safe area */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
        padding-top: env(safe-area-inset-top);
    }
}