/* =======================================================
   💎 1. EL MOTOR DE LA GRILLA KUMARA (TITANIO RESPONSIVO)
   ======================================================= */

/* Contenedor Fila (Row) - El cerebro repartidor */
.km-row {
    display: flex;
    width: 100%;
    max-width: 100%;
    /* Ancho máximo profesional */

    margin: 0 auto;
    /* Centrado automático */
    box-sizing: border-box;
    gap: var(--km-row-gap, 20px);
    /* Espaciado moderno entre columnas */
    padding: var(--km-row-padding, 15px);
    /* Padding dinámico */
    align-items: stretch;
    /* Se estiran por defecto */
    transition: all 0.3s ease;
}

/* Columna (Col) - La unidad flexible */
.km-col {
    flex: 1;
    /* Ocupa el espacio equitativamente por defecto */
    display: flex;
    flex-direction: column;
    /* Para que su contenido fluya hacia abajo */
    box-sizing: border-box;
    position: relative;
    min-height: 50px;
    /* Evita que colapse si está vacía */
    transition: all 0.3s ease;
    min-width: 0 !important;
}

/* 📱 MAGIA RESPONSIVA: Comportamientos en Móvil (<= 768px) */
@media (max-width: 768px) {

    /* Modo 1: APILADO (Stack) - La vieja confiable, 100% de ancho */
    .km-row[data-mobile="stack"] {
        flex-wrap: wrap !important;
        gap: 15px;
    }

    .km-row[data-mobile="stack"]>.km-col {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Modo 2: COMPACTO (Compact) - Lado a lado, forzado */
    .km-row[data-mobile="compact"] {
        flex-wrap: nowrap !important;
        overflow: hidden;
        /* Evita desbordes horizontales feos */
        gap: 10px;
        /* Reducimos el gap para que quepan mejor */
    }

    .km-row[data-mobile="compact"]>.km-col {
        min-width: 0 !important;
        /* Rompe la resistencia del contenido */
        flex: 1 1 0% !important;
        /* Fuerza a que todas midan exactamente igual */
    }

    /* Modo 3: SCROLL (Carrusel Nativo) - Estilo Netflix/Apps modernas */
    .km-row[data-mobile="scroll"] {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
        /* Espacio para la barra de scroll */
        gap: 15px;
    }

    .km-row[data-mobile="scroll"]::-webkit-scrollbar {
        height: 4px;
    }

    .km-row[data-mobile="scroll"]::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 4px;
    }

    .km-row[data-mobile="scroll"]::-webkit-scrollbar-thumb {
        background: #0d6efd;
        border-radius: 4px;
    }

    .km-row[data-mobile="scroll"]>.km-col {
        flex: 0 0 85% !important;
        /* Muestra un "pedacito" de la siguiente columna */
        scroll-snap-align: center;
    }
}

/* 🛠️ AYUDAS VISUALES EN EL EDITOR DE GRAPESJS */
.gjs-dashed .km-col {
    outline: 1px dashed rgba(13, 110, 253, 0.4);
    outline-offset: -2px;
    background-color: rgba(13, 110, 253, 0.02);
}

.gjs-dashed .km-col:empty::before {
    content: '＋ Soltar contenido aquí';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 80px;
    color: rgba(13, 110, 253, 0.5);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}


/* =======================================================
   ✨ 2. INTERFAZ DEL MODAL (ESTÉTICA PREMIUM KUMARA)
   ======================================================= */

/* Fondo oscuro con desenfoque (Glassmorphism) */
.km-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: kmFadeIn 0.3s ease;
    margin-top: 10%;

}

/* La tarjeta del Modal */
.km-modal-content {
    background: #1e293b;
    /* Tono oscuro azulado elegante */
    width: 400px;
    max-width: 90%;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    overflow: hidden;
    transform: translateY(0);
    animation: kmSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Cabecera */
.km-modal-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Botón cerrar sutil */
.km-btn-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}

.km-btn-close:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

/* Cuerpo del Formulario */
.km-modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.km-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.km-label {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Inputs / Selects Premium */
.km-select {
    width: 100%;
    padding: 12px 16px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #f8fafc;
    font-size: 14px;
    appearance: none;
    /* Quita flecha nativa */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.km-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Pie y Botón de Acción */
.km-modal-footer {
    padding: 20px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.km-btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
}

.km-btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.km-btn-primary:active {
    transform: translateY(1px);
}

/* Animaciones */
@keyframes kmFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes kmSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}



/* =========================================
   SISTEMA DE PROPORCIONES (LAYOUTS VISUALES)
   ========================================= */

/* --- 2 COLUMNAS --- */
.km-row[data-layout="50-50"]>.km-col {
    flex: 1 1 0% !important;
}

.km-row[data-layout="30-70"]>.km-col:nth-child(1) {
    flex: 3 1 0% !important;
}

.km-row[data-layout="30-70"]>.km-col:nth-child(2) {
    flex: 7 1 0% !important;
}

.km-row[data-layout="70-30"]>.km-col:nth-child(1) {
    flex: 7 1 0% !important;
}

.km-row[data-layout="70-30"]>.km-col:nth-child(2) {
    flex: 3 1 0% !important;
}

/* --- 3 COLUMNAS --- */
.km-row[data-layout="33-33-33"]>.km-col {
    flex: 1 1 0% !important;
}

.km-row[data-layout="50-25-25"]>.km-col:nth-child(1) {
    flex: 2 1 0% !important;
}

.km-row[data-layout="50-25-25"]>.km-col:nth-child(2),
.km-row[data-layout="50-25-25"]>.km-col:nth-child(3) {
    flex: 1 1 0% !important;
}

.km-row[data-layout="25-50-25"]>.km-col:nth-child(1),
.km-row[data-layout="25-50-25"]>.km-col:nth-child(3) {
    flex: 1 1 0% !important;
}

.km-row[data-layout="25-50-25"]>.km-col:nth-child(2) {
    flex: 2 1 0% !important;
}

.km-row[data-layout="25-25-50"]>.km-col:nth-child(1),
.km-row[data-layout="25-25-50"]>.km-col:nth-child(2) {
    flex: 1 1 0% !important;
}

.km-row[data-layout="25-25-50"]>.km-col:nth-child(3) {
    flex: 2 1 0% !important;
}

/* --- 4 COLUMNAS --- */
.km-row[data-layout="25-25-25-25"]>.km-col {
    flex: 1 1 0% !important;
}



/* ESTILOS DEL MODAL  */

.km-layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.km-layout-btn {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.km-layout-btn:hover,
.km-layout-btn.selected {
    border-color: #0d6efd;
    background: #1a2332;
}

.km-icon-row {
    display: flex;
    gap: 4px;
    height: 25px;
    margin-bottom: 5px;
}

.km-icon-col {
    background: #666;
    border-radius: 3px;
    height: 100%;
}

.km-layout-btn.selected .km-icon-col {
    background: #0d6efd;
}

.km-layout-label {
    font-size: 11px;
    color: #aaa;
    text-align: center;
}

/* 1. LIMITAR ALTURA Y ACTIVAR SCROLL */
#km-modal-columnas {

    max-height: 100vh;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    margin: 0 auto;

}


/* 2. SCROLLBAR MINIMALISTA (Estilo Kumara) */
#km-modal-columnas::-webkit-scrollbar {
    width: 6px;
    /* Muy delgadito */
}

#km-modal-columnas::-webkit-scrollbar-track {
    background: transparent;
    /* Fondo invisible */
}

#km-modal-columnas::-webkit-scrollbar-thumb {
    background: #444;
    /* Color oscuro para el scroll */
    border-radius: 10px;
}

#km-modal-columnas::-webkit-scrollbar-thumb:hover {
    background: #0d6efd;
    /* Cambia a azul Kumara al pasar el mouse */
}

/* 3. OPTIMIZACIÓN DE ESPACIOS (Para hacerlo más compacto) */
#km-modal-columnas .km-form-group {
    margin-bottom: 12px;
    /* Reducimos el margen entre grupos */
}

#km-modal-columnas .km-label {
    margin-bottom: 5px;
    font-size: 13px;
    /* Texto un poco más pequeño */
}

#km-modal-columnas h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    /* Título menos invasivo */
}