/* ============================================
   Pixia - Image to Vector Studio (VTracer)
   (loaded only on image-to-vector.html)
   Complements css/ai-tool.css (.at-* primitives)
   Scope: body.at-vector
   Accent: cyan / blue
   ============================================ */

body.at-vector {
    --vt-accent: #06b6d4;
    --vt-accent-2: #3b82f6;
    --vt-accent-ink: #ffffff;
    --vt-shadow: 0 16px 34px -18px rgba(6, 182, 212, .6);
}

body.at-vector [hidden] { display: none !important; }

body.at-vector .at-kicker {
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    color: #ffffff;
}
body.at-vector .at-btn {
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    color: #ffffff;
    box-shadow: var(--vt-shadow);
}
body.at-vector .at-btn-alt {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}

/* ---------- Layout ---------- */
body.at-vector .vt-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
}

.vt-center,
.vt-right {
    min-width: 0;
    display: grid;
    gap: 16px;
    align-content: start;
}

.vt-center {
    position: sticky;
    inset-block-start: 84px;
    align-self: start;
}

body.at-vector .at-panel { min-height: 0; min-width: 0; }

.vt-panel h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-size: 1.02rem;
    letter-spacing: -.015em;
}

/* ---------- Dropzone ---------- */
.vt-drop {
    display: grid;
    place-items: center;
    gap: 8px;
    text-align: center;
    padding: 30px 16px;
    border-radius: var(--at-radius-lg, 18px);
    border: 1.5px dashed var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-tertiary);
    font-size: 13px;
    line-height: 1.6;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.vt-drop:hover, .vt-drop.is-dragover { border-color: var(--vt-accent); background: color-mix(in srgb, var(--vt-accent) 8%, var(--glass-bg)); color: var(--vt-accent); }
.vt-drop svg { width: 36px; height: 36px; }
.vt-drop strong { font-weight: 700; color: var(--text-secondary); display: block; font-size: 14px; }
.vt-drop em { font-style: normal; font-size: 12px; opacity: .85; }

/* ---------- Buttons ---------- */
.vt-btn-grid { margin-block-start: 12px; display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.vt-btn-grid .at-btn { width: 100%; padding: 12px 14px; font-size: 14px; }

/* ---------- Fields ---------- */
.vt-field { margin-block-start: 14px; }
.vt-field:first-child { margin-block-start: 0; }

.vt-legend { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--text-secondary); margin-block-end: 9px; }

.vt-range-row { display: flex; align-items: center; gap: 12px; }
.vt-range-row input[type="range"] { flex: 1; accent-color: var(--vt-accent); }
.vt-range-row output { min-width: 44px; text-align: end; font-size: 12.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.vt-hint { margin: 9px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-muted); }

/* ---------- Segmented control ---------- */
.vt-seg { display: flex; gap: 6px; }
.vt-seg button {
    flex: 1 1 0;
    padding: 10px 6px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: var(--glass-bg);
    color: var(--text-secondary);
    font: 600 13px/1.15 var(--font-primary);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.vt-seg button:hover { color: var(--text-primary); }
.vt-seg button.is-active {
    color: var(--vt-accent);
    border-color: var(--vt-accent);
    background: color-mix(in srgb, var(--vt-accent) 10%, var(--glass-bg));
}
.vt-seg-wrap { flex-wrap: wrap; }
.vt-seg-wrap button { flex: 1 1 calc(33.333% - 6px); }

/* ---------- Advanced ---------- */
.vt-adv {
    margin-block-start: 16px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: var(--glass-bg);
}
.vt-adv > summary {
    list-style: none;
    cursor: pointer;
    padding: 11px 14px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.vt-adv > summary::-webkit-details-marker { display: none; }
.vt-adv > summary::after {
    content: "";
    width: 7px; height: 7px;
    margin-inline-start: auto;
    border-inline-end: 1.6px solid currentColor;
    border-block-end: 1.6px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .2s var(--at-ease, ease);
}
.vt-adv[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.vt-adv > summary:hover { color: var(--vt-accent); }
.vt-adv-body { padding: 4px 14px 14px; }

/* ---------- Stage / preview ---------- */
.vt-stage-panel { display: flex; flex-direction: column; }
.vt-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 12px; }
.vt-stage-head h2 { margin: 0; }

.vt-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass-bg); }
.vt-tabs button {
    padding: 7px 16px;
    border: 0; border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font: 600 12.5px/1 var(--font-primary);
    cursor: pointer;
    transition: color .15s, background .15s;
}
.vt-tabs button.is-active { background: var(--bg-card-hover); color: var(--text-primary); }
.vt-tabs button:disabled { opacity: .4; cursor: not-allowed; }

.vt-stage {
    position: relative;
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border-radius: var(--at-radius-lg, 18px);
    border: 1px solid var(--glass-border);
    background: repeating-conic-gradient(rgba(128, 128, 128, .08) 0% 25%, transparent 0% 50%) 50% / 22px 22px;
    overflow: hidden;
}
.vt-stage.is-white { background: #ffffff; }
.vt-stage-empty { display: grid; place-items: center; color: var(--text-muted); }
.vt-stage-empty svg { width: 64px; height: 64px; opacity: .5; }

.vt-stage-img {
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    border-radius: 8px;
    display: none;
    box-shadow: 0 8px 30px -12px rgba(0, 0, 0, .3);
}
.vt-stage-img.is-visible { display: block; }

.vt-stage-svg {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
.vt-stage-svg.is-visible { display: flex; }
.vt-stage-svg svg { max-width: 100%; max-height: 480px; width: auto; height: auto; display: block; }

.vt-stage-busy {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    background: color-mix(in srgb, var(--bg-primary) 62%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 3;
}
.vt-stage-busy em { font-style: normal; font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.vt-spinner {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 3px solid var(--glass-border);
    border-block-start-color: var(--vt-accent);
    animation: vtSpin .7s linear infinite;
}
@keyframes vtSpin { to { transform: rotate(360deg); } }

.vt-stage-info {
    margin-block-start: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--text-tertiary);
}
.vt-stage-name { font-weight: 600; color: var(--text-secondary); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vt-stage-dims, .vt-stage-size { font-variant-numeric: tabular-nums; }

/* ---------- Export / progress ---------- */
.vt-export { display: grid; gap: 12px; }
.vt-convert { width: 100%; padding: 13px 14px; font-size: 14.5px; }

.vt-progress { display: grid; gap: 8px; }
.vt-progress-bar { height: 6px; border-radius: 99px; background: var(--glass-border); overflow: hidden; }
.vt-progress-fill { height: 100%; width: 40%; border-radius: 99px; background: linear-gradient(90deg, var(--vt-accent), var(--vt-accent-2)); animation: vtPulse 1s ease-in-out infinite alternate; transition: width .2s ease; }
@keyframes vtPulse { from { opacity: .55; } to { opacity: 1; } }
.vt-progress-msg { font-size: 12.5px; color: var(--text-tertiary); text-align: center; }

/* ---------- Stats ---------- */
.vt-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-block-end: 14px;
}
.vt-stat {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: var(--glass-bg);
    min-width: 0;
}
.vt-stat strong {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vt-stat span { font-size: 11.5px; color: var(--text-muted); }

.vt-actions { display: grid; gap: 9px; grid-template-columns: 1fr 1fr; }
.vt-actions .at-btn { width: 100%; padding: 12px 14px; font-size: 13.5px; }
.vt-actions .at-btn:first-child { grid-column: 1 / -1; }
.vt-copy { grid-column: 1 / -1; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    body.at-vector .vt-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 940px) {
    body.at-vector .vt-layout { grid-template-columns: 1fr; }
    .vt-center { order: 1; position: static; }
    .vt-right { order: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .vt-right > .at-panel:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .vt-right { grid-template-columns: 1fr; }
    .vt-stage { min-height: 300px; }
    .vt-stage-img, .vt-stage-svg svg { max-height: 300px; }
    .vt-seg-wrap button { flex: 1 1 calc(50% - 6px); }
    .vt-actions { grid-template-columns: 1fr; }
}
