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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0c0c0c 0%, #1a1a1a 100%);
    color: #ffffff;
    overflow-x: hidden;
}

/* Header */
.mirror-header {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.mirror-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.btn-settings {
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    color: white;
}

.btn-fullscreen {
    background: linear-gradient(45deg, #4ecdc4 0%, #44a08d 100%);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.btn-fullscreen:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.6);
    color: white;
}

/* Main Mirror Container */
.mirror-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 80px;
}

.camera-container {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: 70vh;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

#canvasElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

/* FPS Indicator */
.fps-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #4ecdc4;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    border: 1px solid rgba(78, 205, 196, 0.3);
    backdrop-filter: blur(5px);
    z-index: 5;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.loading-spinner i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #4ecdc4;
}

.loading-spinner p {
    font-size: 1.2rem;
    margin: 0;
}

/* Error Overlay */
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.error-message {
    text-align: center;
    color: white;
    padding: 2rem;
}

.error-message i {
    font-size: 4rem;
    color: #ff6b6b;
    margin-bottom: 1rem;
}

.error-message h3 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.error-message p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    opacity: 0.8;
}

.error-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: right 0.3s ease;
    z-index: 1100;
    overflow-y: auto;
}

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

.settings-content {
    padding: 2rem;
}

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

.settings-header h3 {
    color: #4ecdc4;
    margin: 0;
    font-size: 1.4rem;
}

.btn-close-settings {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.btn-close-settings:hover {
    color: #ff6b6b;
}

/* Settings Sections */
.camera-settings-section,
.performance-settings-section,
.model-settings-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-settings-section h4,
.performance-settings-section h4,
.model-settings-section h4 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.camera-controls,
.performance-controls,
.model-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Performance Settings Specific Styles */
.performance-settings-section {
    background: rgba(78, 205, 196, 0.05);
    border: 1px solid rgba(78, 205, 196, 0.2);
    border-radius: 10px;
    padding: 1.5rem;
}

.performance-settings-section h4 {
    color: #4ecdc4;
}

.slider-control {
    display: flex;
    flex-direction: column;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.25rem;
}

.form-range {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    height: 8px;
}

.form-range::-webkit-slider-thumb {
    background: #4ecdc4;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
}

.form-range::-moz-range-thumb {
    background: #4ecdc4;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
}

.form-label {
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-check-label {
    color: #ffffff;
    font-weight: 500;
}

.form-check-input:checked {
    background-color: #4ecdc4;
    border-color: #4ecdc4;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(78, 205, 196, 0.25);
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-section h4 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
}

.upload-area.dragover {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.2);
}

.upload-icon {
    font-size: 3rem;
    color: #4ecdc4;
    margin-bottom: 1rem;
}

.upload-link {
    color: #4ecdc4;
    text-decoration: underline;
    cursor: pointer;
}

.upload-progress {
    margin-top: 1rem;
}

.progress {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(45deg, #4ecdc4, #44a08d);
    transition: width 0.3s ease;
}

/* Backgrounds Section */
.backgrounds-section {
    margin-bottom: 2rem;
}

.backgrounds-section h4 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.backgrounds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

.background-item {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.background-item:hover {
    transform: scale(1.05);
    border-color: #4ecdc4;
}

.background-item.active {
    border-color: #4ecdc4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
}

.background-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(78, 205, 196, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.background-item.active .background-overlay {
    opacity: 1;
}

.background-overlay i {
    font-size: 2rem;
    color: white;
}

.delete-bg {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.background-item:hover .delete-bg {
    opacity: 1;
}

/* Clear Background */
.clear-section {
    text-align: center;
}

.btn-clear-bg {
    background: linear-gradient(45deg, #ff6b6b, #ee5a6f);
    border: none;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-clear-bg:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
    color: white;
}

/* Fullscreen Mode */
:fullscreen {
    background: #000;
}

:fullscreen .mirror-header {
    display: none;
}

:fullscreen .mirror-container {
    height: 100vh;
    padding-top: 0;
}

:fullscreen .camera-container {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mirror-title {
        font-size: 1.4rem;
    }
    
    .settings-panel {
        width: 100%;
        right: -100%;
    }
    
    .camera-container {
        width: 95vw;
        height: 60vh;
    }
    
    .backgrounds-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .btn-fullscreen, .btn-settings {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Scrollbar Styling */
.settings-panel::-webkit-scrollbar {
    width: 6px;
}

.settings-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.settings-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.settings-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
