/*
 * Sonrisas Cotizador WordPress 2.11.0-staging
 * Production-fidelity baseline measured from the live WordPress cotizador.
 *
 * Goal: reproduce the rendered WordPress geometry/typography while keeping
 * V2's safer architecture, searchable municipality combobox and smooth
 * conditional character flow. All styles remain scoped to #cotizador.
 */
#cotizador,
#cotizador * {
    box-sizing: border-box;
}

#cotizador {
    font-family: Arial, sans-serif;
    background: #f0f2f5;
    margin: 0;
    padding: 20px;
    font-size: 16px;
    font-weight: 400;
    line-height: 22.4px; /* 1.4, measured on production */
}

#cotizador .quote-card {
    max-width: 1000px;
    margin: auto;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/*
 * Live WP measurement at 412 CSS px viewport:
 * font 28.8/800, line-height 40.32, margins 23.904px 0 24px.
 * The live theme also adds the gold ::after rule measured below.
 */
#cotizador h2 {
    position: relative;
    display: block;
    margin: 23.904px 0 24px;
    padding: 0;
    text-align: center;
    color: #1a1a2e;
    font-family: Arial, sans-serif;
    font-size: 28.8px;
    font-weight: 800;
    line-height: 40.32px;
    letter-spacing: normal;
}

/*
 * Desktop fidelity correction measured against the previous live cotizador
 * at 972 CSS px / DPR 2:
 * - system UI stack
 * - 35.2px / 44px
 * - intrinsic title width (gold rule remains anchored to title start)
 * - no top margin
 *
 * Mobile keeps the previously measured 412px production baseline above.
 */
@media (min-width: 768px) {
    #cotizador h2 {
        width: fit-content;
        max-width: 100%;
        margin: 0 0 24px;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        font-size: 35.2px;
        line-height: 44px;
    }
}

#cotizador h2::after {
    content: "";
    position: absolute;
    display: block;
    left: 0;
    right: auto;
    bottom: -12px;
    width: 70px;
    height: 4px;
    margin: 0;
    border-radius: 4px;
    background: rgb(244, 185, 66);
}

#cotizador form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#cotizador .field {
    min-width: 0;
    margin: 0;
    padding: 0;
}

/* A wrapper is used in V2, so these margins reproduce the spacing that the
   old direct-child flex layout got from gap:8px + label margin-top:8px. */
#cotizador label:not(.visually-hidden),
#cotizador legend,
#cotizador .field-label {
    display: block;
    margin: 8px 0 8px;
    padding: 0;
    color: inherit;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 22.4px;
}

#cotizador .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#cotizador input,
#cotizador button,
#cotizador output {
    font-family: Arial, sans-serif;
}

/* Production uses the browser's native select font rendering. */
#cotizador select {
    font-family: system-ui;
}

/* Live WP input measurement: 42px high, Arial 14/400, 12px padding,
   1px #ccc border, 8px radius, display:block and 1px inline margins. */
#cotizador input[type="text"] {
    display: block;
    width: 100%;
    min-height: 40px;
    height: 42px;
    margin: 0 1px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: rgb(30, 30, 30);
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: normal;
    box-shadow: rgba(0, 0, 0, 0) 0 0 0 0;
    appearance: none;
}

#cotizador select {
    display: block;
    width: 100%;
    height: 44.5px;
    margin: 0;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #000;
    font-family: system-ui;
    font-size: 14px;
    font-weight: 400;
    line-height: normal;
    box-shadow: none;
    appearance: auto;
}

/* Searchable Municipio replaces the old native select. Its box follows the
   select's measured geometry and typography rather than the text-input style. */
#cotizador #municipio-search {
    display: block;
    width: 100%;
    min-height: 44.5px;
    height: 44.5px;
    margin: 0;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #000;
    font-family: system-ui;
    font-size: 14px;
    font-weight: 400;
    line-height: normal;
}

#cotizador input::placeholder {
    color: #9aa1af;
    opacity: 1;
}

#cotizador input:disabled {
    background: #e9ecef;
    color: #777;
    cursor: not-allowed;
}

#cotizador input:focus-visible,
#cotizador select:focus-visible,
#cotizador button:focus-visible,
#cotizador .checkbox-group label:focus-within {
    outline: 2px solid rgba(37, 211, 102, 0.36);
    outline-offset: 2px;
}

#cotizador fieldset {
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

#cotizador .checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin: 10px 0;
    padding: 10px;
    border-radius: 8px;
    background: #f9f9f9;
}

#cotizador .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px;
    border-radius: 6px;
    background: #e9ecef;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease;
}

#cotizador .checkbox-group label:hover {
    background: #dee2e6;
}

#cotizador .checkbox-group input {
    margin: 0;
}

#cotizador .readonly-value {
    display: block;
    width: 100%;
    min-height: 40px;
    height: 42px;
    margin: 0 1px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #e9ecef;
    color: rgb(30, 30, 30);
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: normal;
}

/* The old layout had error nodes as flex items. Inside V2 field wrappers,
   2px top + 8px bottom reproduces gap(8) + old margin-top(-6) + margin-bottom(8). */
#cotizador .error {
    display: none;
    margin: 2px 0 8px;
    padding: 0;
    color: #d32f2f;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 16.8px;
}

#cotizador .error.is-visible {
    display: block;
}

/* Smooth measured-height transition retained from V2.3/V2.4. */
#cotizador .conditional-flow {
    height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        height 280ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 180ms ease,
        transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: height, opacity, transform;
}

#cotizador .conditional-flow-inner {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#cotizador .conditional-flow.is-open {
    opacity: 1;
    transform: translateY(0);
}

#cotizador .combobox {
    position: relative;
}

#cotizador .combobox-options {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: min(46vh, 320px);
    margin: 0;
    padding: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    list-style: none;
    border: 1px solid #c9c9c9;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

#cotizador .combobox-option {
    padding: 10px 12px;
    border-radius: 6px;
    color: #1a1a2e;
    font-family: system-ui;
    font-size: 14px;
    font-weight: 400;
    line-height: 18.2px;
    cursor: pointer;
}

#cotizador .combobox-option[aria-selected="true"],
#cotizador .combobox-option:hover {
    background: #e9ecef;
}

#cotizador .precio-container {
    margin: 16px 0;
    padding: 12px;
    border: 2px solid #2e7d32;
    border-radius: 12px;
    background: #e6f4ea;
    text-align: center;
}

#cotizador .precio-label {
    font-size: 16px;
    font-weight: 400;
}

#cotizador .precio-total {
    margin-top: 4px;
    color: #1b5e20;
    font-size: 28px;
    font-weight: 700;
    line-height: 39.2px;
}

#cotizador .form-status {
    min-height: 0;
    margin: 0;
    color: #555;
    font-size: 12px;
    line-height: 16.8px;
}

#cotizador .form-status:empty {
    display: none;
}

#cotizador button {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    border: 0;
    border-radius: 40px;
    background: #25D366;
    color: #052E24;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: normal;
    cursor: pointer;
    transition: background-color 160ms ease, transform 160ms ease;
}

#cotizador button:hover:not(:disabled) {
    background: #1da851;
}

#cotizador button:disabled {
    opacity: 0.65;
    cursor: wait;
}

#cotizador [hidden] {
    display: none !important;
}

/* No mobile padding/font override: the live production measurements at 412px
   already reflect the desired 20px + 20px nested padding and typography. */
@media (prefers-reduced-motion: reduce) {
    #cotizador .conditional-flow,
    #cotizador button,
    #cotizador .checkbox-group label {
        transition-duration: 0.001ms !important;
    }
}
