/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    opacity: 0.9;
    font-size: 0.9em;
}

/* Room Section */
.room-section {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 600px;
    margin: 0 auto;
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.join-room {
    display: flex;
    gap: 10px;
}

.join-room input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.join-room input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #4ade80;
    color: white;
}

.btn-secondary:hover {
    background: #22c55e;
    transform: translateY(-2px);
}

.btn-small {
    padding: 5px 15px;
    font-size: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Video Section */
.video-section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Desktop: Horizontal layout with AR panel on right */
@media (min-width: 1024px) {
    .video-section {
        flex-direction: row;
        gap: 15px;
    }
}

/* Video Wrapper with Sidebar */
.video-wrapper {
    display: flex;
    flex: 1;
    gap: 15px;
    min-height: 0;
}

/* Participants Sidebar */
.participants-sidebar {
    width: 250px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header {
    padding: 10px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 10px;
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.participant-video-container {
    position: relative;
    background: #1f2937;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.participant-video-container:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.participant-video {
    width: 100%;
    height: 135px;
    object-fit: cover;
    display: block;
}

.participant-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 8px;
    font-size: 12px;
    font-weight: 500;
}

.local-participant {
    border: 2px solid #667eea;
}

/* Main Content Area */
.main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 0;
}

/* AR Panel Wrapper */
.ar-panel-wrapper {
    width: 100%;
}

/* Desktop Layout Container */
@media (min-width: 1024px) {
    .ar-panel-wrapper {
        width: 320px;
        flex-shrink: 0;
    }
}

.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16 = 0.5625) */
    background: #000;
    border-radius: 15px;
    overflow: hidden;
}

/* Main video area (remote video by default) */
.main-video-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 2;
}

/* Local video area (initially hidden, shown when swapped to main) */
.local-video-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Will be shown when swapped */
    z-index: 3;
}

/* AR Canvas */
.ar-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Will be shown when AR is active or showing local video */
    z-index: 3;
    object-fit: contain;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
}

/* Local Video PIP */
.local-video-pip {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 240px;
    height: 135px;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.local-video-pip:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

#pipCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Video Placeholder */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.placeholder-content {
    text-align: center;
    color: #94a3b8;
}

.avatar {
    font-size: 80px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    background: #f3f4f6;
    border-radius: 12px;
    flex-shrink: 0;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #374151;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.control-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.control-btn.leave {
    background: #ef4444;
    color: white;
}

.control-btn.leave:hover {
    background: #dc2626;
}

.control-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* AR Options */
.ar-options {
    background: #f9fafb;
    border-radius: 12px;
    padding: 12px;
    margin-top: 15px;
}

/* Desktop: AR panel on the right side */
@media (min-width: 1024px) {
    .ar-options {
        margin-top: 0;
        height: fit-content;
        position: sticky;
        top: 15px;
    }
}

.ar-options h3 {
    margin-bottom: 10px;
    color: #374151;
    font-size: 14px;
}

/* Landmark Controls */
.landmark-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.landmark-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.landmark-btn:hover {
    border-color: #667eea;
    background: #f7f9ff;
}

.landmark-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.landmark-btn .icon {
    font-size: 1.2em;
}

.landmark-btn span:not(.icon) {
    font-size: 0.9em;
    font-weight: 500;
}

.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-btn {
    padding: 6px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 36px;
    height: 36px;
}

.filter-btn span:not(.filter-icon) {
    display: none;
}

.filter-btn:hover {
    border-color: #667eea;
    background: #f8faff;
}

.filter-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.filter-icon {
    font-size: 18px;
}

/* Status Message */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.status-message.success {
    background: #4ade80;
    color: white;
}

.status-message.error {
    background: #ef4444;
    color: white;
}

.status-message.warning {
    background: #fbbf24;
    color: #78350f;
}

/* Room Info */
.room-info {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-info p {
    margin: 0;
    font-weight: 600;
}

#currentRoomCode {
    color: #667eea;
    font-family: monospace;
    font-size: 1.1em;
    letter-spacing: 2px;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Face Tone Adjustment */
.tone-adjustment {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tone-adjustment h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #fff;
    text-align: center;
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
}

.slider-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    flex-shrink: 0;
}

.tone-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, 
        #333 0%, 
        #666 50%, 
        #ddd 100%);
    border-radius: 3px;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tone-slider:hover {
    opacity: 1;
}

.tone-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #00d4ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
    transition: all 0.2s ease;
}

.tone-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #00d4ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
    transition: all 0.2s ease;
}

.tone-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 12px rgba(0, 212, 255, 0.5);
}

.tone-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 12px rgba(0, 212, 255, 0.5);
}

.slider-value {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
    color: #00d4ff;
    font-weight: 600;
}

.slider-value span {
    padding: 4px 12px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
}

/* Morphing Controls */
.morphing-controls {
    margin-top: 20px;
    padding: 15px;
    background: rgba(240, 240, 240, 0.95);
    border-radius: 10px;
    border: 1px solid rgba(200, 200, 200, 0.5);
}

.morphing-controls h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #333;
    text-align: center;
    font-weight: 500;
}

.morphing-options {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.morph-option-btn {
    padding: 6px 12px;
    background: rgba(100, 100, 100, 0.2);
    border: 1px solid rgba(100, 100, 100, 0.4);
    border-radius: 20px;
    color: #333;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.morph-option-btn:hover {
    background: rgba(100, 100, 100, 0.3);
    color: #000;
    border-color: rgba(100, 100, 100, 0.6);
}

.morph-option-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.morph-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: linear-gradient(to right, 
        #e74c3c 0%, 
        #95a5a6 50%, 
        #3498db 100%);
    border-radius: 3px;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.morph-slider:hover {
    opacity: 1;
}

.morph-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #764ba2;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.3);
    transition: all 0.2s ease;
}

.morph-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #764ba2;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.3);
    transition: all 0.2s ease;
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 320px;
    height: 480px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

/* Desktop: Adjust chat panel position to not overlap with AR panel */
@media (min-width: 1024px) {
    .chat-panel {
        right: 400px; /* Move left to avoid AR panel */
    }
}

.chat-header {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.close-chat-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 15px;
    animation: slideIn 0.3s ease;
}

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

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 12px;
}

.message-user {
    font-weight: 600;
    color: #667eea;
}

.message-time {
    color: #999;
}

.message-content {
    background: white;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: #667eea;
}

.send-chat-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .room-section {
        padding: 20px;
    }
    
    .filter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .local-video-pip {
        width: 120px;
        height: 68px;
        top: 10px;
        left: 10px;
    }
    
    .controls {
        gap: 10px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .tone-adjustment {
        padding: 10px;
    }
    
    .slider-container {
        padding: 0 5px;
    }
    
    .slider-label {
        font-size: 11px;
    }
    
    .chat-panel {
        width: 100%;
        height: 60vh;
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        transform: none;
        border-radius: 15px 15px 0 0;
    }
}