/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-section i {
    font-size: 1.5rem;
    color: #667eea;
}

.logo-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.built-with {
    color: #667eea;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.built-with:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.device-toggle {
    position: relative;
}

.device-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.device-btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

.device-btn.gpu-enabled {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Camera Section */
.camera-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 0.75rem;
    overflow: hidden;
    aspect-ratio: 4/3;
    margin-bottom: 1.5rem;
}

#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    mix-blend-mode: normal;
}

.video-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    backdrop-filter: blur(10px);
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s infinite;
}

.status-dot.loading {
    background: #f59e0b;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot.info {
    background: #3b82f6;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.frame-rate {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.camera-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

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

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

.control-btn.secondary {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.control-btn.secondary:hover {
    background: rgba(239, 68, 68, 0.2);
}

.control-btn.tertiary {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.control-btn.tertiary:hover {
    background: rgba(107, 114, 128, 0.2);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Control Panel */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.panel-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #374151;
}

.tab-content i {
    color: #667eea;
}

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

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Avatar Styles */
.avatar-styles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.avatar-option:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.avatar-option.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.avatar-preview {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.avatar-preview.cartoon {
    background: linear-gradient(135deg, #FFE4B5, #D2691E);
}

.avatar-preview.realistic {
    background: linear-gradient(135deg, #deb887, #8b7355);
}

.avatar-preview.anime {
    background: linear-gradient(135deg, #ff69b4, #4a90e2);
}

.avatar-preview.custom {
    background: #f3f4f6;
    color: #9ca3af;
}

/* Sliders */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 0.5rem;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6b7280;
}

/* Toggle Switches */
.tracking-toggles {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #e5e7eb;
    border-radius: 12px;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"]:checked + .toggle-slider {
    background: #667eea;
}

input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(20px);
}

input[type="checkbox"] {
    display: none;
}

/* Select Inputs */
.select-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.select-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Background Options */
.background-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.bg-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    text-align: center;
}

.bg-option:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.bg-option.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.bg-option i {
    font-size: 1.25rem;
    color: #667eea;
}

.bg-option span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* File Upload */
.file-upload {
    text-align: center;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.upload-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 0.875rem;
}

.export-btn:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.export-btn i {
    font-size: 1.25rem;
    color: #667eea;
}

.manycam-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.manycam-status i {
    color: #6b7280;
}

.manycam-status.connected {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 2rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.loading-content p {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

/* Error Modal */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.error-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 400px;
    margin: 1rem;
}

.error-content i {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
}

.error-content p {
    color: #6b7280;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.close-btn {
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .control-panel {
        order: -1;
    }
    
    .panel-tabs {
        grid-template-columns: repeat(2, 1fr);
        display: grid;
    }
    
    .tab-btn {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .logo-section h1 {
        font-size: 1.25rem;
    }
    
    .camera-controls {
        flex-wrap: wrap;
    }
    
    .control-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .avatar-styles {
        grid-template-columns: 1fr;
    }
    
    .background-options {
        grid-template-columns: 1fr;
    }
    
    .panel-tabs {
        display: flex;
        overflow-x: auto;
    }
    
    .tab-btn {
        flex: 0 0 auto;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }
    
    .camera-section,
    .control-panel {
        padding: 1rem;
    }
    
    .control-btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    .video-overlay {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .status-indicator {
        padding: 0.375rem 0.75rem;
    }
    
    .frame-rate {
        padding: 0.375rem 0.75rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .status-dot {
        animation: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* Focus states for accessibility */
.control-btn:focus,
.tab-btn:focus,
.export-btn:focus,
.upload-btn:focus,
.avatar-option:focus,
.bg-option:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .app-header {
        background: white;
        border-bottom: 2px solid #000;
    }
    
    .camera-section,
    .control-panel {
        background: white;
        border: 2px solid #000;
    }
    
    .control-btn {
        border: 2px solid #000;
    }
}