/* --- Global Reset & Box Sizing Configuration --- */
*, *::before, *::after {
    box-sizing: border-box; /* Prevents structural padding layout scaling overflow bugs */
}

:root {
    --bg-color: #0c0b0e;        /* Deep midnight cinema canvas background */
    --text-color: #f5f5f7;      /* Clean neutral white tone for structural copy */
    --text-muted: #8e8d94;      /* Soft silver slate tint for label structures */
    --panel-bg: #151419;        /* Slightly elevated dark dashboard panel surface */
    --panel-border: #232228;    /* Razor sharp container seam divider boundaries */
    --primary: #ff4500;         /* Electrifying theatre primary neon glow accent */
    --primary-hover: #ff5722;   /* Illuminated neon tint shift upon tracking actions */
    --secondary: #24232a;       /* Clean matte control backing layer */
    --secondary-hover: #302f38; /* Lightened matte control fill surface on state hover */
    --input-bg: #1e1d23;        /* Slightly recessed input box layout well track */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 30px 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    margin: 0;
    font-size: 2.8em;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--primary);
    text-shadow: 0 4px 14px rgba(255, 69, 0, 0.25);
}

/* Base dashboard container wrapper with fluid elevation transitions */
.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
    margin-bottom: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
}

.row {
    display: flex;
    gap: 20px;
}

.col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Flex wrapper grid for inline video loader configuration */
.media-input-group {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
}

/* Ensure the video URL input field expands to fill all available width inside the group */
.media-input-group input {
    flex: 1;
    width: 100%;
}

h3 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-color);
}

label {
    color: var(--text-muted);
    font-size: 0.9em;
    font-weight: 500;
}

input {
    background-color: var(--input-bg);
    color: #ffffff;
    padding: 12px 16px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Deep cinematic neon focus indicator aura rings */
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.12), 0 4px 12px rgba(255, 69, 0, 0.08);
}

input::placeholder {
    color: #4f4d57;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Fluid micro-lift hover interactions */
button:hover {
    transform: translateY(-2px);
}

/* Tactile click feedback depression physics */
button:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(255, 69, 0, 0.3);
}

.btn-secondary {
    background-color: var(--secondary);
    border: 1px solid var(--panel-border);
}
.btn-secondary:hover {
    background-color: var(--secondary-hover);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background-color: #ff3333;
}
.btn-danger:hover {
    background-color: #ff4d4d;
    box-shadow: 0 6px 20px rgba(255, 51, 51, 0.25);
}

/* --- STATUS INDICATOR PULSE DOT SYSTEM --- */
.status-badge {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    white-space: pre-line;
    line-height: 1.5;
    width: 100%;
    border: 1px solid transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.status-badge::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.disconnected {
    background-color: rgba(255, 51, 51, 0.04);
    color: #ff4d4d;
    border-color: rgba(255, 51, 51, 0.12);
}

.disconnected::before {
    background-color: #ff4d4d;
    animation: pulse-red 2s infinite;
}

.connected {
    background-color: rgba(76, 175, 80, 0.05);
    color: #4caf50;
    border-color: rgba(76, 175, 80, 0.15);
}

.connected::before {
    background-color: #4caf50;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(255, 77, 77, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

/* --- SEAMLESS DOCK PLAYER FRAMEWORK --- */
#theaterContainer {
    display: none;
    flex-direction: column;
    width: 100%;
    position: relative;
}

.player-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    background-color: #000;
}

.player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#playerShield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: transparent;
    cursor: default;
}

.custom-controls-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 0;
    padding: 20px 24px;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    margin-bottom: 24px;
}

#customProgressBar {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #232228;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 0;
    padding: 0;
    display: block;
}

#customProgressBar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#customProgressBar::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.controls-buttons-row {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.btn-control {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
}
.btn-play { background-color: #1b5e20; border: 1px solid #2e7d32; }
.btn-play:hover { background-color: #2e7d32; box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2); }
.btn-pause { background-color: #3e2723; border: 1px solid #5d4037; }
.btn-pause:hover { background-color: #5d4037; box-shadow: 0 4px 12px rgba(93, 64, 55, 0.2); }

.btn-control:disabled {
    background-color: #141318 !important;
    border-color: #1d1c22 !important;
    color: #3b3a42 !important;
    cursor: not-allowed;
    opacity: 0.5;
    transform: none !important;
    box-shadow: none !important;
}

#customTimeLabel {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 700;
    min-width: 100px;
    text-align: right;
    margin-left: auto;
    color: var(--text-muted);
}

/* --- TABS SEGMENT INTERFACE WRAPPER --- */
.tabs-container {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 20px;
    padding-bottom: 12px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-color);
    background-color: var(--input-bg);
    transform: none;
}

.tab-btn.active {
    color: #ffffff;
    background-color: var(--primary);
    box-shadow: 0 4px 14px rgba(255, 69, 0, 0.25);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 12px;
}

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

/* =====================================================================
   NEW: HIGH-PREMIUM HARDWARE-ACCELERATED FULLSCREEN CINEMA SEAMLESS OVERLAYS
   ===================================================================== */
#theaterContainer:fullscreen {
    background-color: #000000;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Expand the inner view block configuration to override padding-bottom aspect ratios */
#theaterContainer:fullscreen .player-wrapper {
    width: 100vw;
    height: 100vh;
    padding-bottom: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Translate the controls board into floating ghost dock panels triggered on hover coordinates */
#theaterContainer:fullscreen .custom-controls-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    border-radius: 0;
    border: none;
    margin-bottom: 0;
    z-index: 100;
    background-color: rgba(21, 20, 25, 0.82); /* Semi-transparent cinema backing */
    backdrop-filter: blur(12px);               /* Premium glassmorphism overlay blur */
    -webkit-backdrop-filter: blur(12px);

    /* MODIFIED: Standard fullscreen state has controls hidden with inactivity protection mechanisms */
    opacity: 0;                                /* Hidden by default for uninterrupted view */
    visibility: hidden;                         /* Completely strips pointer events when inactive */
    transform: translateY(10px);               /* Slight drop down alignment offset */
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
}

/* UPDATED: Fully responsive JS-driven visibility trigger selector blueprint */
#theaterContainer:fullscreen .custom-controls-panel.controls-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Maintain visibility specifically when the mouse is physically over the controls dock panel well */
#theaterContainer:fullscreen .custom-controls-panel:hover {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* =====================================================================
   NEW: VIDEO CHAT OVERLAY PREMIUM GLASSMORPHIC DESIGN SYSTEM
   ===================================================================== */
.video-chat-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    background-color: rgba(21, 20, 25, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 69, 0, 0.25);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    z-index: 150;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                height 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.2s ease;
    user-select: none;
}

.video-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background-color: rgba(255, 69, 0, 0.08);
    border-bottom: 1px solid rgba(255, 69, 0, 0.15);
    cursor: move; /* Indicates draggable window */
}

.video-chat-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-chat-header-actions {
    display: flex;
    gap: 4px;
}

.btn-chat-icon {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 11px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-chat-icon:hover {
    color: #ffffff;
    background: rgba(255, 69, 0, 0.2);
    border-color: rgba(255, 69, 0, 0.4);
    transform: scale(1.05);
}

.btn-chat-icon:active {
    transform: scale(0.95);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
    background: rgba(12, 11, 14, 0.4);
    max-height: 380px;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dynamic layouts for Grid */
.video-grid.single-layout {
    grid-template-columns: 1fr;
}

.video-grid.single-layout .video-slot {
    aspect-ratio: 16/9;
}

.video-slot {
    position: relative;
    aspect-ratio: 4/3;
    background-color: #121115;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Highlighting Active Speakers */
.video-slot.active-speaker {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(255, 69, 0, 0.4);
}

.video-slot video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background-color: #000;
}

/* Mirror the local participant stream */
.local-slot video {
    transform: scaleX(-1);
}

.video-label {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background-color: rgba(12, 11, 14, 0.75);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
}

.mic-indicator, .video-indicator {
    background-color: rgba(12, 11, 14, 0.75);
    backdrop-filter: blur(4px);
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.mic-indicator.active, .video-indicator.active {
    opacity: 1;
}

.mic-indicator.muted {
    background-color: rgba(255, 51, 51, 0.8);
    border-color: rgba(255, 51, 51, 0.3);
    opacity: 1;
}

.video-chat-controls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 14px;
    background-color: rgba(21, 20, 25, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 10px;
}

.btn-chat-control {
    flex: 1;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    background-color: var(--secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-chat-control:hover {
    background-color: var(--secondary-hover);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.btn-chat-control.muted {
    background-color: rgba(255, 51, 51, 0.15);
    border-color: rgba(255, 51, 51, 0.3);
    color: #ff4d4d;
}

.btn-chat-control.muted:hover {
    background-color: rgba(255, 51, 51, 0.25);
}

/* --- Completely Collapsed State Trigger Button --- */
.video-chat-restore-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 155;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #ff6f00 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(255, 69, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: slide-in 0.3s ease-out;
}

.video-chat-restore-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 28px rgba(255, 69, 0, 0.45);
}

.video-chat-restore-btn:active {
    transform: translateY(1px);
}

@keyframes slide-in {
    from { transform: translateX(50px) scale(0.9); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

/* Fallback Canvas Pulsing Animation style */
.mock-stream-canvas {
    background: radial-gradient(circle, #201a30 0%, #0d0b14 100%);
}

/* Fullscreen overrides: when inside fullscreen theaterContainer, switch positioning to absolute */
#theaterContainer:fullscreen .video-chat-overlay {
    position: absolute !important;
}
#theaterContainer:fullscreen .video-chat-restore-btn {
    position: absolute !important;
}