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

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

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-light: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.1);
    --green: #10b981;
    --green-glow: rgba(16, 185, 129, 0.3);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.3);
    --yellow: #f59e0b;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(16, 185, 129, 0.08), transparent),
        var(--bg-primary);
}

/* ===== AMBIENT BACKGROUND ===== */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.ambient-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.ambient-bg .orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -10%;
    left: 20%;
    animation-delay: 0s;
}

.ambient-bg .orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    bottom: -5%;
    right: 15%;
    animation-delay: -7s;
}

.ambient-bg .orb:nth-child(3) {
    width: 250px;
    height: 250px;
    background: var(--green);
    top: 40%;
    right: -5%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 15px) scale(1.02); }
}

/* ===== SCREENS ===== */
.screen {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    padding: 20px;
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LOGIN CARD ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 48px 40px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    padding: 1px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.02),
        rgba(99, 102, 241, 0.1)
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.logo-icon svg {
    width: 26px;
    height: 26px;
    color: white;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.925rem;
    margin-bottom: 36px;
    line-height: 1.5;
}

/* ===== FORM ===== */
.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input {
    width: 100%;
    padding: 14px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 20px var(--accent-glow);
}

.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn svg {
    width: 20px;
    height: 20px;
}

/* ===== ROOM SCREEN ===== */
#room-screen {
    max-width: 600px;
}

.room-card {
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.room-header {
    padding: 24px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.room-status {
    width: 10px;
    height: 10px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--green-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--green-glow); }
    50% { opacity: 0.7; box-shadow: 0 0 20px var(--green-glow); }
}

.room-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.room-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.room-header-actions {
    display: flex;
    gap: 8px;
}

/* ===== PARTICIPANTS LIST ===== */
.participants {
    padding: 16px 28px 8px;
    min-height: 100px;
}

.participants-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
}

.participant {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 6px;
    animation: slideIn 0.3s ease;
}

.participant:hover {
    background: var(--bg-card-hover);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.participant-avatar.speaking {
    animation: speaking-ring 1s ease-in-out infinite;
}

@keyframes speaking-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.participant-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}

.participant-you {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.participant-muted {
    color: var(--text-muted);
}

.participant-muted svg {
    width: 18px;
    height: 18px;
}

/* ===== CONTROLS BAR ===== */
.controls {
    padding: 20px 28px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    gap: 12px;
}

.ctrl-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.ctrl-btn svg {
    width: 22px;
    height: 22px;
    color: white;
}

.ctrl-btn-mute {
    background: var(--bg-card-hover);
    border: 1px solid var(--glass-border);
}

.ctrl-btn-mute:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}

.ctrl-btn-mute.muted {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.ctrl-btn-mute.muted svg {
    color: var(--red);
}

.ctrl-btn-leave {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ctrl-btn-leave:hover {
    background: var(--red);
    box-shadow: 0 4px 15px var(--red-glow);
    transform: scale(1.08);
}

/* ===== STATUS / CONNECTING ===== */
.status-bar {
    padding: 0 28px 20px;
    text-align: center;
}

.status-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-text.error {
    color: var(--red);
}

.status-text.connected {
    color: var(--green);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.4s ease, toastOut 0.4s ease 3s forwards;
    max-width: 320px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .screen {
        padding: 16px;
    }

    .card {
        padding: 36px 24px;
    }

    .room-header {
        padding: 18px 20px;
    }

    .participants {
        padding: 14px 20px 6px;
    }

    .controls {
        padding: 16px 20px;
    }

    .status-bar {
        padding: 0 20px 16px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }
}
