/* Webi - Global Styles */
/* Colors from DESIGN.md */
:root {
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --secondary: #6366F1;
    --bg: #FFFFFF;
    --surface: #F8FAFC;
    --border: #E2E8F0;
    --text: #0F172A;
    --muted: #64748B;
    --success: #22C55E;
    --error: #EF4444;
    --admin-chat-bg: #EFF6FF;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

/* Header */
.header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.logo {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
    text-decoration: none;
}
.header-right { display: flex; align-items: center; gap: 1rem; }
.admin-name { color: var(--muted); font-size: 0.875rem; }

/* Admin Navigation */
.admin-nav { display: flex; align-items: center; gap: 0.25rem; }
.admin-nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    transition: all 150ms ease;
}
.admin-nav-link:hover { color: var(--text); background: var(--surface); }
.admin-nav-link.active { color: var(--primary); font-weight: 600; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 150ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-success { border-color: var(--success) !important; color: var(--success) !important; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-full { width: 100%; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: var(--text); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color 150ms ease;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-group textarea { resize: vertical; }
.char-count { font-size: 0.75rem; color: var(--muted); text-align: right; display: block; margin-top: 0.25rem; }
.muted { color: var(--muted); font-weight: 400; }
.error-message { color: var(--error); font-size: 0.875rem; margin-bottom: 0.75rem; padding: 0.5rem; background: #FEF2F2; border-radius: var(--radius); }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.form-container { max-width: 600px; margin: 2rem auto; }
.form-container h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }

/* Auth */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--surface);
}
.auth-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-logo { text-align: center; font-size: 1.5rem; margin-bottom: 1.5rem; }
.webinar-join-title { font-size: 1.5rem; margin-bottom: 0.5rem; text-align: center; }
.webinar-join-desc { color: var(--muted); text-align: center; margin-bottom: 1.5rem; font-size: 0.875rem; }

/* Main content */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.dashboard-header h1 { font-size: 1.5rem; }
.webinar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.webinar-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: box-shadow 150ms ease;
}
.webinar-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.webinar-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.webinar-title { font-size: 1.0625rem; margin-bottom: 0.25rem; }
.webinar-name { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.5rem; }
.webinar-schedule { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.75rem; }
.webinar-date { font-size: 0.75rem; color: var(--muted); }
.webinar-attendee-count { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.5rem; }
.webinar-card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.attendee-details { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.attendee-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.attendee-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--border); }
.attendee-table td { padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--border); }
.attendee-table tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.badge-scheduled { background: #FEF3C7; color: #92400E; }
.badge-live { background: var(--error); color: white; animation: pulse 2s infinite; }
.badge-ended { background: var(--surface); color: var(--muted); }

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}
.empty-state p { margin-bottom: 1rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-card h2 { margin-bottom: 1.25rem; font-size: 1.25rem; }
.link-row { margin-bottom: 1rem; }
.link-row label { font-size: 0.8125rem; font-weight: 500; color: var(--muted); display: block; margin-bottom: 0.375rem; }
.link-copy { display: flex; gap: 0.5rem; }
.link-copy input { flex: 1; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.8125rem; background: var(--surface); color: var(--text); }

/* Schedule toggle */
.schedule-toggle { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.toggle-btn {
    flex: 1;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 150ms ease;
}
.toggle-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Video */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}
/* Custom YouTube Player (KillerPlayer-style) */
.video-wrapper #yt-player,
.video-wrapper iframe {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    border: none;
}

/* Full overlay that blocks all YouTube interactions */
.video-click-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    transition: background 300ms ease;
}
.video-click-overlay.visible {
    background: rgba(0,0,0,0.15);
}

/* Big center play/pause button */
.custom-play-btn {
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 200ms ease, opacity 200ms ease;
    opacity: 0;
}
.video-click-overlay.visible .custom-play-btn { opacity: 1; }
.custom-play-btn:hover { transform: scale(1.1); background: rgba(0,0,0,0.7); }

/* Custom controls bar */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    opacity: 0;
    transition: opacity 300ms ease;
}
.custom-controls.visible { opacity: 1; }
/* Fullscreen button always stays on the far right.
   When seekbar (flex:1) is hidden (live mode), margin-left:auto
   absorbs the empty space. In replay mode the seekbar already
   fills all space so this has no visual effect. */
.custom-controls #ctrl-fs { margin-left: auto; }

.ctrl-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 150ms ease;
}
.ctrl-btn:hover { opacity: 1; }

/* Progress bar */
.progress-bar {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.progress-bar:hover { height: 7px; }
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 200ms linear;
}

/* Time display */
.time-display {
    color: white;
    font-size: 0.75rem;
    font-family: 'Inter', monospace;
    white-space: nowrap;
    min-width: 40px;
}

/* Volume slider */
.vol-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}


/* === LIVE ENTRY OVERLAY ===
   Branded "Watch Live" screen — replaces the old "click to unmute" banner.
   Shows only if the browser auto-mutes the video on load.
   One click starts the video with sound — looks like an intentional entry experience. */
.live-entry-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 300ms ease;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.live-entry-content {
    text-align: center;
    color: white;
    padding: 1.5rem;
    pointer-events: none;
    max-width: 480px;
}
.live-entry-badge {
    display: inline-block;
    background: #EF4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}
.live-entry-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.live-entry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: #0F172A;
    border: none;
    border-radius: 999px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 150ms ease, background 150ms ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.live-entry-btn:hover { background: #F1F5F9; transform: scale(1.04); }
.live-entry-btn:active { transform: scale(0.98); }

/* === REPLAY POSTER STATE ===
   Keeps the overlay and big play button always visible
   until the user clicks play for the first time. */
.video-click-overlay.replay-poster {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.video-click-overlay.replay-poster .custom-play-btn {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
}
.video-click-overlay.replay-poster .custom-play-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.8);
}

/* Fullscreen styles (native) */
.video-wrapper:fullscreen {
    width: 100vw;
    height: 100vh;
    padding-bottom: 0;
    border-radius: 0;
}
.video-wrapper:fullscreen #yt-player,
.video-wrapper:fullscreen iframe {
    width: 100vw;
    height: 100vh;
}

/* Pseudo-fullscreen for iOS Safari (no native Fullscreen API support) */
.video-wrapper.pseudo-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    /* JS sets explicit pixel dimensions from window.innerHeight/innerWidth
       which reflects the actual visible area excluding browser chrome. */
    height: 100vh;
    height: 100dvh;
    z-index: 9999 !important;
    padding-bottom: 0 !important;
    border-radius: 0 !important;
    background: #000 !important;
    /* Prevent any overflow that could show the page behind */
    margin: 0 !important;
}
.video-wrapper.pseudo-fullscreen #yt-player,
.video-wrapper.pseudo-fullscreen iframe {
    width: 100% !important;
    height: 100% !important;
}
/* Safe area for notch/home indicator devices */
.video-wrapper.pseudo-fullscreen .custom-controls {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.pseudo-fs-active {
    overflow: hidden !important;
}
/* Show chat toggle + panel in pseudo-fullscreen too */
.video-wrapper.pseudo-fullscreen .fs-chat-toggle { display: flex; }
.video-wrapper.pseudo-fullscreen .fs-chat-panel { display: none; }
.video-wrapper.pseudo-fullscreen .fs-chat-panel.open { display: flex; }
.video-wrapper.pseudo-fullscreen .fs-chat-toggle.chat-open { right: 380px; }
@media (max-width: 1024px) {
    .video-wrapper.pseudo-fullscreen .fs-chat-toggle.chat-open {
        display: none !important;
    }
    .video-wrapper.pseudo-fullscreen .fs-chat-panel {
        width: 280px;
    }
}
@media (max-width: 480px) {
    .video-wrapper.pseudo-fullscreen .fs-chat-panel {
        width: 220px;
    }
}
.video-section { padding: 1rem; overflow-y: auto; min-height: 0; }
.video-description { padding: 0.75rem 0; }
.video-description summary { cursor: pointer; color: var(--muted); font-size: 0.875rem; }
.video-description p { margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); }

/* Viewer info bar (replaces header on live page) */
.viewer-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0;
    flex-shrink: 0;
}
.viewer-info-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    justify-content: center;
}
.viewer-info-left svg { color: var(--muted); }
.viewer-info-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}
.viewer-info-right {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex: 1;
    justify-content: center;
}
.live-dot {
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
.live-text {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--error);
    letter-spacing: 0.05em;
}

/* Chat */
.chat-panel {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.chat-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.75rem 1rem;
}
.chat-msg {
    margin-bottom: 0.75rem;
    animation: slideUp 200ms ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg-name {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}
.chat-msg-name.admin-name-tag { color: var(--primary); }
.chat-msg-text { font-size: 0.875rem; word-break: break-word; }
.chat-msg.admin-msg { background: var(--admin-chat-bg); padding: 0.5rem 0.75rem; border-radius: var(--radius); }
.chat-msg .pin-btn {
    float: right;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--muted);
    padding: 0.125rem 0.25rem;
}
.chat-msg .pin-btn:hover { color: var(--primary); }
.pinned-message {
    background: #EFF6FF;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.625rem 0.75rem;
    margin: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}
.pinned-message .pinned-label { font-size: 0.6875rem; font-weight: 600; color: var(--primary); text-transform: uppercase; margin-bottom: 0.25rem; }
.chat-disabled-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #fef2f2;
    border-top: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.8125rem;
    font-weight: 500;
    flex-shrink: 0;
}
.chat-disabled-banner svg {
    flex-shrink: 0;
}
.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-input-area input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
}
.chat-input-area input:focus { outline: none; border-color: var(--primary); }

/* Presenter layout */
.presenter-layout {
    display: grid;
    grid-template-rows: 60% 40%;
    height: calc(100vh - 56px);
}
.presenter-video { padding: 1rem; overflow: hidden; }
.control-panel { border-top: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.tab-nav { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    transition: all 150ms ease;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; flex: 1; overflow-y: auto; padding: 1rem; }
.tab-content.active { display: flex; flex-direction: column; }

/* Settings tab */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
}

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #CBD5E1;
    border-radius: 999px;
    cursor: pointer;
    transition: 200ms;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: white;
    border-radius: 50%;
    transition: 200ms;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Attendees tab */
.attendee-count { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.75rem; }
.attendee-list { flex: 1; overflow-y: auto; }
.attendee-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}
.attendee-item .att-name { font-weight: 500; }
.attendee-item .att-email { color: var(--muted); }
.attendee-item .att-time { color: var(--muted); font-size: 0.75rem; }

/* Replay */
.replay-container { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }
.replay-description { margin-top: 1.5rem; }
.replay-description h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.replay-description p { color: var(--muted); }

/* Toast notifications */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    z-index: 300;
    animation: slideIn 200ms ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Success message */
.success-message {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Poll styles (presenter admin) */
.poll-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.poll-card h4 { font-size: 0.9375rem; margin-bottom: 0.5rem; }
.poll-status { margin-bottom: 0.75rem; }
.badge-draft { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.badge-published { background: #DBEAFE; color: #1E40AF; }
.poll-option-result {
    margin-bottom: 0.5rem;
}
.poll-option-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
}
.poll-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.poll-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 300ms ease;
}

/* Poll styles (viewer) */
.viewer-polls { padding: 0; }
.poll-viewer-card {
    background: #F0F9FF;
    border: 1px solid #BAE6FD;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0.75rem;
}
.poll-viewer-question {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}
.poll-voter-options { display: flex; flex-direction: column; gap: 0.375rem; }
.poll-vote-btn {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: white;
    color: var(--primary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 150ms ease;
}
.poll-vote-btn:hover { background: var(--primary); color: white; }
.poll-option-result.my-vote .poll-bar-fill { background: var(--success); }
.poll-ended-label { font-size: 0.75rem; color: var(--muted); font-style: italic; margin-top: 0.25rem; }
.poll-thank-you { padding: 0.5rem 0; font-size: 0.8125rem; color: var(--success); font-weight: 500; }
.poll-total-votes { font-size: 0.75rem; color: var(--muted); margin-top: 0.375rem; }
.poll-in-chat { margin-bottom: 0.75rem; animation: slideUp 200ms ease; }

/* Offer styles (presenter admin) */
.offer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.offer-card h4 { font-size: 0.9375rem; margin-bottom: 0.25rem; }

/* Offer styles (viewer) */
.viewer-offers { padding: 0 1rem; }
.offer-viewer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    animation: offerSlide 400ms ease;
}
@keyframes offerSlide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.offer-viewer-content h4 { font-size: 0.9375rem; margin-bottom: 0.125rem; }
.offer-viewer-content p { font-size: 0.8125rem; color: var(--muted); margin: 0; }
.offer-viewer-btn { white-space: nowrap; flex-shrink: 0; }

/* Chat message actions (presenter) */
.chat-msg-actions {
    float: right;
    display: flex;
    gap: 0.125rem;
    opacity: 0;
    transition: opacity 150ms ease;
}
.chat-msg:hover .chat-msg-actions { opacity: 1; }

/* Reconnecting banner */
.reconnecting-banner {
    background: var(--surface);
    color: var(--muted);
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8125rem;
}

/* === WAITING SCREENS === */

/* Presenter waiting screen */
.presenter-waiting {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f7fb;
    min-height: 400px;
    aspect-ratio: 16/9;
    border-radius: var(--radius);
}
.waiting-content {
    text-align: center;
    padding: 2rem;
}
.waiting-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}
.waiting-subtitle {
    font-size: 1.125rem;
    color: #6b7280;
    margin-bottom: 2rem;
}
.waiting-clock {
    margin: 0 auto 2rem;
    width: 120px;
    height: 120px;
}
.btn-start-webinar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2.5rem;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 200ms ease;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}
.btn-start-webinar:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}
.btn-start-webinar:active {
    transform: translateY(0);
}

/* Attendee waiting room */
.attendee-waiting {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: #f0f2f8;
    display: flex;
    align-items: center;
    justify-content: center;
}
.attendee-waiting-card {
    background: white;
    border-radius: 20px;
    padding: 3rem 2.5rem;
    max-width: 550px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}
.attendee-waiting-card h1 {
    font-size: 2rem;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}
.attendee-waiting-host {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
}
.attendee-waiting-host span {
    color: #e8734a;
    font-weight: 600;
}
.attendee-waiting-card hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin-bottom: 2rem;
}
.attendee-waiting-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    border: 5px solid #e5e7eb;
    border-top: 5px solid #9ca3af;
    border-radius: 50%;
    animation: waitSpin 1s linear infinite;
}
@keyframes waitSpin {
    to { transform: rotate(360deg); }
}
.attendee-waiting-text {
    font-size: 1.0625rem;
    color: #6b7280;
    line-height: 1.6;
}

/* === FULLSCREEN CHAT TOGGLE === */

/* Chat toggle button — only visible in fullscreen */
.fs-chat-toggle {
    display: none;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    background: rgba(50, 50, 50, 0.85);
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 10px 8px;
    cursor: pointer;
    transition: background 200ms ease;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.fs-chat-toggle:hover { background: rgba(80, 80, 80, 0.95); }
.fs-chat-icon { display: block; }
.fs-chat-label {
    display: block;
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Fullscreen chat panel header with close button */
.fs-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.9375rem;
}
.fs-chat-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: color 150ms, background 150ms;
}
.fs-chat-close-btn:hover {
    color: var(--text);
    background: var(--hover);
}

/* Fullscreen chat panel */
.fs-chat-panel {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    z-index: 35;
    background: var(--bg);
    border-left: 1px solid var(--border);
    flex-direction: column;
}
.fs-chat-panel.open { display: flex; }

/* Mobile/tablet fullscreen chat — full-height side panel with compact text */
@media (max-width: 1024px) {
    .fs-chat-toggle {
        top: 12px;
        bottom: auto;
        right: 12px;
        transform: none;
        border-radius: 8px;
        padding: 8px 10px;
        z-index: 50;
    }
    .fs-chat-panel {
        width: 280px;
        top: 0;
        bottom: 0;
        right: 0;
        max-height: none;
        border-left: 1px solid var(--border);
        border-top: none;
        border-radius: 0;
        z-index: 50;
    }
    .fs-chat-panel .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Hide toggle when chat is open — X close button is enough */
    .fs-chat-toggle.chat-open {
        display: none !important;
    }
    /* Compact font sizes */
    .fs-chat-panel .fs-chat-header {
        padding: 0.375rem 0.625rem;
        font-size: 0.8125rem;
    }
    .fs-chat-panel .chat-msg-name {
        font-size: 0.625rem !important;
        margin-bottom: 0 !important;
    }
    .fs-chat-panel .chat-msg-text {
        font-size: 0.6875rem !important;
        line-height: 1.25 !important;
    }
    .fs-chat-panel .chat-msg {
        margin-bottom: 0.1875rem !important;
        padding: 0.125rem 0.5rem;
    }
    .fs-chat-panel .chat-input-area {
        padding: 0.25rem 0.375rem;
    }
    .fs-chat-panel .chat-input-area input {
        font-size: 0.75rem;
        padding: 0.3125rem 0.375rem;
    }
    .fs-chat-panel .chat-input-area .btn {
        font-size: 0.6875rem;
        padding: 0.3125rem 0.5rem;
    }
    .fs-chat-panel .fs-chat-close-btn {
        font-size: 1.25rem;
        padding: 0 4px;
    }
}
/* Small phones: narrower panel */
@media (max-width: 480px) {
    .fs-chat-panel {
        width: 220px;
    }
}

/* Fullscreen poll overlay — floats on top of video */
.fs-poll-overlay {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 45;
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    width: 320px;
    max-width: calc(100% - 32px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: offerSlide 400ms ease;
}
/* Only show in fullscreen or pseudo-fullscreen */
.video-wrapper:fullscreen .fs-poll-overlay { display: block; }
.video-wrapper.pseudo-fullscreen .fs-poll-overlay { display: block; }

/* Fullscreen offer overlay — bottom-right of video */
.fs-offer-overlay {
    display: none;
    position: absolute;
    bottom: 72px;
    right: 16px;
    z-index: 45;
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    width: 300px;
    max-width: calc(100% - 32px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: offerSlide 400ms ease;
}
.fs-offer-overlay.collapsed {
    padding: 0.5rem 0.75rem;
    width: auto;
    cursor: pointer;
}
.fs-offer-overlay.collapsed .fs-offer-body { display: none; }
.fs-offer-overlay .fs-offer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    gap: 0.5rem;
}
.fs-offer-overlay .fs-offer-toggle .fs-offer-arrow {
    transition: transform 200ms;
    font-size: 0.75rem;
}
.fs-offer-overlay.collapsed .fs-offer-toggle .fs-offer-arrow {
    transform: rotate(180deg);
}
.fs-offer-overlay .fs-offer-body {
    margin-top: 0.5rem;
}
.fs-offer-overlay .fs-offer-body h4 { font-size: 0.9375rem; margin-bottom: 0.25rem; }
.fs-offer-overlay .fs-offer-body p { font-size: 0.8125rem; color: var(--muted); margin: 0 0 0.5rem 0; }
.fs-offer-overlay .fs-offer-body .btn { width: 100%; text-align: center; }
.video-wrapper:fullscreen .fs-offer-overlay { display: block; }
.video-wrapper.pseudo-fullscreen .fs-offer-overlay { display: block; }

/* Show these elements only in fullscreen */
.video-wrapper:fullscreen .fs-chat-toggle { display: flex; }
.video-wrapper:fullscreen .fs-chat-panel { display: none; }
.video-wrapper:fullscreen .fs-chat-panel.open { display: flex; }

/* Adjust video in fullscreen when chat is open */
.video-wrapper:fullscreen #yt-player,
.video-wrapper:fullscreen iframe {
    width: 100vw;
    height: 100vh;
}
.video-wrapper:fullscreen .fs-chat-toggle.chat-open {
    right: 380px;
}
@media (max-width: 1024px) {
    .video-wrapper:fullscreen .fs-chat-toggle.chat-open {
        display: none !important;
    }
    .video-wrapper:fullscreen .fs-chat-panel {
        width: 280px;
    }
}
@media (max-width: 480px) {
    .video-wrapper:fullscreen .fs-chat-panel {
        width: 220px;
    }
}

/* ============================================================
   Analytics & Registrants Pages
   ============================================================ */

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* Filter cards */
.filter-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-group { flex: 1; min-width: 140px; }
.filter-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.375rem;
}
.filter-group select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
}
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.filter-row .btn { flex-shrink: 0; align-self: flex-end; }

/* Section cards */
.section-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.section-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem; }
.section-subtitle { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }

/* Traffic flow diagram */
.traffic-flow {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 0;
    flex-wrap: wrap;
    justify-content: center;
}
.traffic-node { text-align: center; }
.traffic-icon {
    width: 48px; height: 48px;
    margin: 0 auto 0.5rem;
    display: flex; align-items: center; justify-content: center;
    background: #EFF6FF;
    border-radius: 50%;
    color: var(--primary);
}
.traffic-icon.live { background: #FEF2F2; color: var(--error); }
.traffic-icon.replay { background: #F0FDF4; color: var(--success); }
.traffic-number { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.traffic-label { font-size: 0.8125rem; color: var(--muted); }
.traffic-arrow { text-align: center; color: var(--primary); }
.traffic-rate { font-size: 1.125rem; font-weight: 700; color: var(--primary); }
.traffic-rate-label { font-size: 0.75rem; color: var(--muted); }
.traffic-branch { display: flex; gap: 2rem; }

/* Engagement grid */
.engagement-grid {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 1.5rem;
    align-items: start;
}
.engagement-chart { min-width: 0; overflow: hidden; }
.engagement-chart canvas { width: 100%; height: auto; display: block; }
.engagement-stats { display: flex; flex-direction: column; gap: 1rem; padding: 0.5rem 1rem 0 0; min-width: 0; }
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.stat-label { font-size: 0.875rem; color: var(--muted); }
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }

/* Offer stats */
.offer-stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.offer-stat-card:last-child { border-bottom: none; }
.offer-stat-title { font-weight: 600; display: block; }
.offer-stat-url { font-size: 0.8125rem; display: block; margin-top: 0.125rem; }
.offer-stat-numbers { text-align: right; }
.offer-stat-clicks { font-size: 1.125rem; font-weight: 700; }
.offer-stat-rate { font-size: 0.875rem; color: var(--muted); margin-left: 0.5rem; }

/* Registrants table */
.table-scroll { overflow-x: auto; }
.registrants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.registrants-table th {
    background: var(--surface);
    font-weight: 500;
    color: var(--muted);
    text-align: left;
    padding: 0.75rem 0.625rem;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.registrants-table td {
    padding: 0.75rem 0.625rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.registrants-table tbody tr:hover { background: var(--surface); }
.table-footer {
    padding: 0.75rem 0.625rem;
    font-size: 0.875rem;
}
.actions-cell { white-space: nowrap; }
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    color: var(--muted);
    border-radius: var(--radius);
    transition: all 150ms;
}
.action-btn:hover { color: var(--text); background: var(--surface); }
.action-delete:hover { color: var(--error); }

/* Modals (shared) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-sm { max-width: 420px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Timestamp inputs */
.timestamp-inputs {
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.ts-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ts-group input {
    width: 60px;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
}
.ts-group span { font-size: 0.875rem; color: var(--muted); }

/* Export radio options */
.export-options { display: flex; flex-direction: column; gap: 0.75rem; }
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 150ms;
}
.radio-option:hover { border-color: var(--primary); }
.radio-option input[type="radio"] {
    margin-top: 0.25rem;
    accent-color: var(--primary);
}
.radio-option strong { font-size: 0.875rem; display: block; }
.radio-option .muted { font-size: 0.8125rem; margin-top: 0.125rem; }

/* === OFFER OVERLAY (mobile only) === */
.offer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.offer-overlay-container {
    background: var(--bg);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.offer-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.offer-overlay-title {
    font-weight: 600;
    font-size: 0.9375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 1rem;
}
.offer-overlay-close {
    background: var(--error);
    color: white;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    white-space: nowrap;
    flex-shrink: 0;
}
.offer-overlay-close:hover { background: #DC2626; }
.offer-overlay-iframe {
    flex: 1;
    width: 100%;
    border: none;
}
.offer-overlay-footer {
    padding: 0.625rem 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
}
.offer-overlay-newtab {
    font-size: 0.8125rem;
    color: var(--primary);
    text-decoration: none;
}
.offer-overlay-newtab:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 1024px) {
    .chat-panel {
        border-left: none;
        border-top: 1px solid var(--border);
        height: 55vh;
        height: 55dvh;
        min-height: 400px;
        max-height: 60vh;
        max-height: 60dvh;
        overflow: hidden;
    }
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .viewer-info-bar { border-top: 1px solid var(--border); }
    .presenter-layout { grid-template-rows: auto 1fr; height: auto; }
    .offer-viewer-card { flex-direction: column; align-items: stretch; text-align: center; }
    .engagement-grid { grid-template-columns: 1fr; }
    .traffic-flow { flex-direction: column; }
    .traffic-branch { flex-direction: column; gap: 1rem; }
    .traffic-arrow svg { transform: rotate(90deg); }
}
@media (max-width: 640px) {
    .main-content { padding: 1rem; }
    .webinar-grid { grid-template-columns: 1fr; }
    .auth-card { max-width: 100%; }
    .header { padding: 0 1rem; }
    .admin-nav { display: none; }
    .filter-row { flex-direction: column; }
    .filter-group { min-width: 100%; }

    /* Mobile chat: taller */
    .video-chat-grid { height: auto; min-height: 100vh; min-height: 100dvh; }
    .chat-panel {
        height: 60vh;
        height: 60dvh;
        min-height: 400px;
        max-height: 65vh;
        max-height: 65dvh;
    }
    .chat-input-area {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        z-index: 10;
        flex-shrink: 0;
    }
}
