/* ============================================================
   Vinco Calculadoras — WordPress Plugin Styles
   Scoped to .vinco-calc-wrapper to avoid theme conflicts
   Design: matches vinco.es brand (Neue Plak, teal #5096a9,
           frosted-glass overlays, pill buttons, rounded cards)
   ============================================================ */

.vinco-calc-wrapper {
    font-family: "Neue Plak", sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    color: #2b2828;
}

/* ── Tabs ────────────────────────────────────────────────── */

.vinco-calc-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #ddeaee;
    margin-bottom: 28px;
}

.vinco-calc-tab {
    padding: 12px 24px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: #a8bfc7;
    cursor: pointer;
    border-radius: 0;
    transition: color 0.2s ease-out, border-color 0.2s ease-out;
}

.vinco-calc-tab:hover {
    color: #5096a9;
}

.vinco-calc-tab.active {
    color: #2b2828;
    border-bottom-color: #5096a9;
}

/* ── Panel ───────────────────────────────────────────────── */

.vinco-calc-panel {
    background: #fff;
    border: 1px solid #d0e4ea;
    padding: 32px 36px;
    border-radius: 24px;
    box-shadow: 0 4px 24px rgba(80, 150, 169, 0.08);
}

.vinco-calc-title {
    margin: 0 0 50px;
    font-size: 26px;
    color: #2b2828;
    font-weight: 400;
    line-height: 1.25;
}

.vinco-calc-subtitle {
    display: block;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #5096a9;
    margin-top: 5px;
}

/* ── Fleje: campos ───────────────────────────────────────── */

.vinco-campo {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 11px 0;
    border-bottom: 1px solid #eef4f6;
    flex-wrap: wrap;
}

.vinco-campo:last-child {
    border-bottom: none;
}

.vinco-destacado {
    background: #eef4f6;
    padding: 16px 20px;
    border-radius: 25px !important;
    border: none !important;
    margin-bottom: 16px;
}

.vinco-separado {
    margin-top: 10px;
}

.vinco-campo-izda {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 0 0 390px;
}

.vinco-campo-izda label {
    min-width: 140px;
    font-weight: 600;
    font-size: 19px;
    color: #6e7d85;
}

.vinco-campo-izda input[type="text"],
.vinco-campo-izda input[type="number"] {
    width: 130px;
    padding: 6px 10px;
    border: 1px solid #d0e4ea;
    border-radius: 25px;
    background: #fff;
    font-size: 19px;
    font-family: inherit;
    text-align: right;
    color: #2b2828;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.vinco-campo-izda input[type="text"]:focus,
.vinco-campo-izda input[type="number"]:focus {
    border-color: #5096a9;
    box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.15);
}

@keyframes vinco-pulse-error {
    0% {
        border-color: #d0e4ea;
        box-shadow: none;
    }

    40% {
        border-color: #5096a9;
        box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.35);
    }

    100% {
        border-color: #5096a9;
        box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.15);
    }
}

.vinco-field-error {
    animation: vinco-pulse-error 0.4s ease forwards;
    border-color: #5096a9 !important;
    box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.2) !important;
}

/* Also pulse the material select */
.vinco-destacado select.vinco-field-error {
    border-color: #5096a9 !important;
    box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.2) !important;
    animation: vinco-pulse-error 0.4s ease forwards;
}

.vinco-campo-izda input[readonly] {
    background: #eef4f6;
    color: #3f444b;
    font-weight: 600;
}

.vinco-campo-izda input[readonly]::-webkit-inner-spin-button,
.vinco-campo-izda input[readonly]::-webkit-outer-spin-button {
    display: none;
}

.vinco-campo-izda input:disabled {
    background: #f0f5f7;
    color: #6e7d85;
    cursor: not-allowed;
    border-color: #c8d8df;
}

/* Override jQuery UI's aggressive opacity on disabled slider */
.vinco-calc-wrapper .ui-slider-disabled,
.vinco-calc-wrapper .ui-slider.ui-state-disabled {
    opacity: 1;
}

.vinco-calc-wrapper .ui-slider-disabled .ui-slider-range {
    background: #a8c4cd;
}

.vinco-calc-wrapper .ui-slider-disabled .ui-slider-handle {
    background: #a8c4cd;
    border-color: #fff;
    box-shadow: 0 0 0 2px #a8c4cd;
    cursor: not-allowed;
}

.vinco-destacado>label {
    font-size: 23px;
}

.vinco-destacado select {
    padding: 8px 36px 8px 14px;
    border: 1px solid #d0e4ea;
    border-radius: 25px;
    font-size: 19px;
    font-family: inherit;
    min-width: 280px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236e7d85' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 14px center;
    appearance: none;
    -webkit-appearance: none;
    color: #2b2828;
    outline: none;
}

.vinco-unit {
    font-size: 19px;
    color: #6e7d85;
    white-space: nowrap;
}

/* ── Disco de color ──────────────────────────────────────── */

.vinco-disco {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.3s;
}

.vinco-disco.vinco-naranja {
    background: #e67e22;
}

.vinco-disco.vinco-rojo {
    background: #c0392b;
}

#vc-tabla-historial .vinco-disco {
    margin-right: 6px;
}

.vinco-leyenda-callout .vinco-disco {
    margin: 0;
}

/* ── Sliders ─────────────────────────────────────────────── */

.vinco-campo-dcha {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 260px;
}

.vinco-slider-lbl {
    font-size: 19px;
    color: #6e7d85;
    white-space: nowrap;
}

.vinco-slider {
    flex: 1;
    height: 6px;
    border-radius: 4px;
}

/* jQuery UI slider overrides */
.vinco-calc-wrapper .ui-slider {
    position: relative;
    background: #d0e4ea;
    border: none;
    border-radius: 4px;
    height: 8px;
}

.vinco-calc-wrapper .ui-slider-handle {
    position: absolute;
    width: 23px;
    height: 23px;
    top: -9px;
    margin-left: -9px;
    background: #5096a9;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #5096a9;
    cursor: pointer;
    outline: none;
    transition: box-shadow 0.2s;
}

.vinco-calc-wrapper .ui-slider-handle:focus {
    box-shadow: 0 0 0 4px rgba(80, 150, 169, 0.3);
}

.vinco-calc-wrapper .ui-slider-range {
    background: #5096a9;
    border-radius: 4px;
}

.vinco-calc-wrapper .vinco-slider.vinco-naranja .ui-slider-handle {
    background: #e67e22;
    box-shadow: 0 0 0 2px #e67e22;
}

.vinco-calc-wrapper .vinco-slider.vinco-rojo .ui-slider-handle {
    background: #c0392b;
    box-shadow: 0 0 0 2px #c0392b;
}

/* ── Acciones (Calcular / Guardar / Limpiar) ─────────────── */

.vinco-acciones {
    gap: 12px !important;
    justify-content: flex-start;
}

.vinco-btn-primary {
    padding: 9px 28px;
    background: #5096a9;
    color: #fff;
    border: none;
    border-radius: 35px;
    font-size: 19px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: background 0.2s, box-shadow 0.2s;
}

.vinco-btn-primary:hover {
    background: #33879e;
    box-shadow: 0 4px 12px rgba(80, 150, 169, 0.35);
}

.vinco-btn-link {
    background: none;
    border: none;
    color: #5096a9;
    font-size: 19px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.vinco-btn-link:hover {
    color: #c0392b;
}

/* ── Historial ───────────────────────────────────────────── */

.vinco-historial {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid #d0e4ea;
}

.vinco-historial-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.vinco-historial-title {
    font-weight: 600;
    font-size: 19px;
    color: #5096a9;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex: 1;
}

.vinco-leyenda-callout {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.vinco-leyenda {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    background: #f6fafc;
    border: 1px solid #d8edf3;
    border-radius: 20px;
    font-size: 16px;
    color: #5f7280;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.vinco-table-wrap {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid #d0e4ea;
    box-shadow: 0 2px 12px rgba(80, 150, 169, 0.07);
}

/* `auto`, not `fixed`: with a fixed layout the 7 columns collapse to a seventh
   of the viewport each and the headings overlap. Auto keeps the table's
   intrinsic width, so .vinco-table-wrap actually scrolls on narrow screens. */
#vc-tabla-historial {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    font-size: 17px;
}

#vc-tabla-historial thead tr th {
    background: #5096a9;
    color: #fff;
    padding: 10px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 17px;
    white-space: nowrap;
}

#vc-tabla-historial thead tr th:first-child {
    border-radius: 15px 0 0 0;
}

#vc-tabla-historial thead tr th:last-child {
    border-radius: 0 15px 0 0;
}

/* Fixed-width narrow columns — material col gets the remaining space */
/* #vc-tabla-historial th:nth-child(1),
#vc-tabla-historial td:nth-child(1),
#vc-tabla-historial th:nth-child(2),
#vc-tabla-historial td:nth-child(2) {
    width: 100px;
} */

/* #vc-tabla-historial th:nth-child(4),
#vc-tabla-historial td:nth-child(4),
#vc-tabla-historial th:nth-child(5),
#vc-tabla-historial td:nth-child(5),
#vc-tabla-historial th:nth-child(6),
#vc-tabla-historial td:nth-child(6) {
    width: 80px;
} */

#vc-tabla-historial tbody tr:nth-child(even) {
    background: #f5fafb;
}

#vc-tabla-historial td {
    padding: 9px 12px;
    border-bottom: 1px solid #eef4f6;
    color: #2b2828;
    text-align: center;
}

#vc-tabla-historial tbody tr:last-child td {
    border-bottom: none;
}

#vc-tabla-historial tbody tr {
    cursor: pointer;
}

#vc-tabla-historial tbody tr:hover {
    background: #d0e4ea;
    transition: background 0.15s;
}

#vc-tabla-historial tbody tr td.vinco-col-eliminar {
    cursor: default;
}

#vc-tabla-historial .vinco-btn-eliminar {
    background: none;
    border: none;
    color: #b0c4cc;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

#vc-tabla-historial .vinco-btn-eliminar:hover {
    color: #c0392b;
}

#vc-tabla-historial th.vinco-col-eliminar,
#vc-tabla-historial td.vinco-col-eliminar {
    width: 32px;
    text-align: center;
    padding: 9px 6px;
}

.vinco-disclaimer {
    font-size: 16px;
    color: #666;
    margin-top: 16px;
    font-style: italic;
    line-height: 1.6;
}

/* ── Cable: pasos ────────────────────────────────────────── */

/* All steps share one card — individual borders removed */
.vinco-cable-paso {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid #d0e4ea;
    border-top: none;
    margin-bottom: 0;
    transition: opacity 0.2s;
}

#vc-paso-resultado {
    gap: 55px;
}

.vinco-cable-paso:first-of-type {
    border-top: 1px solid #d0e4ea;
    border-radius: 16px 16px 0 0;
}

.vinco-cable-paso:last-of-type {
    border-radius: 0 0 16px 16px;
}

#vc-paso-resultado {
    align-items: flex-start;
}

.vinco-cable-paso.vinco-disabled {
    opacity: 0.62;
    pointer-events: none;
}

.vinco-cable-paso-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 210px;
    font-size: 19px;
    color: #2b2828;
}

.vinco-paso-num {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 19px;
    font-weight: 600;
    color: #fff;
    background: #5096a9;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 3px 10px;
    border-radius: 25px;
}

.vinco-cable-paso.vinco-disabled .vinco-paso-num {
    background: #a8c4cd;
}

.vinco-cable-paso-ctrl {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.vinco-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.vinco-cable-paso-ctrl label {
    font-size: 13px;
    color: #6e7d85;
    white-space: nowrap;
    flex-shrink: 0;
}

.vinco-cable-paso-ctrl select {
    flex: 1;
    min-width: 0;
    padding: 9px 36px 9px 14px;
    border: 1px solid #d0e4ea;
    border-radius: 25px;
    font-size: 19px;
    font-family: inherit;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236e7d85' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 14px center;
    appearance: none;
    -webkit-appearance: none;
    color: #2b2828;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.vinco-cable-paso-ctrl select:focus {
    border-color: #5096a9;
    box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.15);
}

/* ── Cable: resultado (paso 4) ───────────────────────────── */

.vinco-cable-resultado {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 45px;
    min-width: 0;
}

.vinco-cable-imagen img {
    display: block;
    width: 175px;
    height: auto;
    border-radius: 10px;
    opacity: 0.9;
}

.vinco-cable-datos {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.vinco-cable-fila {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eef4f6;
}

.vinco-cable-fila:last-child {
    border-bottom: none;
}

.vinco-cable-lbl {
    flex: 0 0 150px;
    font-size: 19px;
    color: #6e7d85;
}

.vinco-cable-fila span:not(.vinco-cable-lbl) {
    font-size: 19px;
    font-weight: 600;
    color: #2b2828;
}

#vc-c2-metros {
    width: 100px;
    padding: 6px 10px;
    border: 1px solid #d0e4ea;
    border-radius: 25px;
    font-size: 19px;
    font-family: inherit;
    text-align: right;
    background: #fff;
    color: #2b2828;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#vc-c2-metros:focus {
    border-color: #5096a9;
    box-shadow: 0 0 0 3px rgba(80, 150, 169, 0.15);
}

.vinco-cable-peso-total {
    background: linear-gradient(135deg, #5096a9, #33879e);
    border-radius: 12px;
    padding: 12px 18px;
    border: none;
    margin-top: 6px;
}

.vinco-cable-peso-total .vinco-cable-lbl {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
}

.vinco-cable-peso-total span:not(.vinco-cable-lbl) {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
    .vinco-calc-panel {
        padding: 20px 16px;
        border-radius: 0 16px 16px 16px;
    }

    /* The desktop column is 390px wide — wider than the phone itself. Going to
       100% is not enough on its own: flex items keep a min-width of auto, so
       the label+input+unit content still forces ~373px. min-width:0 releases
       that floor, and wrapping puts the label on its own line above the input. */
    .vinco-campo-izda {
        flex: 0 0 100%;
        min-width: 0;
        flex-wrap: wrap;
    }

    .vinco-campo-izda label {
        min-width: 100%;
    }

    /* An explicit basis, not auto: with auto the basis is the input's natural
       width, which is wide enough to push the unit onto its own line in some
       rows but not others. A fixed basis keeps every row laid out the same. */
    .vinco-campo-izda input[type="text"],
    .vinco-campo-izda input[type="number"] {
        flex: 1 1 120px;
        width: auto;
        min-width: 0;
    }

    .vinco-destacado select {
        min-width: 0;
        width: 100%;
    }

    .vinco-campo-dcha {
        min-width: 100%;
    }

    /* Without flex-wrap the label's 100% basis does not push the result panel
       onto a second line — it shoves it outside the card instead. */
    .vinco-cable-paso {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }

    /* The label is itself a flex row (badge + text + <strong>); without wrapping
       the highlighted word cannot drop to a second line and juts out. */
    .vinco-cable-paso-label {
        flex: 0 0 100%;
        flex-wrap: wrap;
    }

    .vinco-cable-paso-ctrl select {
        min-width: 100%;
    }

    /* minmax(0, 1fr), not 1fr: a plain 1fr track keeps an auto minimum, so the
       rows below hold the grid open at their min-content width and it spills
       out of the step card. */
    .vinco-cable-resultado {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .vinco-cable-fila {
        justify-content: space-between;
    }

    .vinco-cable-lbl {
        flex: 0 1 auto;
        min-width: 0;
    }

    /* Historial: each row becomes a stacked card. The heading for every cell
       comes from its data-label, set in calculadoras.js from the <thead>, so it
       is already translated. */
    .vinco-table-wrap {
        overflow-x: visible;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    #vc-tabla-historial thead {
        display: none;
    }

    #vc-tabla-historial,
    #vc-tabla-historial tbody,
    #vc-tabla-historial tbody tr,
    #vc-tabla-historial tbody td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #vc-tabla-historial tbody tr {
        position: relative;
        overflow: hidden;
        margin-bottom: 12px;
        padding: 0;
        background: #fff;
        border: 1px solid #d0e4ea;
        border-radius: 14px;
        box-shadow: 0 2px 12px rgba(80, 150, 169, 0.07);
    }

    #vc-tabla-historial tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 40px;
        padding: 0 12px 0 0;
        text-align: right;
    }

    /* One continuous blue band down the left of the card — the desktop <thead>
       turned on its side. The width is a fixed px value, not a %, so it stays
       flush across every row: the first cell reserves room for the delete
       button and a percentage would compute narrower there, notching the band. */
    #vc-tabla-historial tbody td::before {
        content: attr(data-label);
        display: flex;
        align-items: center;
        align-self: stretch;
        flex: 0 0 146px;
        /* min-width:0 defeats the flex min-content floor: a long unbreakable
           word (German "Außendurchmesser") would otherwise widen its own cell
           and notch the band. overflow-wrap lets such a word break instead. */
        min-width: 0;
        overflow-wrap: anywhere;
        box-sizing: border-box;
        padding: 6px 10px;
        background: #5096a9;
        color: #fff;
        font-weight: 600;
        font-size: 14px;
        line-height: 1.25;
        text-align: left;
    }

    /* Room for the delete button, which floats over the top-right corner */
    #vc-tabla-historial tbody tr td:first-child {
        padding-right: 34px;
    }

    /* On desktop the last <tr> drops its bottom border, but here every <tr> is
       a card and still needs its dividers — otherwise the most recently added
       card renders with none. Put them back, then drop only the divider under
       the last visible cell of each card. */
    #vc-tabla-historial tbody tr:last-child td {
        border-bottom: 1px solid #eef4f6;
    }

    #vc-tabla-historial tbody tr td:nth-last-child(2) {
        border-bottom: none;
    }

    #vc-tabla-historial tbody tr td.vinco-col-eliminar {
        position: absolute;
        top: 4px;
        right: 6px;
        width: auto;
        padding: 4px 6px;
        border-bottom: none;
    }

    #vc-tabla-historial tbody td.vinco-col-eliminar::before {
        content: none;
    }
}