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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-height: 100vh;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    font-size: 1rem;
    opacity: 0.8;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

input {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    margin-top: 1rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.error-msg, .success-msg {
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.error-msg {
    background: rgba(244, 67, 54, 0.2);
    color: #ffcdd2;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.success-msg {
    background: rgba(76, 175, 80, 0.2);
    color: #c8e6c9;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.meeting-info {
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.video-grid {
    display: grid;
    gap: 0.5rem;
    height: calc(100vh - 200px);
    padding: 0.5rem;
    overflow: hidden;
}

.video-grid.grid-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.video-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.video-grid.grid-3,
.video-grid.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.video-grid.grid-5,
.video-grid.grid-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.video-grid.grid-many {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: minmax(150px, 1fr);
    overflow-y: auto;
}

.video-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.video-container.local-video {
    border: 2px solid #4CAF50;
}

.video-container.speaking {
    border-color: #2196F3;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.6);
}

.video-container.screen-sharing {
    border-color: #ff9800;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.6);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c2c2c, #404040);
    color: white;
    font-size: 2rem;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.video-placeholder.hidden {
    display: none;
}

.video-placeholder .participant-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.video-label {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.participant-name {
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-controls {
    display: flex;
    gap: 0.3rem;
}

.mic-status {
    font-size: 0.8rem;
}

.mic-status.muted {
    opacity: 0.5;
    filter: grayscale(1);
}

.participants-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.participants-panel.active {
    right: 0;
}

.participants-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
}

.participants-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: white;
}

.close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.close-panel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.participants-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.participant-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.2rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease;
    gap: 0.75rem;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.participant-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.participant-info .participant-name {
    font-weight: 500;
    color: white;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-status {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 0.1rem;
}

.participant-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mic-indicator {
    font-size: 0.9rem;
}

.mic-indicator.muted {
    opacity: 0.5;
    filter: grayscale(1);
}

.meeting-controls {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    background: rgba(26, 26, 26, 0.9);
    padding: 0.75rem 1rem;
    border-radius: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.control-btn {
    min-width: auto;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .meeting-controls {
        flex-wrap: wrap;
        max-width: calc(100vw - 2rem);
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }
    
    .participants-panel {
        width: 100vw;
        right: -100vw;
    }
    
    .video-grid {
        height: calc(100vh - 150px);
    }
}

/* Meeting page specific styles */
#meetingPage {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 1rem;
    border-radius: 0;
    background: #1a1a1a;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Device Selection */
.device-selection {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 300px;
}

.device-selection.active {
    display: block;
}

.device-group {
    margin-bottom: 1rem;
}

.device-group label {
    color: #333;
    margin-bottom: 0.5rem;
    display: block;
}

.device-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    color: #333;
}

.settings-toggle {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.8rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.settings-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Permission request overlay */
.permission-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.permission-dialog {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    margin: 1rem;
}

.permission-dialog h3 {
    margin-bottom: 1rem;
    color: #333;
}

.permission-dialog p {
    margin-bottom: 1.5rem;
    color: #666;
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Navigation toggle for create meeting */
.nav-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.8rem 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Meeting creation result display */
.meeting-result {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

.meeting-result h3 {
    margin-bottom: 1rem;
    color: #c8e6c9;
}

.meeting-detail {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: 0.1rem;
}