@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #161616;
    --bg-surface: #1e1e1e;
    --text-main: #ffffff;
    --text-muted: #888;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body {
    background-color: var(--bg-dark); color: var(--text-main);
    height: 100vh; overflow: hidden; display: flex; flex-direction: column;
}

/* ===================== Toast ===================== */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-30px);
    background: var(--bg-surface); color: var(--text-main); padding: 12px 24px;
    border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow);
    font-size: 0.9rem; z-index: 9999; opacity: 0; transition: opacity 0.3s, transform 0.3s;
    pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== Floating Reactions ===================== */
#reaction-container {
    position: fixed; bottom: 160px; left: 50%; transform: translateX(-50%);
    width: 300px; height: 300px; pointer-events: none; z-index: 500;
    overflow: hidden;
}
.floating-emoji {
    position: absolute; bottom: 0; font-size: 2rem;
    animation: floatUp 2.5s ease-out forwards;
    opacity: 0;
}
@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-280px) scale(1.5); }
}

/* ===================== Join Screen ===================== */
#join-screen, #waiting-room {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-dark); display: flex; justify-content: center;
    align-items: center; z-index: 1000;
}
.join-card {
    background: var(--bg-panel); padding: 2.5rem; border-radius: 20px;
    width: 100%; max-width: 420px; text-align: center;
    border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.join-card h1 {
    margin-bottom: 0.3rem; font-size: 2.2rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.join-card p { margin-bottom: 2rem; color: var(--text-muted); font-size: 0.95rem; }
.join-card input {
    width: 100%; padding: 14px 16px; margin-bottom: 0.8rem;
    background: var(--bg-dark); border: 1px solid var(--border);
    color: var(--text-main); border-radius: 10px; font-size: 0.95rem; transition: border 0.2s;
}
.join-card input:focus { outline: none; border-color: var(--primary); }
.join-card input[readonly] { opacity: 0.6; cursor: not-allowed; }
.checkbox-group {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 1.5rem; color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
}
.btn {
    width: 100%; padding: 14px;
    background: linear-gradient(135deg, var(--primary), #6366f1); color: white;
    border: none; border-radius: 10px; font-weight: 600; font-size: 1.05rem;
    cursor: pointer; transition: 0.3s;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-danger { background: var(--danger); }

/* Waiting spinner */
.waiting-spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 1.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Top Bar ===================== */
.top-bar {
    height: 44px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 1.5rem; font-size: 0.85rem; color: var(--text-muted); flex-shrink: 0;
}
.top-bar #room-name-display { font-weight: 600; color: var(--text-main); }
.top-bar #meeting-timer { font-variant-numeric: tabular-nums; color: var(--warning); font-weight: 500; }
.top-bar #participant-count { color: var(--success); }

/* ===================== Meeting UI ===================== */
#meeting-ui { display: none; flex: 1; flex-direction: column; height: 100vh; }
.main-content { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ===================== Video Grid ===================== */
#video-grid {
    flex: 1; display: flex; flex-wrap: wrap; align-items: center; align-content: center;
    justify-content: center; gap: 0.5rem; padding: 0.5rem; overflow-y: auto; background: var(--bg-dark);
}
.video-container {
    position: relative; background: #000; border-radius: 12px; overflow: hidden;
    aspect-ratio: 16/9; flex: 1 1 45%; max-width: 100%; min-width: 280px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4); border: 1px solid var(--border);
}
.video-container video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Hand raise badge */
.hand-badge {
    position: absolute; top: 10px; right: 10px; font-size: 1.8rem;
    animation: handPulse 1s ease-in-out infinite;
}
@keyframes handPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

.video-label {
    position: absolute; bottom: 8px; left: 8px; right: 8px;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
    padding: 6px 10px; border-radius: 8px; font-size: 0.85rem; font-weight: 500;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.host-action-btn {
    border: none; color: white; padding: 4px 8px; border-radius: 6px;
    cursor: pointer; font-size: 0.85rem; transition: 0.2s;
    background: rgba(255,255,255,0.15); min-width: 32px; min-height: 28px; text-align: center;
}
.host-action-btn:hover { background: rgba(255,255,255,0.3); }
.host-action-btn.active { background: var(--success); }
.host-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.unmute-action:hover { background: var(--primary); }
.share-grant-action:hover { background: #8b5cf6; }
.mod-action:hover { background: var(--warning); }
.kick-action:hover { background: var(--danger); }

/* ===================== Teleprompter ===================== */
#teleprompter {
    display: none; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 80%; max-width: 800px; height: 240px;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: 14px; z-index: 100; overflow: hidden; padding: 2rem 1.5rem;
}
#teleprompter-text {
    width: 100%; height: 100%; background: transparent; border: none; color: white;
    font-size: 26px; line-height: 1.6; text-align: center; resize: none; outline: none;
    font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.teleprompter-controls {
    position: absolute; top: 6px; right: 8px; display: flex; gap: 5px; align-items: center;
}
.tp-btn {
    background: var(--glass); border: 1px solid var(--border); color: white;
    padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 0.75rem; transition: 0.2s;
}
.tp-btn:hover { background: rgba(255,255,255,0.15); }
.tp-speed-label { font-size: 0.7rem; color: var(--text-muted); margin-left: 4px; }

/* ===================== Sidebars (Chat, Participants, Polls) ===================== */
#chat-sidebar, #participants-panel, #poll-panel {
    display: none; width: 320px; background: var(--bg-panel);
    border-left: 1px solid var(--border); flex-direction: column;
}
.chat-header {
    padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600;
    display: flex; justify-content: space-between; align-items: center;
}
.chat-close-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.chat-close-btn:hover { color: var(--text-main); }

#chat-messages { flex: 1; padding: 0.8rem; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-msg {
    background: var(--bg-dark); padding: 8px 12px; border-radius: 10px;
    font-size: 0.85rem; border: 1px solid var(--border);
}
.chat-msg strong { display: block; color: var(--primary); margin-bottom: 3px; font-size: 0.75rem; }
.chat-time { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.chat-input { padding: 0.8rem; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input input {
    flex: 1; padding: 10px 14px; background: var(--bg-dark); border: 1px solid var(--border);
    color: white; border-radius: 8px; font-size: 0.9rem;
}
.chat-input input:focus { outline: none; border-color: var(--primary); }
.chat-input button {
    background: var(--primary); color: white; border: none; padding: 0 1rem;
    border-radius: 8px; cursor: pointer; transition: 0.2s;
}

/* Participants list */
#participants-list { flex: 1; padding: 0.8rem; overflow-y: auto; }
.participant-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; border-radius: 8px; margin-bottom: 4px;
    background: var(--bg-dark); border: 1px solid var(--border); font-size: 0.85rem;
}
.participant-role { font-size: 0.7rem; color: var(--text-muted); margin-left: 6px; }

/* Pending users */
.pending-header {
    padding: 0.5rem 1rem; font-size: 0.8rem; font-weight: 600;
    color: var(--warning); border-top: 1px solid var(--border);
}
.pending-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; margin: 4px 0.8rem; border-radius: 8px;
    background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); font-size: 0.85rem;
}
.pending-actions { display: flex; gap: 4px; }
.admit-btn, .reject-btn {
    border: none; color: white; padding: 4px 10px; border-radius: 6px;
    cursor: pointer; font-size: 0.8rem; font-weight: 600;
}
.admit-btn { background: var(--success); }
.admit-btn:hover { filter: brightness(1.1); }
.reject-btn { background: var(--danger); }
.reject-btn:hover { filter: brightness(1.1); }

/* Polls */
#poll-content { padding: 1rem; overflow-y: auto; flex: 1; }
.poll-create { display: flex; flex-direction: column; gap: 0.6rem; }
.poll-create input, .poll-create textarea {
    padding: 10px; background: var(--bg-dark); border: 1px solid var(--border);
    color: white; border-radius: 8px; font-size: 0.85rem;
}
.poll-create input:focus, .poll-create textarea:focus { outline: none; border-color: var(--primary); }
.poll-create button {
    padding: 10px; background: var(--primary); color: white;
    border: none; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.poll-question { font-weight: 600; margin-bottom: 0.8rem; font-size: 0.95rem; }
.poll-option {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 6px; cursor: pointer; transition: 0.2s; font-size: 0.85rem;
}
.poll-option:hover { border-color: var(--primary); }
.poll-option.voted { border-color: var(--primary); background: rgba(59, 130, 246, 0.1); }
.poll-bar {
    height: 4px; background: var(--primary); border-radius: 2px;
    transition: width 0.5s; margin-top: 4px;
}
.poll-percent { margin-left: auto; color: var(--text-muted); font-size: 0.8rem; }

/* ===================== Reaction Bar ===================== */
#reaction-bar {
    display: none; justify-content: center; gap: 0.5rem;
    padding: 8px; background: var(--bg-panel); border-top: 1px solid var(--border);
}
.reaction-emoji {
    font-size: 1.5rem; background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 6px 12px; cursor: pointer; transition: 0.2s;
}
.reaction-emoji:hover { transform: scale(1.2); background: rgba(255,255,255,0.1); }

/* ===================== Control Bar ===================== */
.control-bar {
    height: 72px; background: var(--bg-panel); border-top: 1px solid var(--border);
    display: flex; justify-content: center; align-items: center; gap: 0.5rem;
    padding: 0 1rem; flex-shrink: 0;
}
.ctrl-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main);
    cursor: pointer; gap: 3px; padding: 6px 12px; border-radius: 10px; transition: 0.2s; min-width: 52px;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
.ctrl-btn span { font-size: 0.65rem; color: var(--text-muted); }
.ctrl-btn.off { color: var(--danger); border-color: rgba(239,68,68,0.3); }
.ctrl-btn.active { color: var(--warning); border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.1); }
.ctrl-btn.danger {
    background: var(--danger); border-color: var(--danger);
    padding: 8px 16px; border-radius: 20px; font-weight: 600;
}
.ctrl-btn.danger span { color: white; font-size: 0.75rem; }
.ctrl-btn.danger:hover { background: var(--danger-hover); }

/* ===================== Utility ===================== */
.hidden { display: none !important; }

/* ===================== Mobile ===================== */
@media (max-width: 768px) {
    .join-card { margin: 1rem; padding: 1.5rem; }
    .top-bar { padding: 0 0.5rem; font-size: 0.75rem; height: 36px; }

    #video-grid { padding: 0.3rem; gap: 0.3rem; }
    .video-container { min-width: 100%; border-radius: 8px; }

    .video-label { bottom: 4px; left: 4px; right: 4px; padding: 6px 8px; gap: 4px; font-size: 0.8rem; }
    .host-action-btn { padding: 6px 8px; font-size: 0.9rem; min-width: 36px; min-height: 32px; border-radius: 8px; }

    #teleprompter { width: 95%; height: 150px; padding: 1rem 0.8rem; }
    #teleprompter-text { font-size: 18px; }

    #chat-sidebar, #participants-panel, #poll-panel {
        position: absolute; top: 0; right: 0; width: 100%;
        height: calc(100vh - 72px); z-index: 50;
    }

    #reaction-bar { gap: 0.3rem; padding: 6px; }
    .reaction-emoji { font-size: 1.3rem; padding: 4px 8px; }

    .control-bar {
        height: 62px; padding: 0 0.3rem; gap: 0.2rem;
        overflow-x: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch;
    }
    .control-bar::-webkit-scrollbar { display: none; }
    .ctrl-btn { padding: 4px 8px; min-width: 44px; border-radius: 8px; }
    .ctrl-btn span { display: none; }
    .ctrl-btn.danger { padding: 6px 12px; }
    .ctrl-btn.danger span { display: inline; font-size: 0.7rem; }
}
