/**
 * Nuevomega_PreorderDeal — frontend styles.
 *
 * PDP CTA pair + modal wizard for "Solicitar proforma" / "Borrador de
 * contrato preventa". Visual language mirrors Nuevomega_CheckoutFlowV2
 * (Technical Precision palette, rounded XL cards, navy/blue accents) but
 * everything is scoped under .nm-pd so we don't depend on the
 * body.nm-wiz class and never collide with checkout styles.
 *
 * Loaded by view/frontend/layout/catalog_product_view.xml. Inert until
 * the <section class="nm-pd"> is rendered by the .phtml (gated by
 * Helper/Config + ViewModel/DealConfig::isApplicable, disabled when the
 * module toggle is off).
 */

/* =====================================================================
 * Local tokens (mirror of CheckoutFlowV2 :root palette, isolated)
 * =================================================================== */
.nm-pd {
    /* Brand */
    --nm-pd-primary: #000209;
    --nm-pd-primary-container: #001c40;
    --nm-pd-secondary: #0051d5;
    --nm-pd-secondary-hover: #003ea7;
    --nm-pd-secondary-soft: #dbe1ff;
    --nm-pd-surface-card: #ffffff;
    --nm-pd-surface-low: #eff4ff;
    --nm-pd-surface-container: #e5eeff;
    --nm-pd-surface-ice: #f8f9ff;
    --nm-pd-on-surface: #0b1c30;
    --nm-pd-on-surface-variant: #44474e;
    --nm-pd-outline: #74777f;
    --nm-pd-outline-variant: #c4c6cf;
    --nm-pd-error: #ba1a1a;
    --nm-pd-success: #1f8a4c;

    /* Radius (matches V2 scale) */
    --nm-pd-radius: 2px;
    --nm-pd-radius-lg: 4px;
    --nm-pd-radius-xl: 8px;
    --nm-pd-radius-full: 12px;

    --nm-pd-space-sm: 12px;
    --nm-pd-space-md: 16px;
    --nm-pd-space-lg: 24px;

    --nm-pd-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --nm-pd-shadow-card: 0 1px 2px rgba(11, 28, 48, 0.06);
    --nm-pd-shadow-modal: 0 12px 48px rgba(0, 2, 9, 0.18);
}

/* =====================================================================
 * PDP trigger buttons
 * =================================================================== */
.nm-pd {
    margin: 16px 0 8px;
    font-family: var(--nm-pd-font);
    color: var(--nm-pd-on-surface);
}

.nm-pd .nm-pd-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.nm-pd .nm-pd-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: var(--nm-pd-radius-xl);
    padding: 14px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    width: 100%;
    transition: background-color 0.15s ease, color 0.15s ease,
        border-color 0.15s ease, box-shadow 0.15s ease;
}

.nm-pd .nm-pd-btn:focus-visible {
    outline: 2px solid var(--nm-pd-secondary);
    outline-offset: 2px;
}

.nm-pd .nm-pd-btn-quote {
    background: var(--nm-pd-secondary);
    color: #ffffff;
    box-shadow: var(--nm-pd-shadow-card);
}

.nm-pd .nm-pd-btn-quote:hover {
    background: var(--nm-pd-secondary-hover);
}

.nm-pd .nm-pd-btn-contract {
    background: var(--nm-pd-surface-card);
    color: var(--nm-pd-secondary);
    border: 1.5px solid var(--nm-pd-secondary);
}

.nm-pd .nm-pd-btn-contract:hover {
    background: var(--nm-pd-surface-low);
}

/* =====================================================================
 * Modal root — overlay + dialog + step content
 * =================================================================== */
.nm-pd-modal-root[hidden] {
    display: none !important;
}

.nm-pd-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
}

.nm-pd-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 2, 9, 0.55);
    backdrop-filter: blur(2px);
    animation: nm-pd-fade-in 0.18s ease;
}

.nm-pd-modal__dialog {
    position: relative;
    background: var(--nm-pd-surface-ice);
    border-radius: var(--nm-pd-radius-full);
    box-shadow: var(--nm-pd-shadow-modal);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nm-pd-pop-in 0.2s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.nm-pd-modal__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 20px 12px;
    border-bottom: 0;
}

/* Hard reset with high specificity: Porto's theme button rules
   (.product-info-main button, button.action, etc.) otherwise bleed into
   these icon buttons and render them as generic theme buttons. */
.nm-pd-modal-root .nm-pd-modal__back,
.nm-pd-modal-root .nm-pd-modal__close {
    appearance: none;
    -webkit-appearance: none;
    background: transparent none;
    background-image: none;
    border: 1px solid transparent;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    line-height: 1;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        color 0.15s ease, transform 0.1s ease;
}

.nm-pd-modal-root .nm-pd-modal__back {
    color: var(--nm-pd-on-surface);
}

.nm-pd-modal-root .nm-pd-modal__back:hover,
.nm-pd-modal-root .nm-pd-modal__back:focus {
    background: rgba(0, 81, 213, 0.08);
    background-image: none;
    border-color: rgba(0, 81, 213, 0.18);
    color: var(--nm-pd-secondary);
    box-shadow: none;
}

.nm-pd-modal-root .nm-pd-modal__back:active,
.nm-pd-modal-root .nm-pd-modal__close:active {
    transform: scale(0.94);
    box-shadow: none;
}

.nm-pd-modal-root .nm-pd-modal__back:focus-visible,
.nm-pd-modal-root .nm-pd-modal__close:focus-visible {
    outline: 2px solid var(--nm-pd-secondary);
    outline-offset: 2px;
}

.nm-pd-modal-root .nm-pd-modal__back[hidden] {
    display: inline-flex !important;
    visibility: hidden;
    pointer-events: none;
}

.nm-pd-modal__title {
    flex: 1;
    margin: 0;
    font-family: inherit;
    font-size: 18px;
    font-weight: 600;
    color: var(--nm-pd-primary);
    text-align: center;
}

.nm-pd-modal-root .nm-pd-modal__close {
    color: var(--nm-pd-on-surface-variant);
}

.nm-pd-modal-root .nm-pd-modal__close:hover,
.nm-pd-modal-root .nm-pd-modal__close:focus {
    background: rgba(0, 2, 9, 0.06);
    background-image: none;
    border-color: var(--nm-pd-outline-variant);
    color: var(--nm-pd-primary);
    box-shadow: none;
}

/* The stroke-icon SVGs: Porto sets `fill` on svg descendants of buttons,
   which turns the strokes into solid blobs. Presentation attributes
   (fill="none" inline) lose to any stylesheet rule, so pin them here. */
.nm-pd-modal-root .nm-pd-modal__nav-icon {
    display: block;
    width: 18px;
    height: 18px;
    pointer-events: none;
    fill: none !important;
    stroke: currentColor;
    flex: none;
}

.nm-pd-modal-root .nm-pd-modal__nav-icon path {
    fill: none !important;
    stroke: currentColor;
}

.nm-pd-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 20px 20px;
}

.nm-pd-modal__footer {
    flex: 0 0 auto;
    padding: 14px 20px 20px;
    border-top: 1px solid var(--nm-pd-outline-variant);
    background: var(--nm-pd-surface-card);
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.nm-pd-modal__footer > * {
    width: 100%;
}

/* Lock page scroll while the modal is open. */
body.nm-pd-modal-open {
    overflow: hidden;
}

@keyframes nm-pd-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes nm-pd-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* =====================================================================
 * Steps — DATOS form
 * =================================================================== */
.nm-pd-step {
    display: none;
    flex-direction: column;
    gap: 14px;
}

.nm-pd-step.is-active {
    display: flex;
}

/* [hidden] overrides the .is-active display so an inactive step is never
   shown — see activateStep(). */
.nm-pd-step[hidden] {
    display: none !important;
}

.nm-pd-step__lead {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--nm-pd-on-surface-variant);
}

.nm-pd-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--nm-pd-surface-card);
    border: 1px solid var(--nm-pd-outline-variant);
    border-radius: var(--nm-pd-radius-xl);
    padding: 12px 14px;
    box-shadow: var(--nm-pd-shadow-card);
}

.nm-pd-field--inline {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.nm-pd-field__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--nm-pd-on-surface-variant);
}

.nm-pd-field__label .required {
    color: var(--nm-pd-error);
    margin-left: 2px;
}

.nm-pd-field__optional {
    font-size: 11px;
    font-weight: 400;
    color: var(--nm-pd-on-surface-variant);
    opacity: 0.7;
    margin-left: 4px;
}

.nm-pd-field__input,
.nm-pd-field__textarea {
    appearance: none;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    color: var(--nm-pd-on-surface);
    width: 100%;
    padding: 0;
    outline: none;
}

.nm-pd-field__input::placeholder,
.nm-pd-field__textarea::placeholder {
    color: var(--nm-pd-outline);
}

.nm-pd-field__row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nm-pd-field__row .nm-pd-field__input {
    flex: 1;
}

.nm-pd-field__hint {
    font-size: 12px;
    line-height: 1.35;
    color: var(--nm-pd-on-surface-variant);
    min-height: 16px;
}

.nm-pd-field__hint.is-error {
    color: var(--nm-pd-error);
}

.nm-pd-field__hint.is-success {
    color: var(--nm-pd-success);
}

.nm-pd-field.is-valid {
    border-color: var(--nm-pd-success);
}

.nm-pd-field.has-error {
    border-color: var(--nm-pd-error);
}

.nm-pd-field--hidden {
    display: none;
}

.nm-pd-btn-mini {
    appearance: none;
    border: 1px solid var(--nm-pd-secondary);
    background: var(--nm-pd-surface-card);
    color: var(--nm-pd-secondary);
    border-radius: var(--nm-pd-radius-lg);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.nm-pd-btn-mini:hover {
    background: var(--nm-pd-surface-low);
}

.nm-pd-btn-mini:disabled {
    opacity: 0.55;
    cursor: progress;
}

/* =====================================================================
 * Step MODALIDAD (cards)
 * =================================================================== */
.nm-pd-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nm-pd-card {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--nm-pd-outline-variant);
    border-radius: var(--nm-pd-radius-xl);
    background: var(--nm-pd-surface-card);
    box-shadow: var(--nm-pd-shadow-card);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.nm-pd-card:hover {
    border-color: var(--nm-pd-secondary);
}

.nm-pd-card._active {
    border: 2px solid var(--nm-pd-secondary);
    background: var(--nm-pd-surface-low);
    padding: 13px 15px;
}

.nm-pd-card__radio {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-top: 4px;
    border: 2px solid var(--nm-pd-outline-variant);
    border-radius: 50%;
    background: var(--nm-pd-surface-card);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nm-pd-card._active .nm-pd-card__radio {
    border-color: var(--nm-pd-secondary);
}

.nm-pd-card._active .nm-pd-card__radio::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--nm-pd-secondary);
}

.nm-pd-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.nm-pd-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nm-pd-card__badge {
    font-size: 16px;
    line-height: 1;
}

.nm-pd-card__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--nm-pd-primary);
}

.nm-pd-card__subtitle {
    font-size: 13px;
    line-height: 1.4;
    color: var(--nm-pd-on-surface-variant);
}

.nm-pd-card__subtitle p { margin: 0 0 4px; }
.nm-pd-card__subtitle p:last-child { margin-bottom: 0; }

.nm-pd-card__pricing {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--nm-pd-on-surface-variant);
}

.nm-pd-card__pricing-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.nm-pd-card__pricing-strike {
    text-decoration: line-through;
    color: var(--nm-pd-outline);
}

.nm-pd-card__pricing-final {
    font-size: 15px;
    font-weight: 700;
    color: var(--nm-pd-primary);
}

.nm-pd-card__pricing-upfront {
    color: var(--nm-pd-secondary);
    font-weight: 500;
}

/* =====================================================================
 * Steps GENERATING / LISTO
 * =================================================================== */
.nm-pd-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 28px 8px;
}

.nm-pd-center__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--nm-pd-surface-container);
    color: var(--nm-pd-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

.nm-pd-center__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--nm-pd-primary);
}

.nm-pd-center__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--nm-pd-on-surface-variant);
    max-width: 360px;
}

.nm-pd-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--nm-pd-secondary-soft);
    border-top-color: var(--nm-pd-secondary);
    border-radius: 50%;
    animation: nm-pd-spin 0.9s linear infinite;
}

@keyframes nm-pd-spin {
    to { transform: rotate(360deg); }
}

/* =====================================================================
 * Primary / secondary buttons inside the wizard
 * =================================================================== */
.nm-pd-btn-primary {
    appearance: none;
    border: 0;
    background: var(--nm-pd-secondary);
    color: #ffffff;
    border-radius: var(--nm-pd-radius-xl);
    padding: 13px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.nm-pd-btn-primary:hover {
    background: var(--nm-pd-secondary-hover);
}

.nm-pd-btn-primary:focus-visible {
    outline: 2px solid var(--nm-pd-secondary);
    outline-offset: 2px;
}

.nm-pd-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.nm-pd-btn-secondary {
    appearance: none;
    background: transparent;
    border: 1.5px solid var(--nm-pd-outline-variant);
    color: var(--nm-pd-on-surface);
    border-radius: var(--nm-pd-radius-xl);
    padding: 12px 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.nm-pd-btn-secondary:hover {
    border-color: var(--nm-pd-secondary);
    color: var(--nm-pd-secondary);
}

.nm-pd-error-banner {
    margin: 4px 0 12px;
    padding: 10px 14px;
    border-radius: var(--nm-pd-radius-xl);
    background: rgba(186, 26, 26, 0.08);
    color: var(--nm-pd-error);
    font-size: 13px;
    line-height: 1.4;
}

.nm-pd-btn-cancel {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--nm-pd-on-surface-variant);
    font-family: inherit;
    font-size: 13px;
    padding: 6px 0;
    cursor: pointer;
    text-decoration: underline;
    align-self: center;
}

/* =====================================================================
 * Mobile (<768px): centered dialog within the visible viewport
 * =================================================================== */
@media (max-width: 767px) {
    .nm-pd-modal {
        padding: 12px;
        align-items: center;
    }

    .nm-pd-modal__dialog {
        max-width: 100%;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: var(--nm-pd-radius-full);
    }

    .nm-pd-modal__body {
        padding: 12px 16px 16px;
    }

    .nm-pd-modal__footer {
        padding: 12px 16px 16px;
    }
}

@media (min-width: 768px) {
    .nm-pd-modal__dialog {
        max-height: 88vh;
    }
}
