/* ─── AI Fit Checker — Frontend Widget ──────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Playfair+Display:wght@600&display=swap');

:root {
    --afc-bg:       #fafaf8;
    --afc-surface:  #ffffff;
    --afc-border:   #e8e4df;
    --afc-dark:     #1a1a1a;
    --afc-accent:   #6b4f9e;
    --afc-accent2:  #8b6fbe;
    --afc-gold:     #c9a96e;
    --afc-text:     #2a2a2a;
    --afc-muted:    #888;
    --afc-success:  #22c55e;
    --afc-danger:   #ef4444;
    --afc-r:        14px;
}

/* ── Widget Container ──────────────────────────────────────────── */
.afc-widget {
    font-family: 'DM Sans', sans-serif;
    background: var(--afc-bg);
    border: 1px solid var(--afc-border);
    border-radius: var(--afc-r);
    overflow: hidden;
    margin: 20px 0;
    position: relative;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* ── Widget Header ─────────────────────────────────────────────── */
.afc-widget-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--afc-accent) 0%, var(--afc-accent2) 100%);
    color: #fff;
    position: relative;
}
.afc-widget-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.afc-widget-icon svg { width: 22px; height: 22px; }
.afc-widget-title {
    font-size: 16px; font-weight: 700; letter-spacing: 0.01em;
}
.afc-widget-sub {
    font-size: 12px; opacity: 0.8; margin-top: 1px;
}
.afc-ai-badge {
    margin-left: auto; flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 6px; padding: 3px 10px;
    font-size: 11px; font-weight: 800;
    letter-spacing: 0.12em;
}

/* ── Steps ─────────────────────────────────────────────────────── */
.afc-step {
    padding: 18px 20px;
    border-bottom: 1px solid var(--afc-border);
    transition: opacity 0.3s;
}
.afc-step-locked {
    opacity: 0.4;
    pointer-events: none;
}
.afc-step-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--afc-text);
}
.afc-step-num {
    width: 24px; height: 24px;
    background: var(--afc-accent);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 800;
    flex-shrink: 0;
}

/* ── Size Selector ─────────────────────────────────────────────── */
.afc-size-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.afc-size-btn {
    min-width: 52px; height: 44px;
    border: 1.5px solid var(--afc-border);
    border-radius: 8px;
    background: var(--afc-surface);
    color: var(--afc-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    padding: 0 10px;
}
.afc-size-btn:hover {
    border-color: var(--afc-accent);
    color: var(--afc-accent);
}
.afc-size-btn.selected {
    background: var(--afc-accent);
    border-color: var(--afc-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(107,79,158,0.35);
    transform: translateY(-1px);
}

/* ── Upload Zone ───────────────────────────────────────────────── */
.afc-upload-zone {
    border: 2px dashed var(--afc-border);
    border-radius: 10px;
    min-height: 110px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative; overflow: hidden;
}
.afc-upload-zone:hover, .afc-upload-zone.drag-over {
    border-color: var(--afc-accent);
    background: rgba(107,79,158,0.04);
}
.afc-upload-label {
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    width: 100%;
}
.afc-upload-inner {
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    padding: 20px;
    text-align: center;
}
.afc-upload-icon svg {
    width: 32px; height: 32px;
    stroke: var(--afc-muted);
}
.afc-upload-text { font-size: 14px; color: var(--afc-text); margin: 0; }
.afc-upload-link { color: var(--afc-accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.afc-upload-hint { font-size: 12px; color: var(--afc-muted); margin: 0; }

.afc-preview-wrap {
    width: 100%; height: 160px;
    position: relative; overflow: hidden;
}
#afcUserPreview {
    width: 100%; height: 100%; object-fit: cover;
}
.afc-remove-photo {
    position: absolute; top: 8px; right: 8px;
    width: 28px; height: 28px;
    background: rgba(0,0,0,0.6); color: #fff;
    border: none; border-radius: 50%;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.afc-remove-photo:hover { background: rgba(239,68,68,0.8); }

/* ── CTA Button ────────────────────────────────────────────────── */
.afc-check-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    width: calc(100% - 40px);
    margin: 16px 20px;
    padding: 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--afc-accent), var(--afc-accent2));
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px; font-weight: 700;
    border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(107,79,158,0.35);
    transition: all 0.2s;
}
.afc-check-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(107,79,158,0.45);
}
.afc-check-btn:disabled {
    opacity: 0.45; cursor: not-allowed;
    box-shadow: none; transform: none;
}
.afc-btn-sparkle { font-size: 18px; }

/* ── Processing Overlay ────────────────────────────────────────── */
.afc-processing {
    position: fixed; inset: 0;
    background: rgba(15,15,17,0.93);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 999998;
}
.afc-processing-inner {
    display: flex; flex-direction: column;
    align-items: center; gap: 20px;
    padding: 48px 40px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    background: #1a1a1f;
    border: 1px solid rgba(107,79,158,0.3);
    border-radius: 20px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.afc-processing-dots span:nth-child(2) { animation-delay: 0.2s; }
.afc-processing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes afc-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1); opacity: 1; }
}
.afc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--afc-accent), var(--afc-accent2));
    border-radius: 99px;
    width: 0%;
    transition: width 0.4s ease;
}

/* Scanner animation */
.afc-scanner {
    width: 160px; height: 190px;
    position: relative; margin-bottom: 4px;
    border: 1.5px solid rgba(139,111,190,0.4);
    border-radius: 10px; overflow: hidden;
    background: rgba(107,79,158,0.07);
}
.afc-scan-user {
    position: absolute; inset: 0;
    background-size: cover; background-position: center top;
    opacity: 0.35;
}
.afc-scan-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(107,79,158,0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(107,79,158,0.1) 1px, transparent 1px);
    background-size: 16px 16px;
}
.afc-scan-line {
    position: absolute; left: 0; right: 0; top: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--afc-accent), transparent);
    box-shadow: 0 0 12px var(--afc-accent);
    animation: afc-scan 1.8s linear infinite;
}
@keyframes afc-scan {
    0%   { top: 0; opacity: 1; }
    90%  { top: 100%; opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.afc-processing-text {
    font-size: 18px; font-weight: 700;
    color: #ffffff;
    min-height: 28px;
    transition: opacity 0.4s;
}
.afc-processing-dots span {
    width: 8px; height: 8px;
    background: var(--afc-accent2);
    border-radius: 50%;
    animation: afc-dot 1.2s ease-in-out infinite;
}
.afc-progress-bar {
    width: 280px; height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 99px; overflow: hidden;
}
.afc-processing-sub {
    font-size: 13px; color: rgba(255,255,255,0.45);
}

/* ── Result Panel ──────────────────────────────────────────────── */
.afc-result {
    padding: 20px;
    animation: afc-fade-up 0.5s ease;
}
@keyframes afc-fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.afc-result-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.afc-result-check {
    width: 36px; height: 36px;
    background: var(--afc-success);
    border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.afc-result-title {
    font-size: 16px; font-weight: 700; color: var(--afc-text);
}
.afc-result-sub { font-size: 13px; color: var(--afc-muted); margin-top: 2px; }

.afc-result-body {
    display: flex; gap: 16px; align-items: flex-start;
    margin-bottom: 16px;
}
.afc-result-image-wrap {
    width: 140px; flex-shrink: 0;
    border-radius: 10px; overflow: hidden;
    position: relative;
    border: 1px solid var(--afc-border);
}
#afcResultImage { width: 100%; display: block; }
.afc-result-size-tag {
    position: absolute; top: 8px; left: 8px;
    background: var(--afc-accent); color: #fff;
    font-size: 11px; font-weight: 800;
    padding: 3px 10px; border-radius: 99px;
    letter-spacing: 0.06em;
}

.afc-result-meta { flex: 1; }
.afc-fit-score { margin-bottom: 12px; }
.afc-fit-score-label {
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--afc-muted);
    margin-bottom: 4px;
}
.afc-fit-score-val {
    font-size: 36px; font-weight: 800;
    color: var(--afc-accent);
    line-height: 1;
}
.afc-fit-notes {
    font-size: 13px; color: var(--afc-text);
    line-height: 1.6;
}

.afc-try-again {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px;
    border: 1.5px solid var(--afc-border);
    background: transparent; color: var(--afc-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.afc-try-again:hover { border-color: var(--afc-accent); color: var(--afc-accent); }

/* ── Zoom Hint ──────────────────────────────────────────────────── */
.afc-result-image-wrap {
    cursor: zoom-in;
}
.afc-zoom-hint {
    position: absolute; bottom: 8px; left: 0; right: 0;
    text-align: center;
    font-size: 11px; font-weight: 600;
    color: #fff;
    background: rgba(0,0,0,0.45);
    padding: 4px 0;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.afc-result-image-wrap:hover .afc-zoom-hint { opacity: 1; }

/* ── Lightbox ───────────────────────────────────────────────────── */
.afc-lightbox {
    position: fixed; inset: 0;
    z-index: 999999;
    display: flex; align-items: center; justify-content: center;
}
.afc-lightbox-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(6px);
    cursor: zoom-out;
    animation: afc-fade 0.25s ease;
}
.afc-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: afc-lb-pop 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
    display: flex; align-items: center; justify-content: center;
}
@keyframes afc-lb-pop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
#afcLightboxImage {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 12px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    display: block;
    object-fit: contain;
}
.afc-lightbox-close {
    position: absolute; top: -14px; right: -14px;
    width: 36px; height: 36px;
    background: #fff; color: #111;
    border: none; border-radius: 50%;
    font-size: 14px; font-weight: 700;
    cursor: pointer; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transition: background 0.15s, transform 0.15s;
}
.afc-lightbox-close:hover { background: #f0f0f0; transform: scale(1.1); }
.afc-lightbox-size-tag {
    position: absolute; top: -14px; left: 0;
    background: var(--afc-accent); color: #fff;
    font-size: 12px; font-weight: 800;
    padding: 4px 14px; border-radius: 99px;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 12px rgba(107,79,158,0.4);
}
.afc-popup-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 999997;
    backdrop-filter: blur(3px);
    animation: afc-fade 0.3s ease;
}
@keyframes afc-fade { from { opacity: 0; } to { opacity: 1; } }

.afc-popup {
    background: var(--afc-surface);
    border-radius: 16px;
    padding: 28px 24px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.2);
    animation: afc-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes afc-pop {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.afc-popup-emoji { font-size: 40px; margin-bottom: 8px; }
.afc-popup-title {
    font-size: 20px; font-weight: 800;
    color: var(--afc-text); margin-bottom: 10px;
}
.afc-popup-body {
    font-size: 13px; color: var(--afc-muted);
    line-height: 1.65; margin-bottom: 20px;
}
.afc-popup-body strong { color: var(--afc-text); }
.afc-popup-actions { display: flex; flex-direction: column; gap: 8px; }
.afc-popup-upgrade {
    padding: 11px; border-radius: 9px;
    background: var(--afc-accent); color: #fff;
    border: none; font-family: 'DM Sans', sans-serif;
    font-size: 14px; font-weight: 700; cursor: pointer;
    transition: background 0.2s;
}
.afc-popup-upgrade:hover { background: var(--afc-accent2); }
.afc-popup-dismiss {
    padding: 11px; border-radius: 9px;
    background: transparent; color: var(--afc-muted);
    border: 1.5px solid var(--afc-border);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; cursor: pointer;
    transition: all 0.2s;
}
.afc-popup-dismiss:hover { border-color: var(--afc-muted); color: var(--afc-text); }
