/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Index Page */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 50%, #155e75 100%);
    min-height: 100vh;
    padding: 20px;
}

.logo-img {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.2));
}

.custom-card {
    background: white;
    border: none;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.custom-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: -0.025em;
}

.btn-primary {
    background: #0891b2;
    border: none;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.025em;
}

.btn-primary:hover {
    background: #0e7490;
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(8, 145, 178, 0.3);
}

.btn-success {
    background: #10b981;
    border: none;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.025em;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
}

/* Room Page */
.room-body {
    background: #0f172a;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
}

.room-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.pre-join-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    z-index: 3000;
}

.pre-join-card {
    background: rgba(30, 41, 59, 0.7) !important;
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3) !important;
}

.pre-join-card h3 {
    color: white;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.pre-join-card .form-control {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: white;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.pre-join-card .form-control:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(8, 145, 178, 0.6);
    color: white;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1), 0 1px 2px rgba(0, 0, 0, 0.2);
    outline: none;
}

.pre-join-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Modern Icon Buttons */
.modern-icon-btn {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    border-radius: 12px !important;
    width: 48px !important;
    height: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
    cursor: pointer !important;
}

.modern-icon-btn i {
    color: #64748b !important;
    font-size: 18px !important;
    transition: all 0.2s ease !important;
}

.modern-icon-btn:hover {
    background: white !important;
    border-color: rgba(8, 145, 178, 0.3) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.modern-icon-btn:hover i {
    color: #0891b2 !important;
}

.modern-icon-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.modern-icon-btn.leave-btn {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.modern-icon-btn.leave-btn i {
    color: #ef4444 !important;
}

.modern-icon-btn.leave-btn:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.modern-icon-btn.leave-btn:hover i {
    color: #dc2626 !important;
}

.preview-wrapper {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 16/9;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.preview-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.btn-outline-light {
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.05);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    transform: translateY(-1px);
}

/* Room Container */
.room-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0f172a;
}

.room-header {
    flex-shrink: 0;
}

/* Videos Grid - Dynamic Layout */
.videos-grid {
    flex: 1;
    display: grid;
    gap: 16px;
    overflow-y: auto;
    padding: 20px;
    background: #0f172a;
    align-content: center;
    justify-content: center;
}

/* Custom scrollbar */
.videos-grid::-webkit-scrollbar {
    width: 8px;
}

.videos-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.videos-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.videos-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* 1 participant - Full screen centered */
.videos-grid.participants-1 {
    grid-template-columns: 1fr;
    max-width: 1000px;
    margin: 0 auto;
}

/* 2 participants - Side by side */
.videos-grid.participants-2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1600px;
    margin: 0 auto;
}

/* 3 participants - 2 top, 1 bottom center */
.videos-grid.participants-3 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1200px;
    margin: 0 auto;
}

.videos-grid.participants-3 .video-wrapper:last-child {
    grid-column: 1 / -1;
    max-width: 600px;
    margin: 0 auto;
}

/* 4 participants - 2x2 grid */
.videos-grid.participants-4 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1400px;
    margin: 0 auto;
}

/* 5-6 participants - 3 columns */
.videos-grid.participants-5,
.videos-grid.participants-6 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1600px;
    margin: 0 auto;
}

/* 7+ participants - 4 columns on large screens */
.videos-grid.participants-7,
.videos-grid.participants-8,
.videos-grid.participants-9,
.videos-grid.participants-10,
.videos-grid.participants-many {
    grid-template-columns: repeat(4, 1fr);
    max-width: 1800px;
    margin: 0 auto;
}

.video-wrapper {
    position: relative;
    background: #1e293b;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 16/9;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    width: 100%;
    height: 100%;
    min-height: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-wrapper:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(8, 145, 178, 0.2);
    transform: translateY(-2px);
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mirror local video */
.video-wrapper.local-video video {
    transform: scaleX(-1);
}

.video-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Screen share video - focus frame styling */
.video-wrapper.screen-share-video {
    border: 3px solid #0891b2;
    box-shadow: 0 8px 40px rgba(8, 145, 178, 0.4), 0 0 0 1px rgba(8, 145, 178, 0.3);
    background: #0f172a;
}

.video-wrapper.screen-share-video:hover {
    border-color: #06b6d4;
    box-shadow: 0 12px 50px rgba(8, 145, 178, 0.6), 0 0 0 2px rgba(8, 145, 178, 0.5);
    transform: translateY(-4px);
}

.video-wrapper.screen-share-video .video-label {
    background: linear-gradient(135deg, #0891b2, #0e7490);
    font-weight: 600;
    padding: 8px 16px;
}

/* Don't mirror screen shares */
.video-wrapper.screen-share-video video {
    transform: none !important;
}

/* Mute indicators */
.mute-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
}

.mute-indicator i {
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(4px);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    padding: 16px;
    display: flex;
    justify-content: space-around;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.mobile-controls .btn {
    flex: 1;
    font-size: 1.3rem;
    padding: 14px;
    border-radius: 12px;
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.2s ease;
}

.mobile-controls .btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(8, 145, 178, 0.3);
    transform: translateY(-2px);
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 4000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 8% auto;
    padding: 0;
    width: 90%;
    max-width: 520px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: -0.02em;
}

.close {
    font-size: 24px;
    font-weight: 400;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.close:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #475569;
}

.modal-body {
    padding: 24px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #475569;
    font-size: 14px;
    letter-spacing: 0.01em;
}

.device-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    font-size: 14px;
    background: white;
    color: #1f2937;
    transition: all 0.2s ease;
    cursor: pointer;
}

.device-select:hover {
    border-color: rgba(8, 145, 178, 0.4);
}

.device-select:focus {
    outline: none;
    border-color: #0891b2;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

/* Waiting Room */
.waiting-list {
    max-height: 400px;
    overflow-y: auto;
}

.waiting-item {
    padding: 16px;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.waiting-item:hover {
    background: rgba(241, 245, 249, 1);
    border-color: rgba(8, 145, 178, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.waiting-item h5 {
    margin: 0;
    font-size: 1rem;
}

.waiting-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Host badge */
.host-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Responsive Design */
@media (max-width: 767px) {
    /* Always single column on mobile */
    .videos-grid,
    .videos-grid.participants-1,
    .videos-grid.participants-2,
    .videos-grid.participants-3,
    .videos-grid.participants-4,
    .videos-grid.participants-5,
    .videos-grid.participants-6,
    .videos-grid.participants-7,
    .videos-grid.participants-8,
    .videos-grid.participants-9,
    .videos-grid.participants-10,
    .videos-grid.participants-many {
        grid-template-columns: 1fr !important;
        padding-bottom: 90px;
        max-width: 100%;
    }
    
    .videos-grid.participants-3 .video-wrapper:last-child {
        grid-column: auto;
        max-width: 100%;
    }
    
    .video-wrapper {
        min-height: 250px;
    }
    
    .logo-img {
        max-width: 120px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    /* 2 columns max on tablets */
    .videos-grid.participants-5,
    .videos-grid.participants-6,
    .videos-grid.participants-7,
    .videos-grid.participants-8,
    .videos-grid.participants-9,
    .videos-grid.participants-10,
    .videos-grid.participants-many {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 992px) and (max-width: 1399px) {
    /* 3 columns max on medium desktops */
    .videos-grid.participants-7,
    .videos-grid.participants-8,
    .videos-grid.participants-9,
    .videos-grid.participants-10,
    .videos-grid.participants-many {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Animations */
.btn {
    transition: all 0.3s ease;
}

.video-wrapper {
    transition: transform 0.2s ease;
}

.video-wrapper:hover {
    transform: scale(1.02);
}

/* Scrollbar Styling */
.videos-grid::-webkit-scrollbar {
    width: 8px;
}

.videos-grid::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.videos-grid::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.videos-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Recording indicator animation */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}
