/* Virtual Try-On CSS - Modern Light Theme */
:root {
    --bg: #ffffff;
    --fg: #1e293b;
    --muted: #64748b;
    --accent: #0ea5e9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg-secondary: #f8fafc;
    --bg-panel: #fefefe;
    --text-light: #94a3b8;
    --primary: #2563eb;
}

* {
    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, #f8fafc 0%, #e2e8f0 100%);
    color: var(--fg);
    line-height: 1.6;
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 2.5rem;
    font-weight: 700;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    width: 100vw !important;
    height: 100vh !important;
    background: var(--bg);
    display: grid !important;
    grid-template-columns: 1fr 380px !important;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.try-on-area {
    position: relative;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: var(--fg);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    font-size: 18px;
    font-weight: 300;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.camera-switch {
    position: absolute;
    top: 24px;
    right: 80px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.switch-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--primary);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.status-overlay {
    position: absolute;
    top: 24px;
    left: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: var(--primary);
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    border-radius: 0;
}

.glasses-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    transition: all 0.1s ease-out;
}

.glasses-overlay svg {
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
}

.sidebar {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 32px 28px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.control-section {
    flex-shrink: 0;
}

.control-section h3 {
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.status-indicator {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.status-detecting {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.status-calibrated {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.measurement-display {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.05) 0%, rgba(5, 150, 105, 0.1) 100%);
    border: 2px solid rgba(5, 150, 105, 0.2);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.measurement-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 8px;
    letter-spacing: -0.05em;
}

.measurement-confidence {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.control-group {
    margin-bottom: 24px;
}

.control-group label {
    display: block;
    margin-bottom: 12px;
    color: var(--fg);
    font-size: 14px;
    font-weight: 500;
}

.control-group span {
    color: var(--accent);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    outline: none;
    margin: 12px 0;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.glasses-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: none;
    overflow: visible;
}

.glasses-option {
    padding: 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.glasses-option:hover {
    border-color: var(--accent);
    background: rgba(14, 165, 233, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.1);
}

.glasses-option.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.glasses-preview {
    width: 48px;
    height: 24px;
    flex-shrink: 0;
    background: var(--border);
    border-radius: 8px;
}

.glasses-info {
    flex: 1;
}

.glasses-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--fg);
}

.glasses-details {
    font-size: 13px;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 8px;
    width: 100%;
    letter-spacing: -0.025em;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--fg);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #10b981 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.4);
}

/* Face tracking visualization */
.face-landmarks {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
}

.pd-measurement-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, var(--success), var(--accent));
    z-index: 4;
    opacity: 0.9;
    animation: fadeOut 3s ease-out forwards;
}

@keyframes fadeOut {
    0% { opacity: 0.9; }
    70% { opacity: 0.9; }
    100% { opacity: 0; }
}

.pd-measurement-point {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--success);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    animation: fadeOut 3s ease-out forwards;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr auto !important;
        height: 100vh !important;
    }
    
    .sidebar {
        border-left: none !important;
        border-top: 1px solid var(--border) !important;
        max-height: 45vh !important;
        padding: 20px !important;
        gap: 20px !important;
        overflow-y: auto !important;
    }
    
    .control-section {
        margin-bottom: 0 !important;
    }
    
    .glasses-selector {
        max-height: 140px;
        overflow-y: auto;
        gap: 10px;
    }
    
    .glasses-option {
        padding: 12px;
    }
    
    .measurement-display {
        padding: 18px;
        margin-bottom: 16px;
    }
    
    .measurement-value {
        font-size: 28px;
    }
}