/* Material Symbols Outlined - Self-hosted */
@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    font-weight: 100 700;
    font-display: block;
    src: url('/MaterialSymbolsOutlined.woff2') format('woff2');
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga';
}

body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 20px;
}

input {
    padding: 8px;
    margin: 5px;
}

button {
    padding: 10px 20px;
    margin: 5px;
    cursor: pointer;
}

#videos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

video {
    width: 45%;
    max-width: 400px;
    margin: 0; /* Remove margin to eliminate gap around tiles */
    border: none; /* Remove border from video tiles */
}

#remoteVideos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    width: 100%;
}

@media (max-width: 600px) {
    video {
        width: 100%;
        max-width: none;
    }

    #remoteVideos {
        grid-template-columns: 1fr;
    }
}

/* ============ EMOJI REACTIONS ============ */

/* CSS Variables for consistent theming */
:root {
    --reaction-bg: rgba(0, 0, 0, 0.6);
    --reaction-text: #ffffff;
    --picker-bg: #2d2d2d;
    --picker-hover: rgba(255, 255, 255, 0.1);
    --picker-border: rgba(255, 255, 255, 0.1);
}

/* Reaction Container - positioned to not overlap controls */
.reaction-container {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 200px;
    height: 350px;
    pointer-events: none;
    z-index: 100;
    overflow: visible;
}

/* Individual floating reaction */
.floating-reaction {
    position: absolute;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: floatEmoji 2.5s ease-out forwards;
    will-change: transform, opacity;
    pointer-events: none;
}

.floating-reaction .emoji {
    font-size: 32px;
    line-height: 1;
}

.floating-reaction .sender-name {
    font-size: 12px;
    color: var(--reaction-text);
    background: var(--reaction-bg);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Float animation with GPU-friendly transforms */
@keyframes floatEmoji {
    0% {
        transform: translateY(0) translateX(var(--drift, 0px)) scale(0.5);
        opacity: 1;
    }
    30% {
        transform: translateY(-100px) translateX(var(--drift, 0px)) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-300px) translateX(var(--drift, 0px)) scale(0.8);
        opacity: 0;
    }
}

/* Emoji Picker Popup */
.emoji-picker {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--picker-bg);
    border-radius: 24px;
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--picker-border);
}

.emoji-picker.hidden {
    display: none;
}

.emoji-option {
    font-size: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.1s;
    line-height: 1;
}

.emoji-option:hover {
    background: var(--picker-hover);
    transform: scale(1.1);
}

.emoji-option:active {
    transform: scale(0.95);
}

/* Emoji Button in Control Bar */
.emoji-btn {
    font-size: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Rate Limit Feedback - Shake Animation */
.emoji-btn.rate-limited {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Mobile-friendly touch styles */
@media (max-width: 768px) {
    .emoji-picker {
        bottom: 90px;
        padding: 6px 10px;
    }

    .emoji-option {
        font-size: 28px;
        padding: 10px;
    }

    .reaction-container {
        right: 10px;
        bottom: 90px;
        width: 150px;
    }

    .floating-reaction .emoji {
        font-size: 28px;
    }

    .floating-reaction .sender-name {
        font-size: 11px;
        max-width: 80px;
    }
}

/* ============ RAISE HAND ============ */

/* Split button container - rounded-xl like mic button */
.raise-hand-container {
    display: flex;
    border-radius: 0.75rem;
    overflow: hidden;
    gap: 0;
    background: rgb(55, 65, 81); /* Solid background to fill the seam */
}

/* Left part - raise hand toggle */
.raise-hand-btn-left {
    border-radius: 0.75rem;
    transition: all 0.2s;
    margin: 0;
    border: none;
}

/* When split button is shown, make it unified with curved divider */
.raise-hand-container:has(.raise-hand-btn-right:not(.hidden)) .raise-hand-btn-left {
    border-top-left-radius: 0.75rem;
    border-bottom-left-radius: 0.75rem;
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-right: none;
    position: relative;
    z-index: 1;
}

/* Right part - lower all (hosts only) - fills behind the curve */
.raise-hand-btn-right {
    border-top-right-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-size: 16px;
    font-weight: bold;
    margin: 0;
    margin-left: -0.5rem;
    padding-left: calc(0.5rem + 8px);
    border: none;
}

.raise-hand-btn-right.hidden {
    display: none;
}

/* Raise Hand Button Active State */
.raise-hand-btn-left.raise-hand-active {
    background: rgb(22, 163, 74) !important;  /* green-500 solid */
    animation: pulse-glow 2s infinite;
}

/* Container background when raise hand is active (to fill seam) */
.raise-hand-container.raise-hand-active {
    background: rgb(22, 163, 74); /* green-500 solid */
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

/* Hand Raised Badge on Video Tile */
.hand-raised-badge {
    background: rgb(22, 163, 74);  /* green-500 */
    color: white;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    text-shadow: none;
}

/* Mobile-friendly raise hand styles */
@media (max-width: 768px) {
    .hand-raised-badge {
        font-size: 0.75rem;
        padding: 2px 8px;
    }

    .raise-hand-btn-right {
        font-size: 12px;
        padding: 0 6px;
    }
}

/* ============ DEVICE SELECTOR ============ */

/* Google Material Symbols font class */
.google-symbols {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga';
}

/* CSS Variables for device selector */
:root {
    --device-dropdown-bg: #2d2d2d;
    --device-dropdown-border: rgba(255, 255, 255, 0.1);
    --device-option-hover: rgba(255, 255, 255, 0.1);
    --device-pill-bg: rgba(255, 255, 255, 0.1);
    --device-pill-hover: rgba(255, 255, 255, 0.2);
}

/* Device Dropdown */
.device-dropdown {
    position: fixed;
    background: var(--device-dropdown-bg);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 200px;
    max-width: 320px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 300;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--device-dropdown-border);
}

.device-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: #e8eaed;
    transition: background 0.15s;
}

.device-option:hover {
    background: var(--device-option-hover);
}

.device-option.selected {
    background: rgba(138, 180, 248, 0.1);
}

.device-checkmark {
    width: 20px;
    color: #8ab4f8;
    font-size: 14px;
    flex-shrink: 0;
}

.device-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.device-empty {
    color: #9aa0a6;
    font-style: italic;
    cursor: default;
}

.device-empty:hover {
    background: transparent;
}

/* Preview Device Pills Container */
.device-pills-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* Device Pill (Preview Screen) - Google Meet light style rounded */
.device-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f0f4f9;
    border: 1px solid #c4c7c5;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 14px;
    color: #1f1f1f;
    -webkit-tap-highlight-color: transparent;
}

.device-pill:hover {
    background: #e3e7eb;
    border-color: #8e918f;
}

.device-pill-icon {
    font-size: 20px;
    color: #444746;
}

.device-pill-label {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-pill-arrow {
    font-size: 18px;
    color: #5f6368;
    margin-left: 2px;
    transition: transform 0.15s;
}

/* Split Button Container */
.device-btn-container {
    display: flex;
    align-items: stretch;
    border-radius: 0.75rem;
    overflow: hidden;
    gap: 0;
    background: rgb(55, 65, 81); /* Solid background to fill the seam */
}

/* Main button in split button */
.device-btn-main {
    border-top-right-radius: 0.5rem !important;
    border-bottom-right-radius: 0.5rem !important;
    position: relative;
    z-index: 1;
}

/* Arrow button (right side of split) - stretches to match main button height */
.device-arrow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    background: rgb(45, 55, 72); /* Darker than main button for nice contrast */
    color: white;
    border: none;
    cursor: pointer;
    margin-left: -0.5rem;
    padding-left: 0.5rem;
    border-top-right-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    transition: background 0.15s;
}

/* Google Material icon inside arrow button */
.device-arrow-icon {
    font-size: 20px;
    color: white;
    line-height: 1;
}

.device-arrow-btn:hover {
    background: rgba(75, 85, 99, 0.9);
}


/* Mobile-friendly device selector styles */
@media (max-width: 768px) {
    .device-pills-container {
        gap: 8px;
    }

    .device-pill {
        padding: 6px 12px;
        font-size: 12px;
    }

    .device-pill-label {
        max-width: 100px;
    }

    .device-dropdown {
        min-width: 180px;
        max-width: 280px;
    }

    .device-option {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Hide device arrow button on small screens */
    .device-arrow-btn {
        display: none;
    }

    /* Restore full border-radius to main button when arrow is hidden */
    .device-btn-main {
        border-top-right-radius: 0.75rem !important;
        border-bottom-right-radius: 0.75rem !important;
    }
}

/* ============ TWO-STEP DROPDOWN (Category Menu + Device List) ============ */

/* Category Menu (Step 1) - Google Meet style rounded horizontal layout */
.device-category-menu {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    padding: 6px;
    background: var(--device-dropdown-bg);
    border-radius: 28px;
    /* No animation - appears instantly */
    max-height: none;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--device-dropdown-border);
    /* Override base dropdown constraints */
    min-width: auto;
    max-width: none;
}

/* Category button (Google Meet style - rounded pill) */
.device-category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    color: #e8eaed;
    transition: background 0.15s;
    font-size: 14px;
    white-space: nowrap;
    font-family: inherit;
}

.device-category-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.device-category-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Active/selected category button (when device list is shown above) */
.device-category-btn.active {
    background: rgba(138, 180, 248, 0.3);
    color: #8ab4f8;
}

.device-category-btn.active .device-category-icon {
    color: #8ab4f8;
}

/* Device list header (shown in stacked dropdown) */
.device-list-header {
    padding: 12px 16px 8px;
    font-size: 14px;
    font-weight: 500;
    color: #e8eaed;
    border-bottom: none;
}

/* Google Material icon in category button */
.device-category-icon {
    font-size: 20px;
    flex-shrink: 0;
    color: #e8eaed;
}

/* Device name label */
.device-category-label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Dropdown arrow */
.device-category-arrow {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    margin-left: 4px;
}

.device-category-arrow svg {
    display: block;
}

/* Device List Menu (Step 2) - stacked above category menu */
.device-list-menu {
    z-index: 10001; /* Above category menu */
    min-width: 220px;
    border-radius: 12px;
    /* No animation - appears instantly above category menu */
}

/* Light theme for device list (preview screen) */
.device-list-menu.light-theme,
.device-dropdown.light-theme {
    background: #f0f4f9;
    border: 1px solid #c4c7c5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.15);
}

.device-list-menu.light-theme .device-option,
.device-dropdown.light-theme .device-option {
    color: #1f1f1f;
}

.device-list-menu.light-theme .device-option:hover,
.device-dropdown.light-theme .device-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.device-list-menu.light-theme .device-option.selected,
.device-dropdown.light-theme .device-option.selected {
    background: rgba(26, 115, 232, 0.08);
}

.device-list-menu.light-theme .device-checkmark,
.device-dropdown.light-theme .device-checkmark {
    color: #1a73e8;
}

.device-list-menu.light-theme .device-back-option,
.device-dropdown.light-theme .device-back-option {
    color: #1a73e8;
}

.device-list-menu.light-theme .device-back-option:hover,
.device-dropdown.light-theme .device-back-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

.device-list-menu.light-theme .device-separator,
.device-dropdown.light-theme .device-separator {
    background: #c4c7c5;
}

.device-list-menu.light-theme .device-list-header,
.device-dropdown.light-theme .device-list-header {
    color: #1f1f1f;
}

/* Back button styling */
.device-back-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    color: #8ab4f8;
    transition: background 0.15s;
    font-weight: 500;
}

.device-back-option:hover {
    background: var(--device-option-hover);
}

.device-back-icon {
    font-size: 18px;
    font-weight: bold;
}

.device-back-label {
    font-size: 14px;
}

/* Separator between back button and device list */
.device-separator {
    height: 1px;
    background: var(--device-dropdown-border);
    margin: 4px 0;
}

/* Mic Test Section */
.mic-test-section {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mic-test-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mic-level-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.mic-level-bar {
    height: 100%;
    background: rgb(138, 180, 248); /* Google Meet blue */
    border-radius: 2px;
    transition: width 0.05s ease-out;
    min-width: 2%;
}

/* Light theme (preview screen) */
.device-list-menu.light-theme .mic-test-label {
    color: rgba(0, 0, 0, 0.6);
}

.device-list-menu.light-theme .mic-level-container {
    background: rgba(0, 0, 0, 0.1);
}

.device-list-menu.light-theme .mic-level-bar {
    background: rgb(26, 115, 232);
}

/* Disabled state (when mic is muted) */
.mic-test-section.disabled {
    opacity: 0.5;
}

.mic-test-section.disabled .mic-test-label {
    color: rgba(255, 255, 255, 0.5);
}

.device-list-menu.light-theme .mic-test-section.disabled .mic-test-label {
    color: rgba(0, 0, 0, 0.4);
}

/* Animations */
@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile styles for category menu */
@media (max-width: 480px) {
    .device-category-menu {
        flex-direction: column;
        gap: 4px;
        padding: 6px;
        border-radius: 20px;
    }

    .device-category-btn {
        width: 100%;
        padding: 10px 14px;
        border-radius: 16px;
    }

    .device-category-label {
        max-width: 200px;
    }
}