/* =========================================================
   SIMULADOR DE AMBIENTES - NUEVA ESTRUCTURA
   3 SHORTCODES: [sp_carrusel] [sp_canvas] [sp_panel]
========================================================= */

#sp-simulador-layout,
.sp-simulador-page,
.sp-shortcodes-layout {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

/* =========================================================
   GALERIA / CARRUSEL
========================================================= */

#sp-carrusel-container,
.sp-carrusel-container {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0 54px;
    box-sizing: border-box;
    background: transparent;
}

#sp-galeria-ambientes,
.sp-galeria-ambientes {
    width: 100%;
    display: flex;
    align-items: stretch;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 2px 12px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-sizing: border-box;
}

#sp-galeria-ambientes::-webkit-scrollbar {
    display: none;
}

.sp-carrusel-arrow,
#sp-carrusel-prev,
#sp-carrusel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    background: #fff;
    color: #111827;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    cursor: pointer;
    font-size: 34px;
    line-height: 40px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s ease;
}

#sp-carrusel-prev,
.sp-carrusel-arrow-prev {
    left: 8px;
}

#sp-carrusel-next,
.sp-carrusel-arrow-next {
    right: 8px;
}

.sp-carrusel-arrow:hover,
#sp-carrusel-prev:hover,
#sp-carrusel-next:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 18px rgba(0,0,0,.22);
}

.sp-ambiente-card {
    flex: 0 0 120px;
    cursor: pointer;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    border: 2px solid #e5e7eb;
    transition: .2s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.sp-ambiente-card:hover {
    transform: translateY(-3px);
}

.sp-ambiente-card.activo {
    border: 3px solid #0b57d0;
    box-shadow: 0 4px 14px rgba(11,87,208,.20);
}

.sp-ambiente-card img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
}

.sp-ambiente-card span {
    display: block;
    padding: 8px 5px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-loading-ambientes {
    width: 100%;
    padding: 18px;
    text-align: center;
    color: #6b7280;
}

/* =========================================================
   CANVAS
========================================================= */

#sp-simulador-wrapper,
.sp-simulador-wrapper {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fff;
    border-radius: 0;
    box-sizing: border-box;
}

#sp-canvas-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

#sp-canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    display: block;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

#sp-canvas-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.82);
    z-index: 10;
    font-size: 17px;
    font-weight: 600;
    color: #374151;
    pointer-events: none;
}

/* =========================================================
   PANEL DE SELECCION
========================================================= */

#sp-panel-colores,
.sp-panel-colores {
    width: 100%;
    min-width: 0;
    padding: 8px 0 0;
    background: #fff;
    box-sizing: border-box;
}

.sp-panel-titulo {
    margin: 0 0 18px;
    font-size: clamp(28px, 2.1vw, 40px);
    line-height: 1.15;
    font-weight: 500;
    color: #222;
}

/* =========================================================
   COLOR SELECCIONADO
========================================================= */

#sp-ficha-color,
.sp-ficha-color {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 10px;
    padding: 0;
    background: #fff;
    border: 0;
    box-shadow: none;
}

#sp-ficha-color-header {
    display: flex;
    align-items: center;
    gap: 18px;
}

#sp-color-preview,
.sp-color-preview {
    width: 88px;
    height: 74px;
    flex: 0 0 88px;
    border-radius: 4px;
    border: 1px solid #d9dde3;
    background: #fff;
    box-shadow: none;
}

#sp-color-info,
.sp-color-info {
    min-width: 0;
    flex: 1 1 auto;
}

.sp-btn-cartillas {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    min-height: 26px;
    margin: 0;
    padding: 5px 9px;
    background: #0b57d0;
    color: #fff !important;
    border-radius: 5px;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.1;
}

.sp-btn-cartillas:hover {
    background: #0848ae;
}

#sp-ficha-contenido {
    line-height: 1.45;
    font-size: 12px;
    color: #374151;
}

#sp-ficha-contenido strong {
    color: #1f2937;
}

/* =========================================================
   CARTILLA HORIZONTAL
========================================================= */

.sp-cartilla-heading {
    margin: 4px 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

#sp-cartilla-colores,
.sp-cartilla-colores {
    display: grid;
    grid-template-columns: repeat(6, minmax(54px, 1fr));
    grid-auto-rows: 58px;
    gap: 9px;
    width: 100%;
    max-height: 192px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 3px 8px 2px;
    box-sizing: border-box;
}

#sp-cartilla-colores::-webkit-scrollbar {
    width: 7px;
}

#sp-cartilla-colores::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 20px;
}

.sp-color-item {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 54px;
    border: 2px solid #fff;
    border-radius: 4px;
    outline: 1px solid #d9dde3;
    cursor: pointer;
    transition: .18s ease;
    box-sizing: border-box;
}

.sp-color-item:hover {
    transform: scale(1.04);
    z-index: 2;
}

.sp-color-item.activo {
    border: 3px solid #0b57d0;
    outline: none;
    transform: scale(1.04);
    box-shadow: 0 3px 10px rgba(11,87,208,.25);
    z-index: 3;
}

/* =========================================================
   FILTROS: CARTILLA + FAMILIA + BUSCADOR
========================================================= */

.sp-filtros-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 12px;
}

.sp-filtro-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #222;
}

#sp-cartilla-selector,
#sp-familia-selector {
    width: 100%;
    height: 50px;
    max-width: none;
    padding: 0 14px;
    font-size: 15px;
    color: #555;
    border: 1px solid #dedede;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
}

#sp-buscador-container,
.sp-buscador-container {
    margin: 14px 0 18px;
}

#sp-buscador-color {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border: 1px solid #dedede;
    border-radius: 8px;
    font-size: 15px;
    color: #374151;
    box-sizing: border-box;
}

#sp-buscador-color:focus,
#sp-cartilla-selector:focus,
#sp-familia-selector:focus {
    outline: none;
    border-color: #0b57d0;
    box-shadow: 0 0 0 2px rgba(11,87,208,.08);
}

/* =========================================================
   BOTONES EN PANEL
========================================================= */

#sp-panel-acciones,
.sp-panel-acciones {
    display: grid;
    grid-template-columns: 1fr 1.35fr 1fr;
    gap: 10px;
    align-items: stretch;
    margin-top: 4px;
}

.sp-btn {
    min-height: 48px;
    padding: 10px 14px;
    border: 0;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
    transition: .2s ease;
}

.sp-btn:hover {
    transform: translateY(-1px);
}

.sp-btn-original,
#sp-toggle-original {
    background: #202b3b;
    color: #fff;
}

.sp-btn-descarga,
#sp-descargar-imagen {
    background: #4f9eaa;
    color: #fff;
}

.sp-btn-producto,
#sp-elegir-productos {
    background: #f58220;
    color: #fff !important;
}

/* Los botones ya no pertenecen al Canvas */
#sp-simulador-wrapper #sp-comparacion-container,
#sp-canvas-container #sp-comparacion-container {
    display: none !important;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1200px) {
    #sp-cartilla-colores {
        grid-template-columns: repeat(6, minmax(52px, 1fr));
    }
}

@media (max-width: 900px) {
    .sp-filtros-panel {
        grid-template-columns: 1fr;
    }

    #sp-panel-acciones {
        grid-template-columns: 1fr;
    }

    #sp-cartilla-colores {
        grid-template-columns: repeat(6, minmax(50px, 1fr));
    }
}

@media (max-width: 768px) {
    #sp-carrusel-container {
        padding: 0 43px;
    }

    .sp-carrusel-arrow,
    #sp-carrusel-prev,
    #sp-carrusel-next {
        width: 36px;
        height: 36px;
        font-size: 27px;
        line-height: 32px;
    }

    #sp-carrusel-prev,
    .sp-carrusel-arrow-prev {
        left: 3px;
    }

    #sp-carrusel-next,
    .sp-carrusel-arrow-next {
        right: 3px;
    }

    .sp-ambiente-card {
        flex-basis: 95px;
    }

    .sp-ambiente-card img {
        height: 60px;
    }

    .sp-panel-titulo {
        font-size: 28px;
    }

    #sp-ficha-color {
        margin-bottom: 14px;
    }

    #sp-ficha-color {
        gap: 10px;
        align-items: flex-start;
    }

    #sp-color-preview {
        width: 74px;
        height: 62px;
        flex-basis: 74px;
    }

    .sp-btn-cartillas {
        padding: 5px 8px;
        font-size: 10px;
        min-height: 24px;
    }

    #sp-cartilla-colores {
        grid-template-columns: repeat(5, minmax(48px, 1fr));
        grid-auto-rows: 50px;
        max-height: 168px;
    }
}

@media (max-width: 520px) {
    #sp-ficha-color {
        flex-wrap: wrap;
    }

    #sp-color-preview {
        width: 70px;
        height: 58px;
        flex-basis: 70px;
    }

    .sp-btn-cartillas {
        width: auto;
    }

    #sp-cartilla-colores {
        grid-template-columns: repeat(4, minmax(48px, 1fr));
        grid-auto-rows: 48px;
        max-height: 159px;
    }
}

/* La ficha de muestra NO muestra la familia. */
#sp-ficha-contenido .sp-ficha-familia,
#sp-ficha-contenido [data-ficha="familia"],
#sp-ficha-contenido .familia,
#sp-ficha-contenido .familias,
#sp-ficha-contenido .sp-familia,
#sp-ficha-contenido [class*="familia"] {
    display: none !important;
}
