/* Import font-family */
@import url('https://fonts.googleapis.com/css?family=Comfortaa:wght@500&display=swap');

/* Modern Variables with Color System */
:root {
    /* Layout */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --btn-size: 52px;
    --btn-size-mobile: 52px;

    /* Colors - Neutral Palette */
    --bg-color: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-tertiary: #242b3d;
    --text-color: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Brand Colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #60a5fa;
    --primary-dark: #1e40af;
    --secondary-color: #8b5cf6;
    --accent-color: #f59e0b;

    /* State Colors */
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;

    /* Glassmorphism */
    --glass-bg: rgba(30, 35, 50, 0.75);
    --glass-bg-strong: rgba(30, 35, 50, 0.9);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(255, 255, 255, 0.25);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 24px rgba(59, 130, 246, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Fallback */
    --fallback-bg: #0f1419;
}

/* Global Styles */
* {
    outline: none;
    font-family: 'Comfortaa', sans-serif;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-color);
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    /* Prevent horizontal layout shift when scrollbars are toggled
       (SweetAlert2 may lock scrolling and/or manage scrollbar padding). */
    scrollbar-gutter: stable;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        linear-gradient(135deg, rgba(15, 20, 25, 0.95) 0%, rgba(26, 31, 46, 0.95) 100%),
        url('background.jpg') center/cover no-repeat fixed,
        var(--fallback-bg);
    will-change: background;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
}

/* Selection Color */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* Modern Unsplash and Author Attribution */
#attribution {
    z-index: 3;
    position: absolute;
    padding: var(--spacing-sm) var(--spacing-md);
    bottom: 0;
    right: var(--spacing-sm);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

#attribution:hover {
    background: var(--glass-bg-strong);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Random image */
img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ensure the random image spans the entire screen */
#randomImage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Prevent buttons from inheriting the image as background */
button {
    background: none;
    color: inherit;
    touch-action: manipulation; /* Prevent zoom and other default behaviors */
}

/* Swap camera mobile only */
#swapCameraBtn,
#screenShareBtn {
    display: none;
}

/* Session Time - Modern Design */
#sessionTime {
    z-index: 4;
    display: none; /* toggled to inline-flex by JS */
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: #ffffff;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    align-items: center;
    gap: 6px;
    min-width: 70px;
    justify-content: center;
    font-family: inherit;
}

#sessionTime::before {
    content: '⏱';
    font-size: var(--font-size-base);
}

#sessionTime:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-color: var(--primary-light);
    box-shadow:
        var(--shadow-lg),
        0 0 16px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* Room */
#roomPage,
#signInPage {
    position: absolute;
    display: none;
}

/* Modern Card Styles with Glassmorphism */
.card {
    max-width: 90% !important;
    margin: 0 auto !important;
    color: var(--text-color) !important;
    font-weight: var(--font-weight-medium) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--border-radius-lg) !important;
    background: transparent !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    box-shadow: var(--shadow-xl) !important;
    overflow: hidden !important;
    transition: all var(--transition-base) !important;
}

.card:hover {
    border-color: var(--glass-border-hover) !important;
    transform: translateY(-2px) !important;
}

.card-header {
    background: rgba(59, 130, 246, 0.1) !important;
    border-bottom: 1px solid var(--glass-border) !important;
    padding: var(--spacing-lg) !important;
}

.card-header h1 {
    margin: 0 !important;
    font-size: var(--font-size-2xl) !important;
    font-weight: var(--font-weight-bold) !important;
    color: #fff !important;
}

.card-body {
    padding: var(--spacing-xl) !important;
    text-align: center !important;
}

/* Media toggle switches on sign-in card */
.media-toggles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.media-toggle-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 12px var(--spacing-md);
    border-radius: var(--border-radius);
    background: rgba(30, 35, 50, 0.5);
    border: 2px solid rgba(16, 185, 129, 0.35);
    cursor: pointer;
    transition: all var(--transition-base);
    user-select: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.media-toggle-item:hover {
    background: rgba(30, 35, 50, 0.7);
    border-color: rgba(16, 185, 129, 0.6);
    transform: translateY(-1px);
    box-shadow:
        0 4px 16px rgba(16, 185, 129, 0.2),
        0 0 0 3px rgba(16, 185, 129, 0.08);
}

.media-toggle-item:has(input:not(:checked)) {
    background: rgba(30, 35, 50, 0.5);
    border-color: rgba(239, 68, 68, 0.35);
}

.media-toggle-item:has(input:not(:checked)):hover {
    background: rgba(30, 35, 50, 0.7);
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow:
        0 4px 16px rgba(239, 68, 68, 0.2),
        0 0 0 3px rgba(239, 68, 68, 0.08);
}

.media-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    background: rgba(16, 185, 129, 0.18);
    color: var(--success-color);
    font-size: var(--font-size-lg);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.media-toggle-item:has(input:not(:checked)) .media-toggle-icon {
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger-color);
}

.media-toggle-label {
    flex: 1;
    text-align: left;
    color: var(--text-color);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    transition: color var(--transition-base);
}

.media-toggle-item:has(input:not(:checked)) .media-toggle-label {
    color: var(--text-secondary);
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(239, 68, 68, 0.4);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 26px;
    transition: var(--transition-base);
}

.switch .slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition-base);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch input:checked + .slider {
    background: var(--success-color);
    border-color: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.switch input:focus + .slider {
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

/* Video Styles */
video {
    width: 100%;
    height: auto;
    border: none;
    border-radius: var(--border-radius);
    object-fit: contain; /* Show full content without cropping */
    cursor: pointer;
    display: block;
    max-width: 100%;
}

/* Screen sharing specific video styling */
video.screen-share,
#localVideo.screen-share,
#remoteVideo.screen-share {
    object-fit: contain !important; /* Show entire screen content without cropping */
    background: #000 !important; /* Black background for letterboxing */
}

/* Camera feed specific styling */
video.camera-feed,
#localVideo.camera-feed,
#remoteVideo.camera-feed {
    object-fit: contain !important; /* Show full content without cropping */
    background: #000 !important; /* Black background for letterboxing */
}

video:hover {
    filter: contrast(105%);
}

video::-webkit-media-controls {
    display: none !important;
}

.mirror {
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    transform: rotateY(180deg);
}

/* Camera Off Overlay */
.camera-off-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(24, 26, 32, 0.92); /* Consistent with UI dark theme */
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 5;
}

/* Local video overlay has higher priority */
#localVideoContainer .camera-off-overlay {
    z-index: 105; /* Always above everything including remote overlays */
}

.camera-off-overlay.show {
    opacity: 1;
    visibility: visible;
}

.camera-off-overlay img {
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
    max-width: 25%; /* Ensure it doesn't exceed 25% of container width */
    max-height: 25%; /* Ensure it doesn't exceed 25% of container height */
    object-fit: contain; /* Maintain aspect ratio */
}

.camera-off-overlay span {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.camera-off-overlay .username {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.camera-off-overlay .status {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.8;
}

/* Modern Local Video Container */
#localVideoContainer {
    z-index: 100;
    position: absolute;
    top: 20px;
    left: 20px;
    width: 220px;
    height: 165px;
    border-radius: var(--border-radius-lg);
    border: 2px solid var(--glass-border);
    overflow: hidden;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    cursor: pointer;
}

#localVideoContainer:hover {
    transform: translateY(-4px) scale(1.03);
}

#localVideoContainer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

#localVideoContainer:hover::after {
    opacity: 1;
}

#localVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--border-radius) - 2px);
    position: relative;
    z-index: 101; /* Ensure local video element is above remote video */
}

/* Override for screen sharing */
#localVideo.screen-share {
    object-fit: contain !important;
    background: #000 !important;
    border: 2px solid #ff6b35 !important; /* Orange border to indicate screen sharing */
}

/* Modern Username Labels - */
#localUsername,
#remoteUsername {
    position: absolute;
    color: #fff;
    background: var(--glass-bg-strong);
    padding: 6px 12px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    z-index: 102;
    transition: all var(--transition-base);
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

#localUsername {
    top: 8px;
    left: 8px;
}

#remoteUsername {
    bottom: 8px;
    left: 8px;
}

#localUsername:hover,
#remoteUsername:hover {
    transform: translateY(-2px);
}

#localUsername::before {
    content: '🟢';
    margin-right: 4px;
    font-size: var(--font-size-sm);
}

#remoteUsername::before {
    content: '🟢';
    margin-right: 4px;
    font-size: var(--font-size-sm);
}

/* Remote Video Container */
#remoteVideoContainer {
    position: relative;
    width: 100%;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    margin: 10px auto;
    max-width: 100%;
    z-index: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
}

#remoteVideoContainer:hover {
    border-color: var(--glass-border-hover);
}

#remoteVideo {
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--border-radius);
    border: none;
    transition: transform 0.3s ease;
}

/* Override for screen sharing */
#remoteVideo.screen-share {
    object-fit: contain !important;
    background: #000 !important;
    border: 2px solid #ff6b35 !important; /* Orange border to indicate screen sharing */
}

#remoteVideo:hover {
    transform: scale(1.02);
}

#streamStatusContainer {
    z-index: 2;
    display: inline-flex;
    position: absolute;
    text-align: center;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    top: 10px;
    left: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 12px;
}

/* Hide Local Video on Mobile */
@media (max-width: 768px) {
    #localVideoContainer {
        width: 120px;
        height: 90px;
        top: 10px;
        left: 10px;
        z-index: 100 !important; /* Ensure local video stays on top on mobile */
    }

    #localVideoContainer:hover {
        transform: scale(1.02);
    }

    #localUsername,
    #remoteUsername {
        font-size: 0.7rem;
        padding: 2px 4px;
        border-radius: 5px;
        max-width: calc(100% - 12px);
    }

    #localUsername {
        top: 1px;
        left: 1px;
    }

    #remoteUsername {
        bottom: 1px;
        left: 1px;
    }

    #localUsername::before,
    #remoteUsername::before {
        font-size: 0.7rem;
        margin-right: 2px;
    }

    /* Mobile Session Time */
    #sessionTime {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 0.75rem;
        border-radius: 16px;
        min-width: 70px;
    }

    #sessionTime::before {
        font-size: 0.8rem;
    }

    #remoteVideoContainer {
        height: 75vh;
    }

    /* Responsive camera off overlay for mobile */
    .camera-off-overlay img {
        width: 32px !important;
        height: 32px !important;
        margin-bottom: 4px !important;
    }

    .camera-off-overlay span {
        font-size: 10px !important;
    }
}

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    #localVideoContainer {
        width: 160px;
        height: 120px;
        z-index: 100 !important; /* Ensure local video stays on top on tablet */
    }

    #remoteVideoContainer {
        height: 75vh;
    }

    /* Responsive camera off overlay for tablet */
    .camera-off-overlay img {
        width: 48px !important;
        height: 48px !important;
        margin-bottom: 6px !important;
    }

    .camera-off-overlay span {
        font-size: 12px !important;
    }
}

/* Desktop responsive */
@media (min-width: 1025px) {
    #localVideoContainer {
        width: 200px;
        height: 150px;
        z-index: 100 !important; /* Ensure local video stays on top on desktop */
    }

    #remoteVideoContainer {
        height: 80vh;
    }
}

/* Large screens */
@media (min-width: 1440px) {
    #localVideoContainer {
        width: 240px;
        height: 180px;
        z-index: 100 !important; /* Ensure local video stays on top on large screens */
    }

    #remoteVideoContainer {
        height: 85vh;
    }

    /* Responsive camera off overlay for large screens */
    .camera-off-overlay img {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 12px !important;
    }

    .camera-off-overlay span {
        font-size: 16px !important;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #localVideoContainer {
        width: 100px;
        height: 75px;
        top: 8px;
        left: 8px;
        z-index: 100 !important; /* Ensure local video stays on top in landscape */
    }

    #remoteVideoContainer {
        height: 90vh;
    }

    /* Responsive camera off overlay for mobile landscape */
    .camera-off-overlay img {
        width: 24px !important;
        height: 24px !important;
        margin-bottom: 2px !important;
    }

    .camera-off-overlay span {
        font-size: 8px !important;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    #localVideoContainer {
        width: 100px;
        height: 75px;
        top: 8px;
        z-index: 100 !important; /* Ensure local video stays on top on small screens */
        left: 8px;
    }

    #localUsername,
    #remoteUsername {
        font-size: 0.65rem;
        padding: 3px 6px;
        border-radius: 10px;
        max-width: calc(100% - 8px);
    }

    #localUsername::before,
    #remoteUsername::before {
        font-size: 0.6rem;
        margin-right: 1px;
    }

    /* Very Small Screen Session Time */
    #sessionTime {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 0.7rem;
        border-radius: 14px;
        min-width: 60px;
    }

    #sessionTime::before {
        font-size: 0.7rem;
    }

    #remoteVideoContainer {
        height: 70vh;
        margin: 5px auto;
    }

    /* Responsive camera off overlay for very small screens */
    .camera-off-overlay img {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 3px !important;
    }

    .camera-off-overlay span {
        font-size: 9px !important;
    }
}

/* Hidden Elements */
.hide {
    visibility: hidden;
    opacity: 0;
}

.show {
    visibility: visible;
    opacity: 1;
}

input {
    text-align: center;
}

/* Modern Input Styling */
#usernameIn {
    display: block;
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    color: var(--text-color);
    border: 2px solid var(--glass-border);
    border-radius: var(--border-radius);
    background: rgba(30, 35, 50, 0.5);
    transition: all var(--transition-base);
    font-weight: var(--font-weight-medium);
    outline: none;
}

#usernameIn::placeholder {
    color: var(--text-muted);
    font-weight: var(--font-weight-normal);
}

#usernameIn:hover {
    border-color: var(--primary-light);
    background: rgba(30, 35, 50, 0.7);
}

#usernameIn:focus {
    border-color: var(--primary-color);
    background: rgba(30, 35, 50, 0.8);
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        var(--shadow-md);
    transform: translateY(-1px);
}

/* Modern Custom Button with Interactions */
.btn-custom {
    height: var(--btn-size);
    width: var(--btn-size);
    margin: 0.3rem;
    color: var(--text-color);
    border: 2px solid transparent;
    border-radius: 50% !important;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-custom::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition:
        width 0.6s,
        height 0.6s;
}

.btn-custom:hover::before {
    width: 100%;
    height: 100%;
}

.btn-custom:hover {
    color: var(--text-color);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-custom:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: var(--shadow-sm);
}

.btn-custom i {
    position: relative;
    z-index: 1;
    font-size: 18px;
}

/* Button Color Variants */
.btn-custom.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
}

.btn-custom.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    box-shadow:
        var(--shadow-lg),
        0 0 20px rgba(59, 130, 246, 0.4);
}

.btn-custom.btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
}

.btn-custom.btn-success:hover {
    background: linear-gradient(135deg, var(--success-hover), #047857);
    box-shadow:
        var(--shadow-lg),
        0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-custom.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
}

.btn-custom.btn-danger:hover {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c);
    box-shadow:
        var(--shadow-lg),
        0 0 20px rgba(239, 68, 68, 0.4);
}

.btn-custom.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
}

.btn-custom.btn-warning:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    box-shadow:
        var(--shadow-lg),
        0 0 20px rgba(245, 158, 11, 0.4);
}

.btn-custom.btn-secondary {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

.btn-custom.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-lg);
}

/* Small Button Size Variant */
.btn-custom.btn-s {
    height: 40px;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0.2rem;
    padding: 0;
    border-width: 2px;
    border-radius: 50% !important;
    box-shadow: var(--shadow-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-custom.btn-s i {
    font-size: 16px;
    color: #ffffff;
    line-height: 1;
}

.btn-custom.btn-s:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

/* Medium Button Size (Default) */
.btn-custom.btn-m {
    height: var(--btn-size);
    width: var(--btn-size);
}

@media (max-width: 768px) {
    .btn-custom {
        height: var(--btn-size-mobile);
        width: var(--btn-size-mobile);
        margin: 0.2rem;
    }

    /* Room controls use .btn-m; ensure mobile sizing wins over base .btn-custom.btn-m */
    .btn-custom.btn-m {
        height: var(--btn-size-mobile);
        width: var(--btn-size-mobile);
    }
    .btn-custom i {
        font-size: 16px;
    }
    .btn-custom:hover {
        transform: scale(1.03);
    }

    /* Room main controls: keep them reachable and prevent wrapping */
    #roomPage {
        padding-bottom: calc(var(--btn-size-mobile) + 28px + env(safe-area-inset-bottom, 0px));
    }

    #roomPage > .row.justify-content-center {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        margin: 0;
        padding: 0 10px;
        z-index: 110;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        --bs-gutter-x: 0;
    }

    #roomPage > .row.justify-content-center::-webkit-scrollbar {
        display: none;
    }

    #roomPage > .row.justify-content-center {
        scrollbar-width: none;
    }

    #roomPage > .row.justify-content-center .btn-custom {
        margin: 0;
        flex: 0 0 auto;
    }
}

/* Extra-small devices (e.g., 320px wide phones) */
@media (max-width: 360px) {
    :root {
        --btn-size-mobile: 48px;
    }

    .btn-custom i {
        font-size: 15px;
    }

    #roomPage {
        padding-bottom: calc(var(--btn-size-mobile) + 24px + env(safe-area-inset-bottom, 0px));
    }

    #roomPage > .row.justify-content-center {
        padding: 0 6px;
        gap: 8px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* Small phones in landscape (short height): keep controls compact */
@media (max-width: 768px) and (max-height: 480px) and (orientation: landscape) {
    :root {
        --btn-size-mobile: 44px;
    }

    .btn-custom i {
        font-size: 14px;
    }

    #roomPage {
        padding-bottom: calc(var(--btn-size-mobile) + 18px + env(safe-area-inset-bottom, 0px));
    }

    #roomPage > .row.justify-content-center {
        padding: 0 8px;
        gap: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    #remoteVideoContainer {
        height: 70vh;
    }
}

/* GitHub div */
#githubDiv {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* User Sidebar with Modern Design */
.user-sidebar {
    z-index: 1000;
    position: fixed;
    display: flex;
    top: 0;
    right: 0;
    width: clamp(320px, 90vw, 500px);
    height: 100%;
    background: var(--glass-bg-strong);
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transition:
        transform var(--transition-slow),
        opacity var(--transition-base);
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
}

.user-sidebar.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    box-shadow:
        var(--shadow-xl),
        -8px 0 32px rgba(0, 0, 0, 0.4);
}

/* Modern Sidebar Header */
.user-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: rgba(15, 20, 25, 0.95);
    border-bottom: 1px solid var(--glass-border);
    gap: var(--spacing-sm);
    overflow: visible;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.sidebar-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-tab {
    background: none;
    border: 2px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    padding: 10px 14px;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all var(--transition-base);
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    justify-content: center;
    overflow: hidden;
}

.sidebar-tab span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.sidebar-tab i,
.sidebar-tab .chat-notification {
    flex-shrink: 0;
}

.sidebar-tab::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transform: translateX(-50%);
    transition: width var(--transition-base);
}

.sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    border-color: var(--glass-border);
}

.sidebar-tab.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.15));
    color: var(--primary-light);
    font-weight: var(--font-weight-semibold);
    border-color: var(--primary-color);
}

.sidebar-tab.active::before {
    width: 60%;
}

/* Chat Notification Badge */
.chat-notification {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    box-shadow: var(--shadow-md);
    animation:
        pulse 2s infinite,
        bounce 0.5s ease-out;
}

.chat-notification.hidden {
    display: none;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Modern Exit Sidebar Button */
.btn-exit-sidebar {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all var(--transition-base);
    flex-shrink: 0;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-exit-sidebar:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger-color);
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-md);
}

.btn-exit-sidebar:active {
    transform: scale(0.95) rotate(10deg);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

/* Modern User Search Bar */
.user-search-bar {
    padding: var(--spacing-md);
    background: rgba(15, 20, 25, 0.8);
    border-bottom: 1px solid var(--glass-border);
}

#userSearchInput {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 2px solid var(--glass-border);
    background: rgba(30, 35, 50, 0.6);
    color: var(--text-color);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    outline: none;
    transition: all var(--transition-base);
}

#userSearchInput:focus {
    border-color: var(--primary-color);
    background: rgba(30, 35, 50, 0.8);
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        var(--shadow-md);
}

#userSearchInput::placeholder {
    color: var(--text-muted);
    font-weight: var(--font-weight-normal);
}

/* User List */
.user-list {
    flex: 1;
    margin: 0;
    padding: var(--spacing-sm) 0;
    list-style: none;
    overflow-y: auto;
}

.user-list li {
    padding: 14px var(--spacing-lg);
    color: #ffffff;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    border-left: 3px solid transparent;
    position: relative;
    margin: 2px 0;
}

.user-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--primary-color);
    transition: width var(--transition-base);
}

.user-list li:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-light);
    border-left-color: var(--primary-color);
    transform: translateX(4px);
}

.user-list li:hover::before {
    width: 3px;
}

.user-list li.selected {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    color: var(--primary-light);
    border-left-color: var(--primary-color);
    font-weight: var(--font-weight-semibold);
}

.user-list li.selected::before {
    width: 3px;
}

/* User List Buttons */
.user-list li .btn-custom {
    flex-shrink: 0;
    margin-right: 10px;
    vertical-align: middle;
}

.user-list li span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    background: rgba(15, 20, 25, 0.4);
}

/* File Transfer Status - Modern Design */
.file-transfer-status {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    max-width: 480px;
    width: min(90%, 480px);
    padding: var(--spacing-md);
    background: var(--glass-bg-strong);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: none;
    animation: slideDown 0.3s ease-out;
}

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

.file-transfer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.05);
    font-size: var(--font-size-sm);
    transition: all var(--transition-base);
}

.file-transfer-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.file-transfer-row.outgoing {
    border-left: 3px solid var(--primary-color);
}

.file-transfer-row.incoming {
    border-left: 3px solid var(--success-color);
}

.file-transfer-info {
    flex: 1;
    margin-right: var(--spacing-sm);
}

.file-transfer-name {
    font-weight: var(--font-weight-semibold);
    color: var(--text-color);
    margin-bottom: 4px;
}

.file-transfer-progress {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    margin-top: 4px;
}

.file-transfer-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary-light), var(--primary-color));
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.file-transfer-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.file-transfer-actions button {
    padding: 6px 10px;
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-base);
}

.chat-message {
    margin-bottom: var(--spacing-md);
    padding: 12px 16px;
    background: var(--glass-bg);
    border-radius: var(--border-radius);
    border-left: 3px solid transparent;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-base);
    animation: messageSlideIn 0.3s ease-out;
}

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

.chat-message:hover {
    background: rgba(30, 35, 50, 0.8);
    border-left-color: var(--glass-border-hover);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.chat-message.own-message {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.1));
    border-left-color: var(--primary-color);
    margin-left: var(--spacing-lg);
}

.chat-message.own-message:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.15));
    border-left-color: var(--primary-light);
}

.chat-message .chat-user {
    font-weight: var(--font-weight-semibold);
    color: var(--primary-light);
    margin-right: 0.5em;
    font-size: var(--font-size-sm);
}

.chat-message.own-message .chat-user {
    color: var(--success-color);
}

.chat-message .chat-text {
    color: var(--text-secondary);
    line-height: 1.5;
    word-wrap: break-word;
    font-size: var(--font-size-base);
    margin-top: 4px;
}

.chat-message .chat-time {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    margin-left: 0.5em;
    float: right;
}

/* Modern Chat Form */
.chat-form {
    display: flex;
    padding: var(--spacing-md);
    background: rgba(15, 20, 25, 0.95);
    border-top: 1px solid var(--glass-border);
    gap: var(--spacing-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Emoji Button */
.btn-emoji {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 12px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--font-size-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn-emoji:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.1) rotate(10deg);
    box-shadow: var(--shadow-md);
}

.btn-emoji:active {
    transform: scale(1.05) rotate(5deg);
}

/* Emoji Picker Container */
.emoji-picker-container {
    position: absolute;
    bottom: 80px;
    left: 16px;
    z-index: 1001;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 320px;
    display: none; /* Hidden by default */
}

.emoji-picker-container.show {
    display: block;
}

.emoji-picker-container em-emoji-picker {
    --rgb-background: 30, 32, 36;
    --rgb-accent: 0, 123, 255;
    --rgb-border: 255, 255, 255, 0.1;
    --rgb-color: 255, 255, 255;
    --border-radius: 8px;
    width: 320px;
    height: 400px;
}

#chatInput {
    flex: 1;
    border: 2px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    background: rgba(30, 35, 50, 0.6);
    color: var(--text-color);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    outline: none;
    transition: all var(--transition-base);
}

#chatInput:focus {
    border-color: var(--primary-color);
    background: rgba(30, 35, 50, 0.8);
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        var(--shadow-md);
}

#chatInput::placeholder {
    color: var(--text-muted);
    font-weight: var(--font-weight-normal);
}

/* Send Button */
.btn-send-chat {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
    color: white;
    padding: 12px 18px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    box-shadow: var(--shadow-md);
}

.btn-send-chat:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    transform: translateY(-2px);
    box-shadow:
        var(--shadow-lg),
        0 0 20px rgba(59, 130, 246, 0.4);
}

.btn-send-chat:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Settings Section */
.settings-section {
    padding: var(--spacing-lg);
    background: rgba(15, 20, 25, 0.4);
    height: 100%;
    overflow-y: auto;
}

.settings-title {
    color: var(--text-color);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: 0 0 var(--spacing-lg) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--glass-border);
}

.settings-title:not(:first-child) {
    margin-top: var(--spacing-xl);
}

.setting-group {
    margin-bottom: var(--spacing-lg);
}

.setting-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.setting-label:hover {
    color: var(--primary-light);
}

/* Toggle switch */
.setting-toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(30, 35, 50, 0.6);
    border: 2px solid var(--glass-border);
    border-radius: 26px;
    transition: all var(--transition-base);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-base);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: #fff;
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.setting-select {
    width: 100%;
    height: 48px;
    padding: 12px 16px;
    border: 2px solid var(--glass-border);
    border-radius: var(--border-radius);
    background: rgba(30, 35, 50, 0.6);
    color: var(--text-color);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    outline: none;
    transition: all var(--transition-base);
    cursor: pointer;
}

.setting-select:focus {
    border-color: var(--primary-color);
    background: rgba(30, 35, 50, 0.8);
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        var(--shadow-md);
}

.setting-select:hover {
    border-color: var(--glass-border-hover);
}

.setting-select option {
    background: var(--bg-secondary);
    color: var(--text-color);
    padding: var(--spacing-sm);
}

.settings-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
}

.btn-test-devices,
.btn-test-devices,
.btn-refresh-devices,
.btn-save-chat,
.btn-clear-chat {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-test-devices,
.btn-save-chat {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    color: white;
}

.btn-test-devices:hover,
.btn-save-chat:hover {
    background: linear-gradient(135deg, var(--success-hover), #047857);
    transform: translateY(-2px);
    box-shadow:
        var(--shadow-md),
        0 0 16px rgba(16, 185, 129, 0.3);
}

.btn-refresh-devices {
    background: var(--glass-bg);
    color: var(--text-color);
    border-color: var(--glass-border);
}

.btn-refresh-devices:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-clear-chat {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
    color: white;
}

.btn-clear-chat:hover {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c);
    transform: translateY(-2px);
    box-shadow:
        var(--shadow-md),
        0 0 16px rgba(239, 68, 68, 0.3);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .user-sidebar {
        width: 100vw;
        max-width: 100vw;
        z-index: 1000;
        height: 100dvh;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .tab-content {
        min-height: 0;
    }

    .sidebar-tabs {
        flex: 1;
        justify-content: space-between;
        overflow: hidden;
    }

    .sidebar-tab {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
        padding: 8px 8px;
        font-size: 0.8rem;
        gap: 4px;
    }

    .sidebar-tab span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-tab i {
        font-size: 0.9rem;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-form {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .btn-emoji {
        padding: 8px 10px;
        font-size: 0.9em;
    }

    #chatInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .settings-section {
        padding: 16px;
    }

    .settings-title {
        font-size: 1rem;
        margin-bottom: 16px;
    }

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

    .settings-actions {
        flex-direction: column;
        gap: 8px;
    }
}

/*--------------------------------------------------------------
# SweetAlert2 Theme
--------------------------------------------------------------*/

/* Ensure the modal always overlays the entire UI */
.swal2-container {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
}

.swal2-container.swal2-backdrop-show {
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}

/* Popup */
.swal2-popup {
    background: var(--glass-bg-strong) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--border-radius-lg) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    box-shadow: var(--shadow-xl) !important;
}

.swal2-title {
    color: var(--text-color) !important;
    font-weight: var(--font-weight-bold) !important;
}

.swal2-html-container {
    color: var(--text-secondary) !important;
}

/* Inputs */
.swal2-input,
.swal2-textarea {
    background: rgba(30, 35, 50, 0.6) !important;
    border: 2px solid var(--glass-border) !important;
    border-radius: var(--border-radius) !important;
    color: var(--text-color) !important;
    transition: all var(--transition-base) !important;
}

.swal2-input:focus,
.swal2-textarea:focus {
    border-color: var(--primary-color) !important;
    background: rgba(30, 35, 50, 0.8) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
    outline: none !important;
}

/* Actions */
.swal2-actions {
    gap: var(--spacing-sm) !important;
}

/* Buttons */
.swal2-popup .swal2-styled {
    border-radius: var(--border-radius) !important;
    font-weight: var(--font-weight-semibold) !important;
    padding: 12px 24px !important;
    transition: all var(--transition-base) !important;
}

.swal2-popup .swal2-styled:focus {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25) !important;
    outline: none !important;
}

.swal2-actions .swal2-confirm {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover)) !important;
    color: #ffffff !important;
    border: none !important;
}

.swal2-actions .swal2-confirm:hover {
    background: linear-gradient(135deg, var(--success-hover), #047857) !important;
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-md) !important;
}

.swal2-actions .swal2-cancel {
    background: var(--glass-bg) !important;
    color: var(--text-color) !important;
    border: 2px solid var(--glass-border) !important;
}

.swal2-actions .swal2-cancel:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--glass-border-hover) !important;
    transform: translateY(-2px) !important;
}

.swal2-actions .swal2-deny {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover)) !important;
    color: #ffffff !important;
    border: none !important;
}

.swal2-actions .swal2-deny:hover {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c) !important;
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-md) !important;
}

/* Close button */
.swal2-close {
    color: var(--text-secondary) !important;
    transition: all var(--transition-fast) !important;
}

.swal2-close:hover {
    color: var(--danger-color) !important;
}

/* Toastify custom styles */
.toastify-custom {
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    cursor: default !important;
    text-align: center;
}

.toastify-custom .toast-close {
    color: #fff !important;
    opacity: 0.8;
    padding-left: 8px;
}

.toastify-custom .toast-close:hover {
    opacity: 1;
}

.swal2-timer-progress-bar {
    background: linear-gradient(90deg, var(--success-color), var(--primary-color)) !important;
}

/* Modern Webkit-Scrollbar Styles */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color), var(--primary-hover));
    border-radius: var(--border-radius);
    border: 2px solid var(--bg-color);
    transition: all var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-light), var(--primary-color));
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, var(--primary-hover), var(--primary-dark));
}

/* For Firefox */
.color-red {
    color: red !important;
}

/*--------------------------------------------------------------
# Pulse Effect
--------------------------------------------------------------*/

.pulsate {
    animation: pulsate 3s ease-in-out infinite;
    -webkit-animation: pulsate 3s ease-in-out infinite;
}

@keyframes pulsate {
    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

/*--------------------------------------------------------------
# Loading States & Skeleton Screens
--------------------------------------------------------------*/

.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--glass-bg) 25%, rgba(255, 255, 255, 0.05) 50%, var(--glass-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--border-radius);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/*--------------------------------------------------------------
# Accessibility - Focus Visible States
--------------------------------------------------------------*/

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

button:focus-visible,
.btn-custom:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--primary-color);
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.15),
        var(--shadow-md);
}

/*--------------------------------------------------------------
# Page Transitions & Fade Effects
--------------------------------------------------------------*/

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

.slide-up {
    animation: slideUp 0.4s ease-out;
}

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

/*--------------------------------------------------------------
# Bootstrap Button Overrides
--------------------------------------------------------------*/

.btn {
    font-weight: var(--font-weight-semibold);
    transition: all var(--transition-base);
    border-radius: var(--border-radius);
    padding: 12px 24px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    transform: translateY(-2px);
    box-shadow:
        var(--shadow-md),
        0 0 16px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    border: none;
}

.btn-secondary {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border-hover);
}

/*--------------------------------------------------------------
# Utility Classes
--------------------------------------------------------------*/

.text-gradient {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.shadow-glow-primary {
    box-shadow:
        var(--shadow-md),
        0 0 24px rgba(59, 130, 246, 0.3);
}

.shadow-glow-success {
    box-shadow:
        var(--shadow-md),
        0 0 24px rgba(16, 185, 129, 0.3);
}

.shadow-glow-danger {
    box-shadow:
        var(--shadow-md),
        0 0 24px rgba(239, 68, 68, 0.3);
}

/*
z-index:
    - 1. remoteVideo
    - 2. streamStatusContainer
    - 3. localVideoContainer, attribution
    - 4. sessionTime
    - 5. userSidebar
    - 6. file-transfer-status
    - 7. SweetAlert2
*/
