.pieza-zellige {
    cursor: pointer;
    transition: fill 0.3s ease;
    stroke: #eee;
    stroke-width: 0.5;
}

.pieza-zellige:hover {
    opacity: 0.8;
    stroke: #000;
}

#canvas-simulador {
    background-color: #f8f8f8;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Etiqueta superpuesta "Vista previa" dentro del contenedor de previsualización.
   Usa position:absolute para no alterar el flujo ni dimensiones del layout. */
#canvas-simulador {
    position: relative; /* no modifica layout, permite elementos absolute dentro */
}
.preview-label {
    position: absolute;
    top: 8px;
    left: 200px; /* desplazado 92px a la derecha desde 8px */
    transform: none;
    background: rgba(0,0,0,0.6);
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 2000;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* legacy class kept for compatibility */
.preview-label.top-left { top:8px; left:200px; }

/* ── Marca Blanca ── */
:root {
    --color-principal: #059669;
    --color-hover: #047857;
    --color-texto: #065f46;
}

.btn-marca {
    background-color: var(--color-principal);
}
.btn-marca:hover {
    background-color: var(--color-hover);
}

.texto-marca {
    color: var(--color-texto);
}

/* ── Catálogo: items ── */
.catalogo-item {
    position: relative;
    cursor: pointer;
}
.catalogo-item-thumb {
    position: relative;
    aspect-ratio: 1;
    background-color: #e5e7eb;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.catalogo-item:hover .catalogo-item-thumb {
    border-color: #10b981;
}
.catalogo-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 1;
}
.thumb-iniciales {
    font-size: 10px;
    font-weight: bold;
    color: #9ca3af;
    position: absolute;
    pointer-events: none;
}

/* Badge contador de variantes */
.variantes-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-principal, #059669);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: none;
}

/* Backdrop + Modal selector de variantes */
#selector-variantes-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.35);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: svBackdropIn 0.2s ease-out;
}
@keyframes svBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
#selector-variantes {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
    padding: 1.25rem 1.5rem 1.5rem;
    max-width: 420px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    animation: svPanelIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes svPanelIn {
    from { opacity: 0; transform: scale(0.88) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.sv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.sv-titulo {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sv-cerrar {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.sv-cerrar:hover {
    color: #374151;
}
.sv-subtitulo {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 1rem;
}
.sv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.sv-opcion {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.sv-opcion:hover {
    border-color: var(--color-principal, #10b981);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
    transform: translateY(-2px);
}
.sv-opcion:active {
    transform: translateY(0) scale(0.97);
}
.sv-opcion-img {
    width: 100px;
    height: 100px;
    border-radius: 6px;
    overflow: hidden;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sv-opcion-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sv-opcion-fallback {
    font-size: 16px;
    font-weight: 700;
    color: #9ca3af;
}
.sv-opcion-nombre {
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    text-align: center;
    line-height: 1.2;
}

/* ══════════════════════════════════════════════════
   MODAL DE PRESUPUESTO
   ══════════════════════════════════════════════════ */

#presupuesto-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: presupBackdropIn 0.2s ease-out;
}
@keyframes presupBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#presupuesto-modal {
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: presupModalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes presupModalIn {
    from { opacity: 0; transform: scale(0.9) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Cabecera ── */
.presup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.presup-titulo {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.presup-cerrar {
    background: none;
    border: none;
    font-size: 26px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.presup-cerrar:hover { color: #374151; }

/* ── Cuerpo: dos columnas ── */
.presup-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.presup-col-form {
    width: 40%;
    flex-shrink: 0;
    border-right: 1px solid #e5e7eb;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.presup-col-resumen {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.presup-col-titulo {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

/* ── Formulario ── */
.presup-campo {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.9rem;
}
.presup-campo label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.presup-campo input,
.presup-campo textarea {
    border: 1.5px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    color: #111827;
    background: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.presup-campo input:focus,
.presup-campo textarea:focus {
    border-color: var(--color-principal, #059669);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
    background: #fff;
}
.presup-campo textarea { resize: vertical; }
.presup-privacidad-label {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    text-transform: none;
    letter-spacing: normal;
}
.presup-privacidad-label input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0.1rem 0 0;
}

/* ── Sección de diseño ── */
.presup-seccion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.presup-sec-titulo {
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.presup-diseno-row {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
}
.presup-separador {
    border: none;
    border-top: 1px dashed #e5e7eb;
    margin: 0.75rem 0;
}

/* ── Miniatura SVG ── */
.presup-thumb-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.presup-thumb-vacio {
    width: 140px;
    height: 140px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #9ca3af;
    border: 1.5px dashed #d1d5db;
}

/* ── Campo m² ── */
.presup-m2-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: 140px;
}
.presup-m2-wrap label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.presup-m2-wrap input {
    border: 1.5px solid #d1d5db;
    border-radius: 0.4rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: #111827;
    background: #f9fafb;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}
.presup-m2-wrap input:focus {
    border-color: var(--color-principal, #059669);
    background: #fff;
}
.presup-cantidad-minimo {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-principal, #059669);
    line-height: 1.2;
}

/* ── Info olambrilla ── */
.presup-olambrilla-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin-top: 0.35rem;
    padding: 0.3rem 0.5rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.35rem;
    width: 100%;
    box-sizing: border-box;
}
.presup-olambrilla-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #059669;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.presup-olambrilla-valor {
    font-size: 0.85rem;
    font-weight: 700;
    color: #047857;
    white-space: nowrap;
}

/* ── Calculadora KORA8 ── */
.presup-kora8-wrap {
    margin-top: 0.4rem;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 0.4rem;
    background: #f9fafb;
    padding: 0.4rem 0.5rem;
}
.presup-kora8-extra {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: #374151;
    margin-bottom: 0.3rem;
    cursor: pointer;
}
.presup-kora8-linea {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.18rem 0;
}
.presup-kora8-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #4b5563;
}
.presup-kora8-linea strong {
    font-size: 0.88rem;
    color: #111827;
}

/* ── Tabla de piezas ── */
.presup-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
}
.presup-tabla thead tr {
    background: #f3f4f6;
}
.presup-tabla th {
    padding: 0.3rem 0.4rem;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}
.presup-tabla td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.presup-tabla tbody tr:last-child td { border-bottom: none; }
.presup-tabla tbody tr:hover { background: #fafafa; }

.presup-td-img {
    width: 65px;
}
.presup-molde-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    border: 1px solid #e5e7eb;
}
.presup-molde-fallback {
    width: 50px;
    height: 50px;
    background: #e5e7eb;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
}
.presup-td-nombre {
    font-weight: 600;
    color: #111827;
    max-width: 110px;
}
.presup-td-color {
    white-space: nowrap;
}
.presup-color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.12);
    vertical-align: middle;
    margin-right: 6px;
}
.presup-color-hex {
    font-family: monospace;
    font-size: 0.68rem;
    color: #374151;
    vertical-align: middle;
}
.presup-td-nombre {
    font-weight: 600;
    color: #111827;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presup-sin-piezas {
    font-size: 0.78rem;
    color: #9ca3af;
    font-style: italic;
    padding: 0.5rem 0;
}

/* ── Footer ── */
.presup-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.presup-btn-cancelar {
    background: none;
    border: 1.5px solid #d1d5db;
    border-radius: 0.6rem;
    padding: 0.55rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.presup-btn-cancelar:hover { border-color: #9ca3af; color: #374151; }

.presup-btn-enviar {
    border: none;
    border-radius: 0.6rem;
    padding: 0.55rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}
.presup-btn-enviar:disabled { opacity: 0.6; cursor: not-allowed; }

.presup-aviso-error {
    width: 100%;
    order: -1;
    text-align: center;
    font-size: 0.8rem;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.4rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.25rem;
}

/* ── Pantalla de éxito ── */
.presup-exito {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 280px;
    color: var(--color-principal, #059669);
}
.presup-exito h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #111827;
}
.presup-exito p {
    font-size: 0.9rem;
    color: #6b7280;
}
.presup-btn-cerrar-exito {
    margin-top: 0.75rem;
    border: none;
    border-radius: 0.6rem;
    padding: 0.6rem 1.75rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}

/* Language selector (header) */
#lang-selector .lang-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    padding: 0.25rem;
    cursor: pointer;
}
#lang-selector .lang-btn.lang-active {
    outline: 2px solid var(--color-principal, #059669);
    border-radius: 6px;
}

/* Ensure language selector sits at the far right and flags have uniform spacing */
#lang-selector {
    margin-left: auto; /* push to the right in the header flex container */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#lang-selector .lang-btn {
    width: 36px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 6px;
}
#lang-selector .lang-btn:hover { background: rgba(0,0,0,0.04); }

/* ── Responsivo: móvil ── */
@media (max-width: 640px) {
    #presupuesto-backdrop { padding: 0; align-items: flex-end; }
    #presupuesto-modal {
        height: 95dvh;
        max-height: 95vh;
        max-height: 95dvh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        max-width: 100%;
    }
    .presup-body {
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .presup-col-form,
    .presup-col-resumen {
        flex: 0 0 auto;
        overflow: visible;
    }
    .presup-col-form {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .presup-diseno-row { flex-direction: column; align-items: flex-start; }
    .presup-thumb-wrap { flex-direction: row; align-items: flex-end; gap: 0.75rem; }
    .presup-m2-wrap { width: auto; flex: 1; }
    .presup-tabla { font-size: 0.75rem; }
}
