/* ================================================================
   AI VIRTUAL TRY-ON - Frontend Widget Styles v2
   Mobile-first, no horizontal overflow, no logo
   ================================================================ */

/* Box-sizing applies to ALL try-on elements */
.smp-tryon-modal, .smp-tryon-modal * { box-sizing: border-box; }

body.smp-tryon-body-lock { overflow: hidden; }

/* Trigger button on product page */
.smp-tryon-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff !important; border: none; padding: 12px 22px;
    border-radius: 8px; font-weight: 600; font-size: 15px;
    cursor: pointer; margin: 12px 0; transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 12px rgba(99,102,241,0.25);
    font-family: inherit; max-width: 100%;
}
.smp-tryon-trigger:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99,102,241,0.4); color: #fff !important; }
.smp-tryon-trigger:active { transform: translateY(0); }

/* Modal */
.smp-tryon-modal {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1e293b;
}
.smp-tryon-modal.smp-tryon-show { opacity: 1; }
.smp-tryon-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.7); backdrop-filter: blur(6px); }
.smp-tryon-dialog {
    position: relative; background: #fff;
    width: min(92vw, 900px); max-height: 92vh;
    border-radius: 16px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}

/* Header — no logo */
.smp-tryon-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #fafafa, #fff);
}
.smp-tryon-title { font-weight: 700; font-size: 16px; color: #1e293b; }
.smp-tryon-close { background: none; border: none; font-size: 26px; cursor: pointer; color: #64748b; line-height: 1; padding: 0 4px; }
.smp-tryon-close:hover { color: #1e293b; }

/* Stepper */
.smp-tryon-stepper {
    display: flex; gap: 4px; padding: 12px 18px;
    background: #f8fafc; border-bottom: 1px solid #e2e8f0;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.smp-tryon-step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #94a3b8; padding: 4px 8px; border-radius: 14px; flex-shrink: 0; }
.smp-tryon-step span { width: 22px; height: 22px; background: #e2e8f0; color: #94a3b8; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.smp-tryon-step.active { color: #6366f1; background: rgba(99,102,241,0.1); }
.smp-tryon-step.active span { background: #6366f1; color: #fff; }
.smp-tryon-step.completed span { background: #10b981; color: #fff; font-size: 0; }
.smp-tryon-step.completed span::before { content: '✓'; font-size: 13px; }

/* Body */
.smp-tryon-body { padding: 18px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.smp-tryon-pane h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; color: #1e293b; }
.smp-tryon-hint { color: #64748b; font-size: 13px; margin: 0 0 14px; line-height: 1.5; }

/* Tabs */
.smp-tryon-tabs { display: flex; gap: 4px; padding: 4px; background: #f1f5f9; border-radius: 8px; margin-bottom: 14px; }
.smp-tryon-tab { flex: 1; background: none; border: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-weight: 500; color: #64748b; font-size: 13px; min-width: 0; font-family: inherit; }
.smp-tryon-tab.active { background: #fff; color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Upload area — using <label> for native file picker support */
.smp-tryon-upload-area {
    position: relative; display: block;
    border: 2px dashed #cbd5e1; border-radius: 12px;
    padding: 28px 16px; text-align: center; cursor: pointer;
    transition: all 0.2s; color: #64748b; background: #fafbfc;
    width: 100%; max-width: 100%;
}
.smp-tryon-upload-area:hover, .smp-tryon-upload-area:focus-within { border-color: #6366f1; background: rgba(99,102,241,0.04); color: #6366f1; }
.smp-tryon-upload-area p { margin: 10px 0 0; font-size: 14px; line-height: 1.4; }
.smp-tryon-upload-area svg { stroke: currentColor; }
.smp-tryon-upload-area img { display: block; margin: 0 auto; }

/* Camera */
.smp-tryon-camera-pane { text-align: center; }
.smp-tryon-camera-pane video, .smp-tryon-camera-pane canvas { max-width: 100%; max-height: 360px; border-radius: 12px; background: #000; display: block; margin: 0 auto; }
.smp-tryon-cam-actions { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Measurements */
.smp-tryon-meas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.smp-tryon-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.smp-tryon-field label { font-size: 12px; font-weight: 600; color: #475569; }
.smp-tryon-field label small { font-weight: 400; color: #94a3b8; }
.smp-tryon-field input, .smp-tryon-field select {
    padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 14px; font-family: inherit; width: 100%; max-width: 100%; min-width: 0;
    background: #fff; color: #1e293b;
}
.smp-tryon-field input:focus, .smp-tryon-field select:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.smp-tryon-inline { display: flex; gap: 6px; min-width: 0; }
.smp-tryon-inline input { flex: 1 1 auto; min-width: 0; }
.smp-tryon-inline select { width: 78px; flex-shrink: 0; }

/* Body photo pane */
.smp-tryon-photo-pane > * { margin-bottom: 12px; }
.smp-tryon-photo-pane > *:last-child { margin-bottom: 0; }
.smp-tryon-instructions-link {
    background: rgba(99,102,241,0.08); color: #6366f1;
    border: 1px solid rgba(99,102,241,0.2);
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px;
}

/* Action bar */
.smp-tryon-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 20px; padding-top: 14px; border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.smp-tryon-btn {
    padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px;
    cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
    white-space: nowrap;
}
.smp-tryon-btn-primary { background: #6366f1; color: #fff; }
.smp-tryon-btn-primary:hover:not(:disabled) { background: #5258e0; }
.smp-tryon-btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.smp-tryon-btn-secondary { background: #fff; color: #475569; border-color: #cbd5e1; }
.smp-tryon-btn-secondary:hover { background: #f8fafc; }

/* Generate loader */
.smp-tryon-loader { text-align: center; padding: 32px 16px; }
.smp-tryon-spinner { width: 50px; height: 50px; margin: 0 auto 18px; border: 4px solid #e2e8f0; border-top-color: #6366f1; border-radius: 50%; animation: smp-tryon-spin 0.9s linear infinite; }
@keyframes smp-tryon-spin { to { transform: rotate(360deg); } }
.smp-tryon-progress { width: 100%; max-width: 320px; margin: 14px auto 8px; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.smp-tryon-progress-bar { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); width: 0%; transition: width 0.5s ease; border-radius: 3px; }
.smp-tryon-progress-text { font-size: 13px; color: #64748b; }

/* Result */
.smp-tryon-result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.smp-tryon-result-image { display: flex; flex-direction: column; min-width: 0; }
.smp-tryon-result-image img { width: 100%; height: auto; max-height: 560px; object-fit: contain; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); background: #f8fafc; }
.smp-tryon-result-buttons { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.smp-tryon-result-buttons .smp-tryon-btn { flex: 1; justify-content: center; min-width: 100px; }
.smp-tryon-saved-pill { font-size: 12px; color: #065f46; background: #d1fae5; padding: 4px 10px; border-radius: 12px; font-weight: 500; flex-shrink: 0; }

.smp-tryon-result-side { font-size: 13px; line-height: 1.5; min-width: 0; }
.smp-tryon-score-mini { display: inline-block; border: 2px solid #6366f1; border-radius: 10px; padding: 10px 18px; margin-bottom: 12px; text-align: center; }
.smp-tryon-verdict { font-style: italic; padding: 10px 12px; background: #f8fafc; border-left: 3px solid #6366f1; border-radius: 0 6px 6px 0; margin-bottom: 10px; font-size: 13px; }
.smp-tryon-detail { padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.smp-tryon-detail strong { color: #1e293b; }
.smp-tryon-detail ul { margin: 6px 0 0; padding-left: 18px; }
.smp-tryon-detail li { margin-bottom: 3px; }
.smp-tryon-meta { margin-top: 10px; font-size: 11px; color: #94a3b8; }

/* Instructions overlay */
.smp-tryon-inst-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.75); backdrop-filter: blur(6px);
    z-index: 1000000; display: flex; align-items: center; justify-content: center;
    padding: 12px;
}
.smp-tryon-inst-card {
    background: #fff; padding: 24px; border-radius: 14px;
    width: min(92vw, 600px); max-height: 88vh; overflow-y: auto;
    position: relative; box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.smp-tryon-inst-card h3 { margin: 0 0 14px; font-size: 18px; }
.smp-tryon-inst-list { padding-left: 20px; font-size: 14px; line-height: 1.6; color: #334155; }
.smp-tryon-inst-list li { margin-bottom: 6px; }
.smp-tryon-inst-samples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.smp-tryon-sample { text-align: center; padding: 10px; border-radius: 10px; border: 1px solid #e2e8f0; }
.smp-tryon-sample-svg svg { width: 70px; height: 112px; display: block; margin: 0 auto 6px; }
.smp-tryon-sample-good { background: #f0fdf4; }
.smp-tryon-sample-bad  { background: #fef2f2; }

/* =========== MOBILE =========== */
@media (max-width: 768px) {
    .smp-tryon-dialog { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
    .smp-tryon-body { padding: 14px; }
    .smp-tryon-head { padding: 12px 14px; }
    .smp-tryon-stepper { padding: 10px 14px; gap: 2px; }
    .smp-tryon-step { font-size: 11px; padding: 3px 6px; }
    .smp-tryon-step span { width: 18px; height: 18px; font-size: 10px; }
    .smp-tryon-result-grid { grid-template-columns: 1fr; gap: 16px; }
    .smp-tryon-result-image img { max-height: 60vh; }
    .smp-tryon-actions { flex-direction: column-reverse; }
    .smp-tryon-actions .smp-tryon-btn { width: 100%; justify-content: center; }
    .smp-tryon-tab { font-size: 12px; padding: 7px 6px; }
    .smp-tryon-meas-grid { grid-template-columns: 1fr; }
    .smp-tryon-inst-card { padding: 18px; }
}

@media (max-width: 480px) {
    .smp-tryon-upload-area { padding: 22px 12px; }
    .smp-tryon-upload-area p { font-size: 13px; }
    .smp-tryon-inst-samples { gap: 8px; }
    .smp-tryon-sample-svg svg { width: 56px; height: 90px; }
}

/* ================================================================
   v3 ADDITIONS: Session UI, History, Category, Fixed Close Button
   ================================================================ */

/* Saved photo preview */
.smp-tryon-saved-preview {
    display: flex; gap: 14px; align-items: center;
    background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(99,102,241,0.04));
    border: 1px solid rgba(16,185,129,0.2);
    padding: 14px; border-radius: 12px; margin-bottom: 14px;
}
.smp-tryon-saved-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.smp-tryon-saved-info { flex: 1; min-width: 0; }
.smp-tryon-saved-info h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: #1e293b; }
.smp-tryon-saved-info p { margin: 0 0 6px; font-size: 12px; color: #64748b; }

.smp-tryon-btn-link {
    background: none !important; border: none !important; padding: 0 !important;
    color: #6366f1 !important; font-size: 13px !important; cursor: pointer;
    text-decoration: underline; font-family: inherit;
}

/* "Saved" pill on tabs */
.smp-tryon-pill-saved {
    display: inline-block; background: #10b981; color: #fff;
    font-size: 9px; padding: 1px 6px; border-radius: 6px;
    margin-left: 4px; font-weight: 700; letter-spacing: 0.3px;
    vertical-align: middle; text-transform: uppercase;
}

/* Category selector */
.smp-tryon-cat-select {
    width: 100%; padding: 10px 12px;
    border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff; color: #1e293b;
}
.smp-tryon-cat-select:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }

/* ISSUE 2 FIX: instruction close button — different class so it doesn't bubble */
.smp-tryon-inst-close-btn {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,0.05); border: none;
    width: 32px; height: 32px; border-radius: 50%;
    font-size: 22px; line-height: 1; cursor: pointer;
    color: #64748b; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.smp-tryon-inst-close-btn:hover { background: rgba(0,0,0,0.1); color: #1e293b; }

/* History strip */
.smp-tryon-history { margin-top: 18px; padding-top: 14px; border-top: 1px dashed #e2e8f0; }
.smp-tryon-history-label { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.smp-tryon-history-strip {
    display: flex; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.smp-tryon-history-item {
    flex: 0 0 80px; cursor: pointer;
    transition: transform 0.15s;
    text-align: center;
}
.smp-tryon-history-item:hover { transform: translateY(-2px); }
.smp-tryon-history-item img {
    width: 80px; height: 100px; object-fit: cover;
    border-radius: 8px; border: 2px solid #e2e8f0;
    transition: border-color 0.15s;
}
.smp-tryon-history-item:hover img { border-color: #6366f1; }
.smp-tryon-history-name { font-size: 10px; color: #64748b; margin-top: 4px; line-height: 1.2; }

@media (max-width: 768px) {
    .smp-tryon-saved-preview { flex-direction: row; padding: 10px; gap: 10px; }
    .smp-tryon-saved-preview img { width: 64px; height: 64px; }
    .smp-tryon-history-item { flex: 0 0 72px; }
    .smp-tryon-history-item img { width: 72px; height: 90px; }
}

/* ================================================================
   v4 ADDITIONS: Mode tabs, inline pose examples, section labels
   ================================================================ */

/* Mode tabs (Step 1 — choose body photo vs measurements) */
.smp-tryon-mode-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-bottom: 16px;
}
.smp-tryon-mode-tab {
    background: #fff; border: 2px solid #e2e8f0; border-radius: 12px;
    padding: 14px 12px; text-align: center; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.smp-tryon-mode-tab:hover { border-color: #cbd5e1; background: #f8fafc; }
.smp-tryon-mode-tab.active {
    border-color: #6366f1; background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04));
    box-shadow: 0 2px 8px rgba(99,102,241,0.15);
}
.smp-tryon-mode-icon { font-size: 28px; margin-bottom: 4px; }
.smp-tryon-mode-title { font-weight: 600; font-size: 14px; color: #1e293b; line-height: 1.2; }
.smp-tryon-mode-desc { font-size: 11px; color: #64748b; line-height: 1.3; }

/* Inline pose examples for body upload */
.smp-tryon-pose-examples {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 12px; margin-bottom: 12px;
}
.smp-tryon-pose-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.smp-tryon-pose {
    text-align: center; padding: 6px 4px; border-radius: 8px;
}
.smp-tryon-pose-good { background: rgba(16,185,129,0.05); }
.smp-tryon-pose-bad  { background: rgba(239,68,68,0.05); }
.smp-tryon-pose-svg svg { width: 100%; height: 80px; display: block; margin: 0 auto 4px; }
.smp-tryon-pose-label { font-size: 11px; color: #475569; line-height: 1.3; }

/* Section labels for the measurements mode */
.smp-tryon-section-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    color: #475569; margin-bottom: 6px;
}

/* Small variant of saved preview (for face inside measurements mode) */
.smp-tryon-saved-preview-small img { width: 56px; height: 56px; }
.smp-tryon-saved-preview-small { padding: 10px; }

@media (max-width: 768px) {
    .smp-tryon-mode-tabs { grid-template-columns: 1fr; }
    .smp-tryon-pose-row { grid-template-columns: repeat(2, 1fr); }
    .smp-tryon-pose-svg svg { height: 70px; }
}
