/* ════════════════════════════════════════════════════════
   Serigest Personalizzazioni – Frontend  v1.1.0
   Design token: stessa palette di Serigest Grid Order
   ════════════════════════════════════════════════════════ */

/* Usa le stesse variabili root definite da sgo-frontend.css;
   fallback se SGO non è caricato */
:root {
    --sp-accent:      var(--sgo-accent,      #16a34a);
    --sp-accent-bg:   var(--sgo-accent-bg,   #f0fdf4);
    --sp-accent-ring: var(--sgo-accent-ring, rgba(22,163,74,.18));
    --sp-border:      var(--sgo-border,      #e4e7ec);
    --sp-bg:          var(--sgo-bg,          #f9fafb);
    --sp-surface:     var(--sgo-surface,     #ffffff);
    --sp-text:        var(--sgo-text,        #111827);
    --sp-muted:       var(--sgo-muted,       #6b7280);
    --sp-danger:      var(--sgo-danger,      #dc2626);
    --sp-radius:      var(--sgo-radius,      8px);
    --sp-font:        var(--sgo-font,        -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif);
}

/* ── Container ──────────────────────────────────────── */
.sp-container {
    margin: 32px 0 0;
    font-family: var(--sp-font);
    font-size: 15px;
    color: var(--sp-text);
    line-height: 1.5;
}

/* ── Section header ─────────────────────────────────── */
.sp-section-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: none;
}

.sp-section-header h3 {
    margin: 0 0 4px;
    font-family: var(--sp-font);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--sp-text);
}

.sp-section-subtitle {
    margin: 0;
    font-family: var(--sp-font);
    font-size: 13px;
    font-weight: 400;
    color: var(--sp-muted);
    line-height: 1.4;
}

/* ── Item card ──────────────────────────────────────── */
.sp-item {
    background: #f5f6f8;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color .15s;
}

.sp-item.is-active {
    border-color: var(--sp-text);
}

/* ── Toggle row ─────────────────────────────────────── */
.sp-item__header { padding: 0; }

.sp-item__toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    cursor: pointer;
    user-select: none;
}

/* Custom checkbox */
.sp-item__toggle input[type="checkbox"] {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--sp-text);
    margin: 0;
}

.sp-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.sp-item__thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--sp-border);
    flex-shrink: 0;
}

/* Placeholder icon when no image */
.sp-item__icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sp-bg);
    border: 1px solid var(--sp-border);
    border-radius: 6px;
}
.sp-item__icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--sp-muted);
}

.sp-toggle-label strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--sp-text);
    display: block;
}

.sp-item__desc {
    display: block;
    font-size: 13px;
    color: var(--sp-muted);
    font-weight: 400;
    margin-top: 1px;
}

.sp-item__price-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--sp-muted);
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Body (expanded) ────────────────────────────────── */
.sp-item__body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--sp-border);
}

/* ── Sub-label ──────────────────────────────────────── */
.sp-item__options-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sp-muted);
    margin: 14px 0 8px;
    display: block;
}
.sp-item__options-label small {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--sp-muted);
    opacity: .7;
}

/* ── Option cards (radio chips) ─────────────────────── */
.sp-item__options { margin-top: 4px; }

.sp-option-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sp-option-card { cursor: pointer; }

.sp-option-card input[type="radio"] { display: none; }

.sp-option-card__inner {
    display: block;
    padding: 7px 14px;
    border: 1px solid var(--sp-border);
    border-radius: 6px;
    background: var(--sp-surface);
    transition: border-color .12s, background .12s, color .12s;
    min-width: 72px;
    text-align: center;
}

.sp-option-card.is-selected .sp-option-card__inner,
.sp-option-card input[type="radio"]:checked + .sp-option-card__inner {
    border-color: var(--sp-text);
    background: var(--sp-text);
    color: #fff;
}

.sp-option-card__inner strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.sp-option-card__price {
    display: block;
    font-size: 11px;
    color: var(--sp-muted);
    margin-top: 2px;
}

.sp-option-card.is-selected .sp-option-card__price,
.sp-option-card input[type="radio"]:checked + .sp-option-card__inner .sp-option-card__price {
    color: rgba(255,255,255,.65);
}

.sp-option-card__price em { font-style: normal; }

.sp-option-card__price:only-child,
.sp-option-card.is-selected .sp-option-card__price,
.sp-option-card input[type="radio"]:checked + .sp-option-card__inner .sp-option-card__price {
    color: rgba(255,255,255,.65);
}

/* ── Artwork upload ─────────────────────────────────── */
.sp-item__artwork { margin-top: 4px; }

.sp-upload-area { margin-top: 8px; }

/* Drop zone */
.sp-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 28px 20px;
    border: 1.5px dashed var(--sp-border);
    border-radius: var(--sp-radius);
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s;
    box-sizing: border-box;
}
.sp-upload-btn:hover {
    border-color: var(--sp-text);
    background: var(--sp-surface);
}

.sp-upload-btn__icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: 8px;
}
.sp-upload-btn__icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--sp-muted);
}

.sp-upload-btn__text {
    text-align: center;
}
.sp-upload-btn__text strong {
    display: block;
    font-family: var(--sp-font);
    font-size: 13px;
    font-weight: 600;
    color: var(--sp-text);
}
.sp-upload-btn__text span {
    display: block;
    font-family: var(--sp-font);
    font-size: 11px;
    color: var(--sp-muted);
    margin-top: 2px;
}

/* Preview (after upload) */
.sp-upload-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--sp-bg);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
}

.sp-upload-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--sp-border);
    flex-shrink: 0;
    background: var(--sp-surface);
}

.sp-upload-name {
    flex: 1;
    font-family: var(--sp-font);
    font-size: 13px;
    font-weight: 500;
    color: var(--sp-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-upload-doc-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    color: #4f46e5;
}

.sp-upload-doc-ext {
    font-family: var(--sp-font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #4f46e5;
    line-height: 1;
}

.sp-upload-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--sp-danger);
    padding: 0;
    flex-shrink: 0;
    transition: background .12s, border-color .12s;
}
.sp-upload-remove:hover {
    background: #fef2f2;
    border-color: var(--sp-danger);
}
.sp-upload-remove svg {
    width: 10px;
    height: 10px;
    stroke: currentColor;
}

.sp-upload-status {
    font-family: var(--sp-font);
    font-size: 11px;
    color: var(--sp-muted);
    margin-top: 6px;
    min-height: 16px;
}

/* ── Upload progress bar ────────────────────────────── */
.sp-upload-progress {
    margin-top: 10px;
    height: 3px;
    border-radius: 100px;
    background: var(--sp-border);
    overflow: hidden;
    display: none;
}

.sp-upload-progress.is-active {
    display: block;
}

.sp-upload-progress__fill {
    height: 100%;
    width: 0%;
    border-radius: 100px;
    background: var(--sp-text);
    transition: width .25s ease;
    animation: sp-progress-indeterminate 1.4s ease infinite;
}

@keyframes sp-progress-indeterminate {
    0%   { transform: translateX(-100%); width: 60%; }
    50%  { transform: translateX(80%);   width: 60%; }
    100% { transform: translateX(200%);  width: 60%; }
}

.sp-upload-progress.is-done .sp-upload-progress__fill {
    animation: none;
    width: 100%;
    background: var(--sp-accent);
    transition: width .2s ease;
}

/* ── Note textarea ──────────────────────────────────── */
.sp-item__note { margin-top: 4px; }

.sp-note-field {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--sp-border);
    border-radius: 6px;
    font-family: var(--sp-font);
    font-size: 13px;
    color: var(--sp-text);
    background: var(--sp-surface);
    resize: vertical;
    margin-top: 6px;
    transition: border-color .12s;
}
.sp-note-field::placeholder { color: var(--sp-muted); opacity: .7; }
.sp-note-field:focus {
    outline: none;
    border-color: var(--sp-text);
}

/* ── Extra summary bar ──────────────────────────────── */
.sp-extra-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding: 11px 14px;
    background: var(--sp-bg);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    font-family: var(--sp-font);
    font-size: 13px;
}

.sp-extra-summary__label {
    color: var(--sp-muted);
    font-weight: 500;
    flex: 1;
}

.sp-extra-summary__amount {
    color: var(--sp-text);
    font-weight: 700;
    font-size: 15px;
}

.sp-extra-summary__note {
    color: var(--sp-muted);
    font-size: 11px;
    flex-basis: 100%;
}

/* ── Desktop: colonna singola ───────────────────────── */
@media (min-width: 641px) {
    .sp-container {
        display: block;
    }
    .sp-section-header {
        margin-bottom: 0;
    }
    .sp-item {
        margin-bottom: 8px;
    }
    /* Icona SVG leggermente più grande su desktop */
    .sp-item__icon svg {
        width: 32px;
        height: 32px;
    }
    .sp-item__toggle {
        padding: 14px 16px;
        gap: 14px;
    }
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
    .sp-option-cards {
        flex-direction: column;
    }
    .sp-option-card__inner {
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}
