/* Virtual Try-On v2 | css/style.css */

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

:root {
    --bg: #08080c;
    --card: rgba(255,255,255,0.03);
    --accent: #00f5d4;
    --pink: #ff006e;
    --text: #fff;
    --muted: rgba(255,255,255,0.5);
    --border: rgba(255,255,255,0.08);
}

body {
    font-family: 'Manrope', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 5% 5%, rgba(131,56,236,0.08) 0%, transparent 40%),
                radial-gradient(ellipse at 95% 95%, rgba(0,245,212,0.05) 0%, transparent 40%);
    pointer-events: none;
}

/* Header - inside camera section */
header {
    position: absolute;
    top: 12px;
    left: 14px;
    z-index: 50;
}

.logo {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.5rem;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Layout */
.container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 10px;
}

/* Camera */
.camera-section {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 4/3;
    max-height: 85vh;
}

.camera-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

#video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}

#canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* Photo mode */
.photo-container {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--bg);
    align-items: center;
    justify-content: center;
}

.photo-container.active {
    display: flex;
}

#photoCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.upload-area:hover {
    border-color: var(--accent);
    background: rgba(0,245,212,0.02);
}

.upload-area.hidden { display: none; }

.upload-icon { font-size: 2rem; opacity: 0.5; margin-bottom: 8px; }
.upload-text { font-size: 0.75rem; color: var(--muted); }
.upload-hint { font-size: 0.6rem; color: var(--muted); opacity: 0.5; margin-top: 4px; }

#photoInput { display: none; }

/* Corners */
.scan-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: 0.3s;
}

.scan-overlay.active { opacity: 1; }

.corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
}

.corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

/* Status */
.status {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s infinite;
}

.status-dot.loading { background: #ffd60a; }
.status-dot.error { background: var(--pink); animation: none; }

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

/* Debug - скрыт */
.debug-info {
    display: none;
}

/* Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    padding-right: 4px;
}

.controls-panel::-webkit-scrollbar { width: 3px; }
.controls-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.panel-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.panel-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Mode tabs */
.mode-tabs {
    display: flex;
    gap: 3px;
    background: rgba(0,0,0,0.3);
    padding: 3px;
    border-radius: 7px;
    margin-bottom: 8px;
}

.mode-tab {
    flex: 1;
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: 'Manrope', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.2s;
}

.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--accent); color: var(--bg); }

/* Models */
.models-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.model-item {
    aspect-ratio: 1;
    border-radius: 7px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.15s;
    background: rgba(255,255,255,0.02);
    padding: 3px;
    position: relative;
}

.model-item:hover { border-color: rgba(255,255,255,0.2); }
.model-item.active { border-color: var(--accent); box-shadow: 0 0 20px rgba(0,245,212,0.2); }

.model-item img { width: 100%; height: 100%; object-fit: contain; }

.model-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    font-size: 0.5rem;
    padding: 2px;
    text-align: center;
    color: var(--muted);
    border-radius: 0 0 5px 5px;
}

/* Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--muted);
}

.slider-label span:last-child {
    color: var(--accent);
    font-weight: 600;
    min-width: 35px;
    text-align: right;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.1);
    -webkit-appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent);
}

/* Buttons */
.actions {
    display: flex;
    gap: 5px;
}

.btn {
    flex: 1;
    padding: 9px;
    border: none;
    border-radius: 7px;
    font-family: 'Manrope', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #00c4a7);
    color: var(--bg);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,245,212,0.25);
}

.btn-secondary {
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: rgba(255,255,255,0.08); }

.btn-icon { width: 34px; flex: none; }

/* Loading */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: 0.4s;
}

.loading-screen.hidden { opacity: 0; visibility: hidden; }

.loader {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--muted);
}

/* Flash */
.snapshot-flash {
    position: fixed;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 999;
}

.snapshot-flash.active { animation: flash 0.3s; }

@keyframes flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Mobile */
@media (max-width: 800px) {
    .main-content { 
        grid-template-columns: 1fr;
        gap: 0;
        height: 100vh;
        padding: 0;
    }
    
    .container {
        padding: 0;
    }
    
    header {
        top: 8px;
        left: 10px;
        z-index: 100;
    }
    
    .logo { font-size: 0.75rem; }
    .subtitle { font-size: 0.45rem; }
    
    .camera-section { 
        aspect-ratio: auto;
        max-height: none;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .corner { display: none; }
    
    .status {
        bottom: auto;
        top: 8px;
        right: 10px;
        left: auto;
        transform: none;
        padding: 4px 10px;
        font-size: 0.6rem;
    }
    
    /* Zoom indicator */
    .zoom-indicator {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0,0,0,0.7);
        padding: 10px 20px;
        border-radius: 10px;
        font-size: 1.2rem;
        font-weight: 600;
        color: var(--accent);
        opacity: 0;
        transition: opacity 0.2s;
        pointer-events: none;
        z-index: 50;
    }
    
    .zoom-indicator.show {
        opacity: 1;
    }
    
    /* Controls panel - slide up */
    .controls-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(8,8,12,0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 0 12px 12px;
        border-radius: 20px 20px 0 0;
        border-top: 1px solid var(--border);
        max-height: 60vh;
        transform: translateY(calc(100% - 60px));
        transition: transform 0.3s ease;
        z-index: 200;
        overflow: hidden;
    }
    
    .controls-panel.expanded { 
        transform: translateY(0);
        overflow-y: auto;
    }
    
    .controls-toggle {
        display: flex;
        justify-content: center;
        padding: 12px 0 8px;
        cursor: pointer;
        position: sticky;
        top: 0;
        background: rgba(8,8,12,0.97);
        z-index: 10;
    }
    
    .toggle-handle {
        width: 40px;
        height: 4px;
        background: rgba(255,255,255,0.3);
        border-radius: 2px;
    }
    
    .panel-card {
        padding: 10px;
        border-radius: 10px;
        margin-bottom: 8px;
    }
    
    .panel-title {
        font-size: 0.55rem;
        margin-bottom: 8px;
    }
    
    .mode-tabs {
        margin-bottom: 0;
    }
    
    .mode-tab {
        padding: 8px 6px;
        font-size: 0.7rem;
    }
    
    .models-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    
    .model-item {
        border-radius: 8px;
    }
    
    .model-name {
        font-size: 0.45rem;
        padding: 2px;
    }
    
    .slider-group {
        gap: 8px;
    }
    
    .slider-row {
        gap: 2px;
    }
    
    .slider-label {
        font-size: 0.6rem;
    }
    
    input[type="range"] {
        height: 6px;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }
    
    .actions {
        gap: 6px;
    }
    
    .btn {
        padding: 12px 8px;
        font-size: 0.7rem;
    }
    
    .btn-icon {
        width: 44px;
        font-size: 1.1rem;
    }
    
    /* Quick actions bar - always visible */
    .quick-actions {
        position: fixed;
        bottom: 70px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 10px;
        z-index: 150;
        background: rgba(0,0,0,0.6);
        padding: 8px 12px;
        border-radius: 30px;
        backdrop-filter: blur(10px);
    }
    
    .quick-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: none;
        background: rgba(255,255,255,0.1);
        color: white;
        font-size: 1.2rem;
        cursor: pointer;
        transition: 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .quick-btn:active {
        transform: scale(0.9);
        background: var(--accent);
    }
    
    .quick-btn.primary {
        background: var(--accent);
        color: var(--bg);
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }
}

@media (min-width: 801px) {
    .controls-toggle { display: none; }
    .quick-actions { display: none; }
    .zoom-indicator { display: none; }
}

/* Prevent pull-to-refresh on mobile */
html, body {
    overscroll-behavior: none;
}

/* Touch feedback */
@media (hover: none) {
    .model-item:active {
        transform: scale(0.95);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}
