/* AI Hair Growth Simulator — Neural Lab */
.ai-neural-lab {
    position: relative;
    padding: clamp(60px, 8vw, 100px) 5%;
    background: #050508;
    color: #e8e8e8;
    overflow: hidden;
}

.ai-lab-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(184, 150, 93, 0.18), transparent),
        radial-gradient(circle at 20% 80%, rgba(184, 150, 93, 0.06), transparent 40%),
        linear-gradient(180deg, #0a0a0f 0%, #050508 100%);
    pointer-events: none;
}

.ai-lab-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(184, 150, 93, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(184, 150, 93, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
    animation: ai-grid-drift 24s linear infinite;
}

.ai-lab-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(184, 150, 93, 0.04), transparent);
    animation: ai-sweep 8s ease-in-out infinite;
}

@keyframes ai-grid-drift {
    0% { transform: translateY(0); }
    100% { transform: translateY(48px); }
}

@keyframes ai-sweep {
    0%, 100% { left: -100%; }
    50% { left: 140%; }
}

.ai-lab-container {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
}

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

.ai-lab-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--rp-gold, #b8965d);
    border: 1px solid rgba(184, 150, 93, 0.35);
    background: rgba(184, 150, 93, 0.08);
    margin-bottom: 16px;
}

.ai-lab-badge .ai-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 12px #34d399;
    animation: ai-pulse-dot 2s ease infinite;
}

@keyframes ai-pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.ai-lab-header h2 {
    font-family: var(--serif, 'Cormorant Garamond', serif);
    font-size: clamp(2rem, 5vw, 3rem);
    color: #fff;
    margin-bottom: 12px;
}

.ai-lab-header h2 span {
    background: linear-gradient(135deg, #b8965d, #ffdfa4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-lab-header p {
    color: #888;
    max-width: 560px;
    margin: 0 auto;
    font-size: 0.95rem;
}

/* Step rail */
.ai-step-rail {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 36px;
    flex-wrap: wrap;
}

.ai-step-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #555;
    border: 1px solid #222;
    background: rgba(255,255,255,0.02);
    transition: 0.35s;
}

.ai-step-pill.active {
    color: var(--rp-gold, #b8965d);
    border-color: rgba(184, 150, 93, 0.5);
    background: rgba(184, 150, 93, 0.1);
    box-shadow: 0 0 20px rgba(184, 150, 93, 0.15);
}

.ai-step-pill.done {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

.ai-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    background: #1a1a1a;
}

.ai-step-pill.active .ai-step-num { background: var(--rp-gold, #b8965d); color: #000; }
.ai-step-pill.done .ai-step-num { background: #34d399; color: #000; }

/* Main grid */
.ai-lab-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 900px) {
    .ai-lab-grid { grid-template-columns: 1fr; }
}

.ai-panel {
    border-radius: 20px;
    border: 1px solid rgba(184, 150, 93, 0.15);
    background: rgba(12, 12, 16, 0.85);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.ai-panel-controls { padding: 24px; }

/* Dropzone */
.ai-dropzone {
    position: relative;
    border: 2px dashed rgba(184, 150, 93, 0.35);
    border-radius: 16px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: 0.35s;
    margin-bottom: 20px;
}

.ai-dropzone:hover,
.ai-dropzone.drag-over {
    border-color: var(--rp-gold, #b8965d);
    background: rgba(184, 150, 93, 0.06);
    box-shadow: 0 0 30px rgba(184, 150, 93, 0.1);
}

.ai-dropzone.has-image {
    padding: 0;
    border-style: solid;
    aspect-ratio: 4/3;
}

.ai-dropzone-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
    display: none;
}

.ai-dropzone.has-image .ai-dropzone-thumb { display: block; }
.ai-dropzone.has-image .ai-dropzone-copy { display: none; }

.ai-dropzone-icon {
    font-size: 2rem;
    color: var(--rp-gold, #b8965d);
    margin-bottom: 10px;
}

.ai-dropzone-copy h4 {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 6px;
}

.ai-dropzone-copy p {
    font-size: 0.75rem;
    color: #666;
}

.ai-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Quality meter */
.ai-quality-block {
    margin-bottom: 22px;
}

.ai-quality-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 8px;
}

.ai-quality-label strong { color: var(--rp-gold, #b8965d); }

.ai-quality-track {
    height: 6px;
    background: #1a1a1a;
    border-radius: 3px;
    overflow: hidden;
}

.ai-quality-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #34d399);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ai-quality-tips {
    font-size: 0.72rem;
    color: #555;
    margin-top: 8px;
    line-height: 1.5;
}

.ai-quality-tips.ok { color: #34d399; }

/* Preferences */
.ai-prefs-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #666;
    margin-bottom: 12px;
}

.ai-segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.ai-segment-btn {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    background: #111;
    color: #888;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.25s;
}

.ai-segment-btn.active {
    border-color: var(--rp-gold, #b8965d);
    color: #fff;
    background: rgba(184, 150, 93, 0.15);
}

.ai-style-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.ai-chip {
    padding: 8px 14px;
    border-radius: 50px;
    border: 1px solid #2a2a2a;
    background: transparent;
    color: #888;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.25s;
}

.ai-chip.active {
    border-color: var(--rp-gold, #b8965d);
    color: var(--rp-gold, #b8965d);
    background: rgba(184, 150, 93, 0.1);
}

.ai-density-row {
    margin-bottom: 20px;
}

.ai-density-row label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 8px;
}

.ai-density-row input[type="range"] {
    width: 100%;
    accent-color: var(--rp-gold, #b8965d);
}

/* Generate button */
.ai-generate-btn {
    position: relative;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #8a6e2f, #b8965d, #d4b87a);
    color: #0a0a0a;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    overflow: hidden;
    transition: 0.35s;
}

.ai-generate-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.ai-generate-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(184, 150, 93, 0.35);
}

.ai-generate-btn .ai-btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: ai-btn-shine 3s ease infinite;
}

@keyframes ai-btn-shine {
    0% { left: -100%; }
    50%, 100% { left: 150%; }
}

/* Viewport */
.ai-panel-viewport { padding: 20px; }

.ai-viewport-frame {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 16px;
    overflow: hidden;
    background: #0a0a0c;
    border: 1px solid rgba(184, 150, 93, 0.2);
    box-shadow: 0 0 60px rgba(184, 150, 93, 0.08), inset 0 0 80px rgba(0,0,0,0.5);
}

.ai-viewport-frame::before {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(184, 150, 93, 0.15);
    border-radius: 10px;
    pointer-events: none;
    z-index: 4;
}

.ai-viewport-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--rp-gold, #b8965d);
    border-style: solid;
    z-index: 5;
    pointer-events: none;
    opacity: 0.6;
}

.ai-viewport-corner.tl { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.ai-viewport-corner.tr { top: 8px; right: 8px; border-width: 2px 2px 0 0; }
.ai-viewport-corner.bl { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; }
.ai-viewport-corner.br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }

.ai-preview-img,
.ai-result-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.ai-preview-img.visible { display: block; z-index: 1; }

.ai-result-compare {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
}

.ai-result-compare.active { display: block; }

.ai-result-compare .ba-layer { position: absolute; inset: 0; }
.ai-result-compare .ba-after { z-index: 1; }
.ai-result-compare .ba-before {
    z-index: 2;
    clip-path: inset(0 50% 0 0);
}
.ai-result-compare img { width: 100%; height: 100%; object-fit: cover; }
.ai-result-compare .ba-range {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: ew-resize; z-index: 6; margin: 0;
}
.ai-result-compare .ba-handle-line {
    position: absolute; top: 0; bottom: 0; left: 50%;
    width: 2px; background: var(--rp-gold, #b8965d);
    z-index: 5; transform: translateX(-50%);
    box-shadow: 0 0 15px rgba(184, 150, 93, 0.8);
    pointer-events: none;
}
.ai-result-compare .ba-handle-line::after {
    content: '◀ ▶';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--rp-gold, #b8965d);
    border: 2px solid #fff;
    font-size: 7px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
}

.ai-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #444;
    z-index: 0;
    text-align: center;
    padding: 20px;
}

.ai-placeholder i {
    font-size: 3rem;
    color: rgba(184, 150, 93, 0.2);
    margin-bottom: 16px;
}

.ai-placeholder p { font-size: 0.85rem; }

.ai-placeholder.hidden { display: none; }

/* Scan overlay */
.ai-scan-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    display: none;
    overflow: hidden;
}

.ai-scan-overlay.active { display: block; }

.ai-scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--rp-gold, #b8965d), transparent);
    box-shadow: 0 0 20px var(--rp-gold, #b8965d);
    animation: ai-scan-move 2.2s ease-in-out infinite;
}

@keyframes ai-scan-move {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.ai-scan-grid {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(184, 150, 93, 0.03) 3px,
        rgba(184, 150, 93, 0.03) 4px
    );
    animation: ai-scan-grid-pulse 1s ease infinite;
}

@keyframes ai-scan-grid-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Loader */
.ai-loader-panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 8, 0.92);
    backdrop-filter: blur(8px);
    padding: 30px;
}

.ai-loader-panel.active { display: flex; }

.ai-loader-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid #222;
    border-top-color: var(--rp-gold, #b8965d);
    animation: ai-spin 0.9s linear infinite;
    margin-bottom: 24px;
}

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

.ai-loader-stage {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rp-gold, #b8965d);
    text-align: center;
    margin-bottom: 16px;
    min-height: 1.2em;
}

.ai-progress-track {
    width: 100%;
    max-width: 280px;
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
    overflow: hidden;
}

.ai-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8a6e2f, #b8965d);
    transition: width 0.4s ease;
    border-radius: 2px;
}

.ai-loader-sub {
    font-size: 0.7rem;
    color: #555;
    margin-top: 12px;
    text-align: center;
}

/* Metrics bar */
.ai-metrics {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.ai-metrics.visible { display: grid; }

.ai-metric {
    text-align: center;
    padding: 12px 8px;
    border-radius: 10px;
    background: rgba(184, 150, 93, 0.06);
    border: 1px solid rgba(184, 150, 93, 0.12);
}

.ai-metric strong {
    display: block;
    font-size: 1.1rem;
    color: var(--rp-gold, #b8965d);
    font-family: var(--serif, 'Cormorant Garamond', serif);
}

.ai-metric span {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
}

/* Toolbar */
.ai-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.ai-toolbar.ready { opacity: 1; }

.ai-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid #333;
    background: #111;
    color: #aaa;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-decoration: none;
    transition: 0.25s;
}

.ai-tool-btn:hover {
    border-color: var(--rp-gold, #b8965d);
    color: #fff;
}

.ai-tool-btn.primary {
    background: #25D366;
    border-color: #25D366;
    color: #fff;
}

.ai-tool-btn:disabled { opacity: 0.3; pointer-events: none; }

@media (max-width: 480px) {
    .ai-metrics { grid-template-columns: 1fr; }
    .ai-panel-controls { padding: 16px; }
}
