/* Base Reset & Variables */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-base: #09090b;      /* Zinc 950 */
    --bg-panel: #18181b;     /* Zinc 900 */
    --bg-surface: #27272a;   /* Zinc 800 */
    --bg-hover: #3f3f46;     /* Zinc 700 */
    --accent-color: #3b82f6; /* Blue 500 */
    --accent-hover: #2563eb; /* Blue 600 */
    --accent-transparent: rgba(59, 130, 246, 0.15);
    --text-main: #f4f4f5;    /* Zinc 50 */
    --text-muted: #a1a1aa;   /* Zinc 400 */
    --border-color: #3f3f46; /* Zinc 700 */
    --danger-color: #ef4444; /* Red 500 */
    
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Layout */
.app-container { display: flex; height: 100vh; width: 100vw; }

/* === START SCREEN === */
.start-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: var(--bg-base);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.start-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 3rem; border-radius: 12px;
    width: 400px; max-width: 90%;
    text-align: center;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; color: var(--text-main); }
.brand h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px; }
.large-brand { justify-content: center; margin-bottom: 0.5rem; }
.large-brand h1 { font-size: 1.5rem; }
.accent-icon { color: var(--accent-color); fill: var(--accent-color); }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }

.form-group { text-align: left; margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500; }
.form-group input {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 12px 14px; border-radius: 8px;
    font-size: 0.95rem; outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent-color); }

.action-tabs { display: flex; background: var(--bg-surface); border-radius: 8px; margin-bottom: 1.5rem; padding: 4px; }
.tab-btn {
    flex: 1; padding: 8px 0; background: transparent; border: none;
    color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
    cursor: pointer; border-radius: 6px; transition: all 0.2s;
}
.tab-btn.active { background: var(--bg-panel); color: var(--text-main); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.full-width-btn { width: 100%; padding: 12px; font-size: 1rem; margin-top: 0.5rem; }

/* === SIDEBARS === */
.sidebar {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    padding: 1.5rem; overflow-y: auto; z-index: 100;
}
.left-sidebar { width: 320px; flex-shrink: 0; }
.right-sidebar { width: 280px; flex-shrink: 0; border-right: none; border-left: 1px solid var(--border-color); overflow-x: hidden; }

/* Reduced from 2rem to 1.25rem to bring Telestrator & Stamps closer */
.section { margin-bottom: 1.25rem; } 
.section h2 { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.8rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }

.url-upload-wrapper { position: relative; display: flex; flex-direction: column; gap: 8px; }
.url-input {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 10px 12px; border-radius: 8px;
    font-size: 0.85rem; outline: none; transition: border-color 0.2s;
}
.url-input:focus { border-color: var(--accent-color); }
.helper-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }

.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .url-input { flex-grow: 1; width: auto; }
.input-row .btn { white-space: nowrap; }

/* Reduced margin from 12px to 4px to tighten up the "or" gap symmetrically */
.separator {
    display: flex; align-items: center; text-align: center; color: var(--text-muted); 
    font-size: 0.75rem; margin: 4px 0; font-weight: 500; text-transform: uppercase; letter-spacing: 1px;
}
.separator::before, .separator::after {
    content: ''; flex: 1; border-bottom: 1px solid var(--border-color);
}
.separator::before { margin-right: 10px; }
.separator::after { margin-left: 10px; }

.local-file-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-surface);
    color: var(--text-main); font-size: 0.85rem; transition: all 0.2s; padding: 10px 0; border-radius: 8px;
    width: 100%; font-weight: 500;
    margin-top: 0; /* Overrides the .full-width-btn margin to make spacing perfectly even */
}
.local-file-btn:hover { background: var(--bg-hover); border-color: var(--text-muted); color: #fff; }

/* Tools & Color Picker */
.color-palette { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.color-preset {
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent;
    cursor: pointer; transition: transform 0.1s; outline: none; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.color-preset:hover { transform: scale(1.15); }
.color-preset.active { border-color: white; transform: scale(1.15); }

.color-picker-wrapper {
    position: relative; width: 24px; height: 24px; border-radius: 50%;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.color-picker-wrapper svg { color: white; filter: drop-shadow(0px 1px 1px rgba(0,0,0,0.8)); pointer-events: none; }
.color-picker-wrapper input[type="color"] { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.tools-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stickers-container { display: flex; gap: 8px; flex-wrap: wrap; }
.sticker {
    width: 36px; height: 36px; flex-shrink: 0; 
    display: flex; align-items: center; justify-content: center;
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.sticker img { width: 20px; height: 20px; pointer-events: none; }
.sticker:hover { background-color: var(--bg-hover); border-color: var(--text-muted); }
.sticker.selected { border-color: var(--accent-color); background-color: var(--accent-transparent); }

/* Notes Section */
.notes-section { flex-grow: 1; display: flex; flex-direction: column; min-height: 180px; margin-bottom: 1.5rem; }
.note-input-container { display: flex; gap: 8px; margin-bottom: 15px; }

#note-input {
    flex-grow: 1; background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 10px 12px; border-radius: 8px;
    font-size: 0.9rem; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
#note-input::placeholder { color: var(--text-muted); }
#note-input:focus { border-color: var(--accent-color); box-shadow: 0 0 0 2px var(--accent-transparent); }
#add-note-btn { padding: 0 16px; font-size: 1.2rem; font-weight: bold; }

.notes-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex-grow: 1; padding-right: 5px; }
.empty-notes { font-size: 0.85rem; color: var(--text-muted); font-style: italic; text-align: center; margin-top: 1rem; }

.note-item {
    background: var(--bg-surface); padding: 10px 12px; border-radius: 8px;
    font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border-color);
}
.note-item:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.note-header { display: flex; justify-content: space-between; align-items: center; }
.note-time {
    display: inline-block; background: var(--accent-transparent); color: var(--accent-color);
    padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
}
.delete-note-btn { 
    background: none; border: none; color: var(--text-muted); 
    font-size: 1.2rem; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; line-height: 1;
}
.delete-note-btn:hover { color: var(--danger-color); background: rgba(239, 68, 68, 0.15); }
.note-text { color: var(--text-main); line-height: 1.4; font-size: 0.85rem; }

/* Shortcuts Grid */
.shortcuts-section { border-top: 1px solid var(--border-color); padding-top: 1.5rem; margin-bottom: 0; }
.shortcuts-grid { display: flex; flex-direction: column; gap: 8px; }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--text-muted); }
kbd {
    background: var(--bg-surface); border: 1px solid var(--border-color); border-bottom-width: 2px;
    border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-main);
}

/* === RIGHT SIDEBAR (ROOM) === */
.room-header { margin-bottom: 2rem; background: var(--bg-surface); padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); }
.room-info { display: flex; flex-direction: column; gap: 6px; }
.room-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-weight: 600; }
.code-wrapper { display: flex; align-items: center; justify-content: space-between; }
.code-buttons { display: flex; align-items: center; gap: 4px; }
.room-code { font-family: var(--font-mono); font-size: 1.2rem; font-weight: bold; color: var(--accent-color); letter-spacing: 2px; }

.users-section { flex-grow: 1; }
.users-list { display: flex; flex-direction: column; gap: 6px; }
.user-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    background: var(--bg-surface); border-radius: 8px; border: 1px solid transparent;
    transition: all 0.3s ease;
}
.user-item.active-action { border-color: var(--accent-color); box-shadow: 0 0 12px var(--accent-transparent); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent-color);
    display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.85rem; color: white; flex-shrink: 0;
}
.user-details { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.user-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }
.role-host { color: var(--accent-color); font-weight: 600; }
.user-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.kick-btn { color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 4px; border-radius: 4px; }
.kick-btn:hover { color: var(--danger-color); background: rgba(239, 68, 68, 0.15); }

/* Per-participant mute + volume slider */
.local-mute-btn {
    background: transparent; border: none; cursor: pointer; padding: 4px; border-radius: 6px;
    color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.local-mute-btn:hover { background: rgba(255,255,255,0.07); color: var(--text-main); }
.local-mute-btn.locally-muted { color: var(--danger-color); }

/* Inline volume slider — slides in from the right on hover, no layout shift */
.peer-volume-wrapper {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
    opacity: 0; overflow: visible;
    max-width: 0;
    transition: opacity 0.25s ease, max-width 0s ease 0.25s;
    pointer-events: none;
}
.user-item:hover .peer-volume-wrapper {
    opacity: 1; max-width: 100px;
    transition: opacity 0.25s ease, max-width 0s ease 0s;
    pointer-events: auto;
}
.peer-volume-icon { color: var(--text-muted); flex-shrink: 0; pointer-events: none; }
.peer-volume-slider {
    -webkit-appearance: none; appearance: none;
    width: 48px; height: 20px;
    background: transparent; cursor: pointer; outline: none; flex-shrink: 0;
}
.peer-volume-slider::-webkit-slider-runnable-track {
    height: 3px; border-radius: 2px; background: var(--bg-hover);
}
.peer-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--text-main); margin-top: -3.5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    transition: background 0.15s;
}
.peer-volume-slider::-moz-range-track {
    height: 3px; border-radius: 2px; background: var(--bg-hover);
}
.peer-volume-slider::-moz-range-thumb {
    width: 10px; height: 10px; border: none; border-radius: 50%;
    background: var(--text-main);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    transition: background 0.15s;
}
.peer-volume-slider:hover::-webkit-slider-thumb { background: var(--accent-color); }
.peer-volume-slider:hover::-moz-range-thumb { background: var(--accent-color); }

.sync-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; }
.status-indicator.online { background-color: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }

/* Buttons General */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 500; font-size: 0.9rem; transition: all 0.2s;
}
.primary-btn { background-color: var(--accent-color); color: white; }
.primary-btn:hover { background-color: var(--accent-hover); }
.icon-btn { background-color: var(--bg-surface); color: var(--text-muted); padding: 8px; border: 1px solid var(--border-color); }
.icon-btn:hover { background-color: var(--bg-hover); color: var(--text-main); border-color: var(--text-muted); }
.icon-btn.active-tool { background-color: var(--accent-transparent); border-color: var(--accent-color); color: var(--accent-color); }
.small-btn { padding: 4px; }

/* === MAIN AREA === */
.main-area { flex-grow: 1; display: flex; flex-direction: column; background-color: var(--bg-base); min-width: 0; }
.video-container-wrapper { flex-grow: 1; display: flex; justify-content: center; align-items: center; padding: 2rem; overflow: hidden; position: relative; }
.video-container {
    position: relative; width: 100%; height: 100%;
    background-color: #000; border-radius: 12px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); border: 1px solid var(--border-color);
}
.main-video { width: 100%; height: 100%; object-fit: contain; }

/* Canvas & Cursor */
.drawing-canvas { 
    position: absolute; top: 0; left: 0; 
    z-index: 10; cursor: crosshair; transition: opacity 0.2s; 
}

.remote-cursor {
    position: absolute; pointer-events: none; z-index: 100;
    transition: none;
    display: none; align-items: flex-start;
}
.remote-cursor-name {
    position: absolute; top: 6px; left: 6px;
    background: rgba(59, 130, 246, 0.9);
    color: white; font-size: 0.65rem;
    padding: 2px 6px; border-radius: 3px; font-weight: 700;
    white-space: nowrap; letter-spacing: 0.05em;
    text-transform: uppercase;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(147, 197, 253, 0.3);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* URL/Waiting States */
.video-container.waiting { display: flex; align-items: center; justify-content: center; background-color: #111; }
.video-container.waiting .main-video { display: none; }
.waiting-message {
    display: none; color: var(--text-muted); font-size: 1.2rem; font-weight: 500;
    text-align: center; animation: pulse 2s infinite;
}
.video-container.waiting .waiting-message { display: block; }
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; color: var(--accent-color); }
    100% { opacity: 0.6; }
}

/* === BOTTOM CONTROLS === */
.bottom-controls { height: auto; background-color: var(--bg-panel); border-top: 1px solid var(--border-color); padding: 1rem 2rem; display: flex; flex-direction: column; gap: 15px; }
.timeline-area { display: flex; align-items: center; gap: 15px; width: 100%; position: relative; }
.time-display { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); width: 70px; text-align: center; user-select: none; }

.custom-timeline-container { position: relative; flex-grow: 1; height: 24px; display: flex; align-items: center; cursor: pointer; }
.timeline-track { position: absolute; width: 100%; height: 6px; background-color: var(--bg-surface); border-radius: 3px; pointer-events: none; }
.timeline-progress { position: absolute; left: 0; height: 6px; background-color: var(--accent-color); border-radius: 3px; width: 0%; pointer-events: none; }

.timeline-slider {
    position: absolute; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
    -webkit-appearance: none; appearance: none; z-index: 10;
}
.timeline-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 4px; height: 16px; background: white; border-radius: 2px; opacity: 1; position: relative; z-index: 20; }
.timeline-slider::-moz-range-thumb { width: 4px; height: 16px; background: white; border: none; border-radius: 2px; opacity: 1; }
.timeline-slider:disabled { cursor: not-allowed; }
.timeline-slider:disabled::-webkit-slider-thumb { background: gray; }

.bottom-row-actions { display: flex; justify-content: space-between; align-items: center; }
.playback-controls { display: flex; justify-content: center; align-items: center; gap: 20px; flex: 1; }
.secondary-controls { display: flex; align-items: center; justify-content: flex-end; gap: 15px; flex: 1; }
.left-controls-spacer { flex: 1; } /* For perfect centering */

.control-group { display: flex; gap: 10px; }
.control-btn { background: transparent; color: var(--text-muted); padding: 8px; }
.control-btn:hover { background-color: var(--bg-surface); color: var(--text-main); }

.play-btn {
    width: 48px; height: 48px; border-radius: 50%; background-color: var(--accent-color); color: white;
    display: flex; align-items: center; justify-content: center; padding: 0; transition: transform 0.1s, background-color 0.2s;
}
.play-btn:hover { transform: scale(1.05); background-color: var(--accent-hover); }
.play-btn svg { margin-left: 2px; }
#pause-icon { margin-left: 0; }

.volume-control { display: flex; align-items: center; gap: 10px; color: var(--text-muted); }

/* Custom Dropdown UI for Playback Speed */
.custom-select { position: relative; font-size: 0.85rem; font-weight: 500; cursor: pointer; user-select: none; min-width: 80px;}
.select-selected { background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: border-color 0.2s; }
.select-selected:hover { border-color: var(--text-muted); }
.select-selected::after { content: "▼"; font-size: 0.6rem; color: var(--text-muted); }
.select-items { position: absolute; background-color: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 6px; bottom: 100%; left: 0; right: 0; z-index: 99; margin-bottom: 6px; overflow: hidden; box-shadow: 0 -4px 12px rgba(0,0,0,0.5); display: flex; flex-direction: column; }
.select-items.select-hide { display: none; }
.select-items div { padding: 8px 10px; color: var(--text-main); transition: background 0.1s; }
.select-items div:hover { background-color: var(--bg-hover); }
.select-items div.same-as-selected { color: var(--accent-color); font-weight: bold; background-color: var(--accent-transparent); }

/* Custom Styled Volume Slider */
.volume-slider {
    -webkit-appearance: none; appearance: none;
    width: 80px; height: 6px; border-radius: 3px;
    background: var(--bg-surface); cursor: pointer; outline: none;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--text-main); transition: background 0.2s;
}
.volume-slider::-moz-range-thumb {
    width: 14px; height: 14px; border: none; border-radius: 50%;
    background: var(--text-main); transition: background 0.2s;
}
.volume-slider:hover::-webkit-slider-thumb { background: var(--accent-color); }
.volume-slider:hover::-moz-range-thumb { background: var(--accent-color); }

/* TOAST NOTIFICATIONS */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--bg-panel); color: var(--text-main); padding: 12px 16px;
    border-radius: 8px; border-left: 4px solid var(--accent-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); font-size: 0.9rem;
    display: flex; align-items: center; gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.toast.error { border-left-color: var(--danger-color); }
.toast.success { border-left-color: #10b981; }
.toast.warning { border-left-color: #f59e0b; }
.toast.fade-out { animation: fadeOut 0.3s forwards; }

@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
/* ─── Voice Chat ─────────────────────────────────────────────────────────── */

/* Speaking indicator — clean blue outline, no shadow */
.user-item.speaking {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    transition: outline 0.15s;
}

/* Mic mute button in bottom controls */
.voice-mute-btn { position: relative; color: #94a3b8; }
.voice-mute-btn:hover { color: #e2e8f0; }
.voice-mute-btn.muted { color: #ef4444; }
.voice-mute-btn.muted svg { stroke: #ef4444; }