
/* ==========================================================
   HOME LAYOUT PREVIEW
   CSS completo para la vista de edición de layouts
   ========================================================== */

.home-layout-preview,
.home-layout-preview *,
.home-layout-preview *::before,
.home-layout-preview *::after {
    box-sizing: border-box;
}

.home-layout-preview-wrapper {
    width: 100%;
    min-width: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
}

.home-layout-preview {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 16px;
    overflow: hidden;
    background: #f3f5f8;
    border: 1px solid #d7dfe8;
    border-radius: 4px;
}

/* ==========================================================
   CONTENEDORES Y ESTRUCTURA
   ========================================================== */

.home-layout-preview .grid-section {
    display: block;
    width: 100%;
    min-width: 0;
}

.home-layout-preview .home-layout-container {
    min-width: 0;
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
}

/* Flex solo en contenedores que tengan la clase original */
.home-layout-preview .home-layout-container.flex {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    min-width: 0;
}

/* ==========================================================
   COLUMNAS FLEX
   Se descuenta el gap de 16 px para evitar desbordamientos.
   ========================================================== */

.home-layout-preview .home-layout-container.flex > .col-1-1 {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
}

.home-layout-preview .home-layout-container.flex > .col-1-2 {
    flex: 0 0 calc((100% - 16px) / 2);
    width: calc((100% - 16px) / 2);
    max-width: calc((100% - 16px) / 2);
}

.home-layout-preview .home-layout-container.flex > .col-1-3 {
    flex: 0 0 calc((100% - 32px) / 3);
    width: calc((100% - 32px) / 3);
    max-width: calc((100% - 32px) / 3);
}

.home-layout-preview .home-layout-container.flex > .col-1-4 {
    flex: 0 0 calc((100% - 48px) / 4);
    width: calc((100% - 48px) / 4);
    max-width: calc((100% - 48px) / 4);
}

/* Separación entre elementos */
.home-layout-preview .grid-gutter-2 {
    column-gap: 16px;
    row-gap: 16px;
}

/* Gutter interior */
.home-layout-preview .gutter-2 {
    padding-left: 8px;
    padding-right: 8px;
}

/* ==========================================================
   CONTENEDORES GRID
   ========================================================== */

.home-layout-preview .home-layout-container.grid-1-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
}

.home-layout-preview .home-layout-container.grid-1-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
}

.home-layout-preview .home-layout-container.grid-1-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
}

.home-layout-preview .home-layout-container.grid-1-2,
.home-layout-preview .home-layout-container.grid-1-3,
.home-layout-preview .home-layout-container.grid-1-4 {
    gap: 16px;
}

.home-layout-preview .home-layout-container.grid-1-2 > *,
.home-layout-preview .home-layout-container.grid-1-3 > *,
.home-layout-preview .home-layout-container.grid-1-4 > * {
    min-width: 0;
    max-width: 100%;
}

/* ==========================================================
   ESPACIADOS ORIGINALES
   ========================================================== */

.home-layout-preview .pt-1 {
    padding-top: 4px;
}

.home-layout-preview .pt-2 {
    padding-top: 8px;
}

.home-layout-preview .pt-4 {
    padding-top: 16px;
}

.home-layout-preview .pb-2 {
    padding-bottom: 8px;
}

.home-layout-preview .pb-4 {
    padding-bottom: 16px;
}

/* ==========================================================
   SLOTS DE IMAGEN
   ========================================================== */

.home-layout-preview .home-layout-slot {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

/* Vista previa de imagen */
.home-layout-preview .home-layout-slot-preview {
    position: relative;
    width: 100%;
    min-width: 0;
    aspect-ratio: var(--slot-ratio, 1 / 1);
    overflow: hidden;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #e9ecef;
}

/* Contenedor de imagen existente */
.home-layout-preview .home-layout-slot-existing {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Imagen existente */
.home-layout-preview .home-layout-slot-existing img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
}

/* Imagen alternativa sin clase .home-layout-slot-existing */
.home-layout-preview .home-layout-slot-preview > img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
}

/* Slot vacío */
.home-layout-preview .home-layout-slot-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 80px;
    color: #9aa4ad;
    text-align: center;
}

.home-layout-preview .home-layout-slot-empty i {
    margin-bottom: 8px;
    font-size: 24px;
}

.home-layout-preview .home-layout-slot-empty span {
    font-size: 12px;
}

.home-layout-preview .home-layout-slot-empty small {
    max-width: 95%;
    overflow-wrap: anywhere;
    font-size: 10px;
}

/* Información del slot */
.home-layout-preview .home-layout-slot-info {
    position: absolute;
    z-index: 2;
    top: 6px;
    right: 6px;
    left: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 5px 7px;
    color: #fff;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 0;
}

.home-layout-preview .home-layout-slot-info strong,
.home-layout-preview .home-layout-slot-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Nombre de imagen */
.home-layout-preview .home-layout-slot-existing-name {
    position: absolute;
    right: 4px;
    bottom: 4px;
    left: 4px;
    overflow: hidden;
    padding: 3px 5px;
    color: #fff;
    font-size: 10px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.55);
}

/* ==========================================================
   FORMULARIO DE EDICIÓN
   ========================================================== */

.home-layout-preview .home-layout-slot-fields {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
}

.home-layout-preview .home-layout-slot-fields input,
.home-layout-preview .home-layout-slot-fields select,
.home-layout-preview .home-layout-slot-fields textarea {
    box-sizing: border-box;
    max-width: 100%;
}

.home-layout-preview .home-layout-slot-fields img,
.home-layout-preview img {
    max-width: 100%;
}

.home-layout-preview img.responsive {
    display: block;
    width: 100%;
    height: auto;
}

.home-layout-preview a {
    min-width: 0;
}

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

@media (max-width: 767px) {

    .home-layout-preview {
        padding: 10px;
    }

    .home-layout-preview .home-layout-container.flex > .col-1-2.col-1-1-m,
    .home-layout-preview .home-layout-container.flex > .col-1-3.col-1-1-m,
    .home-layout-preview .home-layout-container.flex > .col-1-4.col-1-1-m {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }

    .home-layout-preview .home-layout-container.grid-1-2,
    .home-layout-preview .home-layout-container.grid-1-3,
    .home-layout-preview .home-layout-container.grid-1-4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .home-layout-preview .home-layout-slot-fields {
        padding: 10px;
    }
}
