:root {
    --bg-color: #0d0d12;
    --panel-bg: rgba(25, 25, 35, 0.7);
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --danger: #ef4444;
    --success: #10b981;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Layout */
#app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#meeting-area {
    display: none;
    /* Shown by JS */
    flex: 1;
    flex-direction: column;
    padding: 12px;
    padding-bottom: 92px;
    /* Space for control bar */
    gap: 12px;
    position: relative;
    background: #202124;
    color: #fff;
    width: 100%;
    height: 100%;
}

.room-info-pill {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 16px;
    border-radius: 24px;
    backdrop-filter: blur(8px);
}

.room-id-text {
    font-size: 14px;
    font-weight: 500;
    color: #f1f3f4;
}

.copy-link-btn {
    background: transparent;
    border: none;
    color: #bdc1c6;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.copy-link-btn:hover {
    color: #fff;
}

.copy-link-btn svg {
    width: 18px;
    height: 18px;
}

#video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    align-items: center;
    justify-content: center;
}

.video-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #1a1a24;
    aspect-ratio: 16 / 9;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.video-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(4px);
}

/* Side Panel (Chat/Files) */
#side-panel {
    width: 350px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

#side-panel.hidden {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    height: 100%;
}

.panel-tabs {
    display: flex;
    padding: 10px;
    gap: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.3s;
}

.tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: none;
}

.panel-content.active {
    display: flex;
    flex-direction: column;
}

/* Landing Page Redesigned (Centered) */
#landing-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #ffffff !important;
    color: #202124;
    overflow-y: auto;
    z-index: 1000;
}

.top-nav {
    padding: 24px 40px;
    display: flex;
    justify-content: flex-end;
}

#clock {
    font-size: 18px;
    font-weight: 500;
    color: #5f6368;
}

.landing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.graphic-container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.preview-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #202124;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    /* Mirror Effect */
}

.preview-controls-container {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.pre-control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #dadce0;
    background: #ea4335;
    /* Default red for inactive */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.pre-control-btn:hover {
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3);
}

.pre-control-btn.active {
    background: #1a73e8;
    /* Blue for active */
    border-color: #1a73e8;
}

.pre-control-btn svg {
    width: 24px;
    height: 24px;
}

/* Lobby Overlay */
#lobby-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #202124;
    z-index: 2000;
    /* Above everything */
    text-align: center;
}

.lobby-content {
    max-width: 400px;
    padding: 40px;
}

.lobby-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(26, 115, 232, 0.2);
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mirror effect for other videos too */
#local-video,
video[id^="remote-video-"] {
    transform: scaleX(-1);
}

.landing-content h1 {
    font-size: 44px;
    font-weight: 400;
    line-height: 52px;
    color: #202124;
    margin-bottom: 12px;
    background: none;
    -webkit-text-fill-color: initial;
}

.subtitle {
    font-size: 18px;
    color: #5f6368;
    margin-bottom: 40px;
}

.centered-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.centered-form input {
    width: 100%;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 16px;
    color: #3c4043;
    text-align: left;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
}

.centered-form input:focus {
    border: 2px solid #1a73e8;
    padding: 13px 15px;
}

.create-call-btn {
    width: 100%;
    background: #1a73e8;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.create-call-btn:hover {
    background: #1b66c9;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

/* Admission Panel (Host) */
.admission-panel {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 320px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    overflow: hidden;
    color: #202124;
    border: 1px solid #e8eaed;
}

.admission-panel.hidden {
    display: none;
}

.admission-header {
    padding: 16px;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
}

.admission-header h3 {
    font-size: 14px;
    font-weight: 500;
}

.knock-item {
    padding: 16px;
    border-bottom: 1px solid #f1f3f4;
}

.knock-item span {
    display: block;
    font-size: 14px;
    margin-bottom: 12px;
}

.knock-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #dadce0;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.action-btn.accept {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

.action-btn.accept:hover {
    background: #1b66c9;
}

/* Chat Styles */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bottom Controls */
#control-bar {
    height: 80px;
    background: #202124;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 0 20px;
    z-index: 1200;
    /* Above meeting area but below overlays */
    position: absolute;
    /* In relation to meeting-area container */
    bottom: 0;
    left: 0;
    right: 0;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #3c4043;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.control-btn:hover {
    background: #434649;
}

.control-btn.active {
    background: #3c4043;
}

.control-btn.active:hover {
    background: #434649;
}

.control-btn.inactive,
.control-btn:not(.active) {
    background: #ea4335;
}

.control-btn.inactive:hover,
.control-btn:not(.active):hover {
    background: #d93025;
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

/* Local Video Thumbnail */
#local-video-container {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 200px;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

#local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #side-panel {
        width: 100%;
        position: absolute;
        top: 0;
        right: 0;
        height: calc(100% - 80px);
        z-index: 20;
    }

    #video-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-wrapper {
    animation: fadeIn 0.4s ease-out;
}