/* ====================================================================
 * Assistant taille IA — aligné sur le design .psp (fiche produit Primtee)
 * ================================================================== */

/* Badge IA (bouton + modale) */
.psp__ai-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 20px;
    height: 16px;
    padding: 0 5px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, #4338ca 0%, #6366f1 45%, #7c3aed 100%);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(67, 56, 202, 0.35);
    vertical-align: middle;
}

.psp__ai-badge--modal {
    min-width: 24px;
    height: 20px;
    padding: 0 7px;
    font-size: 10px;
    border-radius: 5px;
}

/* Bouton déclencheur (fiche produit) */
.psp__attribute-head .psp__size-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 6px 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--psp-fg, #0b0b0b);
    background: transparent;
    border: 0;
    border-bottom: 1px solid currentColor;
    border-radius: 0;
    cursor: pointer;
    transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.psp__attribute-head .psp__size-ai-btn:hover {
    opacity: 0.65;
}

.psp__attribute-head .psp__size-ai-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.psp__attribute-head .psp__size-ai-btn .psp__ai-badge {
    margin-left: 2px;
}

.psp__attribute-head {
    flex-wrap: wrap;
    gap: 8px;
}

/* ------------------------------------------------------------------
 * Modal (tokens identiques à .psp)
 * ---------------------------------------------------------------- */
.psp-size-modal {
    --psp-fg: #0b0b0b;
    --psp-muted: #6e7480;
    --psp-line: rgba(15, 15, 15, 0.08);
    --psp-line-strong: rgba(15, 15, 15, 0.14);
    --psp-bg: #ffffff;
    --psp-bg-soft: #f4f4f2;
    --psp-radius-xl: 22px;
    --psp-radius-lg: 18px;
    --psp-radius-md: 14px;
    --psp-radius-sm: 10px;
    --psp-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --psp-transition: 320ms var(--psp-ease);
    --psp-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06), 0 20px 44px rgba(0, 0, 0, 0.08);
    --psp-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08), 0 30px 60px rgba(0, 0, 0, 0.12);

    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 24px);
    box-sizing: border-box;
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
}

.psp-size-modal[hidden] {
    display: none !important;
}

body.psp-size-modal-open {
    overflow: hidden;
}

.psp-size-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 11, 11, 0.52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: pspSizeFadeIn 280ms var(--psp-ease);
}

.psp-size-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: min(92vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--psp-bg);
    border-radius: var(--psp-radius-xl);
    box-shadow: var(--psp-shadow-lg);
    border: 1px solid var(--psp-line);
    overflow: hidden;
    animation: pspSizeSlideUp 360ms var(--psp-ease);
}

.psp-size-modal__dialog::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4338ca 0%, #6366f1 50%, #7c3aed 100%);
    pointer-events: none;
    z-index: 1;
}

@keyframes pspSizeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pspSizeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* En-tête */
.psp-size-modal__head {
    flex: 0 0 auto;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--psp-line);
    background: var(--psp-bg);
}

.psp-size-modal__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.psp-size-modal__guide-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--psp-fg);
    text-decoration: none;
    background: var(--psp-bg-soft);
    border: 1px solid var(--psp-line);
    border-radius: var(--psp-radius-sm);
    transition: background var(--psp-transition), border-color var(--psp-transition), transform var(--psp-transition);
}

.psp-size-modal__guide-link:hover {
    background: #fff;
    border-color: var(--psp-line-strong);
    color: var(--psp-fg);
    transform: translateY(-1px);
}

.psp-size-modal__guide-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.psp-size-modal__guide-external {
    width: 12px !important;
    height: 12px !important;
    opacity: 0.55;
}

.psp-size-modal__close {
    appearance: none;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--psp-line);
    border-radius: 50%;
    background: #fff;
    color: var(--psp-fg);
    cursor: pointer;
    transition: background var(--psp-transition), border-color var(--psp-transition);
}

.psp-size-modal__close:hover {
    background: var(--psp-bg-soft);
    border-color: var(--psp-line-strong);
}

.psp-size-modal__close svg {
    width: 18px;
    height: 18px;
}

.psp-size-modal__title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.psp-size-modal__title {
    margin: 0;
    font-size: clamp(20px, 4vw, 24px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--psp-fg);
}

.psp-size-modal__subtitle {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--psp-muted);
    font-weight: 400;
}

.psp-size-modal__hint {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--psp-muted);
}

/* Corps scrollable */
.psp-size-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.psp-size-modal__section {
    margin-bottom: 22px;
}

.psp-size-modal__section:last-of-type {
    margin-bottom: 18px;
}

.psp-size-modal__section-title {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--psp-muted);
}

/* Champs */
.psp-size-modal__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.psp-size-field {
    display: block;
}

.psp-size-field--full {
    margin-top: 14px;
}

.psp-size-field__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--psp-fg);
}

.psp-size-field__label--inline {
    margin-bottom: 10px;
}

.psp-size-field__input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--psp-fg);
    background: #fff;
    border: 1px solid var(--psp-line-strong);
    border-radius: var(--psp-radius-md);
    box-sizing: border-box;
    transition: border-color var(--psp-transition), box-shadow var(--psp-transition);
}

.psp-size-field__input::placeholder {
    color: var(--psp-muted);
    font-weight: 400;
}

.psp-size-field__input:hover {
    border-color: rgba(15, 15, 15, 0.22);
}

.psp-size-field__input:focus {
    outline: none;
    border-color: var(--psp-fg);
    box-shadow: 0 0 0 3px rgba(11, 11, 11, 0.08);
}

/* Chips (style psp__option) */
.psp-size-modal__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.psp-size-modal__chips--fit {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.psp-size-chip {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.psp-size-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.psp-size-chip__text {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    color: var(--psp-fg);
    background: #fff;
    border: 1px solid var(--psp-line);
    border-radius: var(--psp-radius-sm);
    transition: border-color var(--psp-transition), background var(--psp-transition), color var(--psp-transition), transform var(--psp-transition);
}

.psp-size-chip:hover .psp-size-chip__text {
    border-color: var(--psp-fg);
}

.psp-size-chip input:focus-visible + .psp-size-chip__text {
    outline: 2px solid var(--psp-fg);
    outline-offset: 2px;
}

.psp-size-chip input:checked + .psp-size-chip__text {
    background: var(--psp-fg);
    color: #fff;
    border-color: var(--psp-fg);
}

/* Erreur */
.psp-size-modal__error {
    margin: 0 0 14px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid rgba(185, 28, 28, 0.18);
    border-radius: var(--psp-radius-sm);
}

.psp-size-modal__error[hidden] {
    display: none !important;
}

/* Bouton principal (style psp__add-to-cart) */
.psp-size-modal__submit {
    appearance: none;
    width: 100%;
    min-height: 56px;
    padding: 0 24px;
    border: 0;
    border-radius: var(--psp-radius-md);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform var(--psp-transition), opacity var(--psp-transition), box-shadow var(--psp-transition);
}

.psp-size-modal__submit--primary {
    background: var(--psp-fg);
    color: #fff;
}

.psp-size-modal__submit--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--psp-shadow-md);
}

.psp-size-modal__submit--primary:active:not(:disabled) {
    transform: translateY(0);
}

.psp-size-modal__submit:disabled {
    opacity: 0.72;
    cursor: wait;
}

.psp-size-modal__submit.is-loading .psp-size-modal__submit-label {
    opacity: 0.35;
}

.psp-size-modal__submit.is-loading .psp-size-modal__submit-spinner {
    display: block !important;
    position: absolute;
    animation: pspSizeSpin 0.9s linear infinite;
}

.psp-size-modal__submit-spinner {
    width: 22px;
    height: 22px;
}

@keyframes pspSizeSpin {
    to { transform: rotate(360deg); }
}

.psp-size-modal__submit--secondary {
    margin-top: 10px;
    background: #fff;
    color: var(--psp-fg);
    border: 1px solid var(--psp-line-strong);
    min-height: 48px;
}

.psp-size-modal__submit--secondary:hover:not(:disabled) {
    background: var(--psp-bg-soft);
}

/* Résultat */
.psp-size-modal__result {
    animation: pspSizeFadeIn 280ms var(--psp-ease);
}

.psp-size-modal__result[hidden] {
    display: none !important;
}

.psp-size-result {
    text-align: center;
}

.psp-size-result__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--psp-muted);
    background: var(--psp-bg-soft);
    border-radius: 999px;
}

.psp-size-result__hero {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--psp-muted);
}

.psp-size-result__size {
    display: block;
    margin: 4px 0 16px;
    font-size: clamp(36px, 8vw, 48px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--psp-fg);
}

.psp-size-result__alt {
    margin: 0 0 14px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--psp-fg);
    background: var(--psp-bg-soft);
    border-radius: var(--psp-radius-md);
}

.psp-size-result__alt strong {
    font-weight: 600;
}

.psp-size-result__expl {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--psp-muted);
    text-align: left;
}

.psp-size-result__warn {
    margin: 0 0 14px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.45;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid rgba(146, 64, 14, 0.15);
    border-radius: var(--psp-radius-sm);
    text-align: left;
}

.psp-size-result__disclaimer {
    margin: 0 0 18px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--psp-muted);
}

.psp-size-result__actions {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Mobile */
@media (max-width: 520px) {
    .psp-size-modal__dialog {
        max-height: 94vh;
        border-radius: var(--psp-radius-lg) var(--psp-radius-lg) 0 0;
        align-self: flex-end;
    }

    .psp-size-modal {
        align-items: flex-end;
        padding: 0;
    }

    .psp-size-modal__grid {
        grid-template-columns: 1fr;
    }

    .psp-size-modal__chips--fit {
        grid-template-columns: 1fr;
    }

    .psp-size-modal__toolbar {
        flex-wrap: wrap;
    }

    .psp-size-modal__guide-link {
        flex: 1 1 auto;
        min-width: 0;
    }
}
