/**
 * Template Loop Grid - Estilos
 * Widget standalone de Elementor con carga instantánea "Cargar Más"
 * 
 * @version 1.0.0
 */

/* ===================================
   Variables CSS
   =================================== */
:root {
    --tlg-animation-duration: 400ms;
    --tlg-button-bg: #0073aa;
    --tlg-button-color: #ffffff;
    --tlg-button-bg-hover: #005177;
    --tlg-placeholder-bg: #f0f0f0;
}

/* ===================================
   Wrapper Principal
   =================================== */
.tlg-wrapper {
    width: 100%;
}

/* ===================================
   Grid Layout
   =================================== */
.tlg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

/* ===================================
   Items del Grid
   =================================== */
.tlg-item {
    position: relative;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity var(--tlg-animation-duration) ease,
                transform var(--tlg-animation-duration) ease;
}

/* Items ocultos - Estado inicial */
.tlg-item--hidden {
    display: none;
    opacity: 0;
}

/* ===================================
   Animaciones al Mostrar
   =================================== */

/* Fade In */
.tlg-wrapper[data-animation="fade"] .tlg-item--hidden.tlg-item--showing {
    opacity: 0;
}

.tlg-wrapper[data-animation="fade"] .tlg-item--hidden.tlg-item--visible {
    opacity: 1;
}

/* Slide Up */
.tlg-wrapper[data-animation="slide-up"] .tlg-item--hidden.tlg-item--showing {
    opacity: 0;
    transform: translateY(30px);
}

.tlg-wrapper[data-animation="slide-up"] .tlg-item--hidden.tlg-item--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Scale */
.tlg-wrapper[data-animation="scale"] .tlg-item--hidden.tlg-item--showing {
    opacity: 0;
    transform: scale(0.8);
}

.tlg-wrapper[data-animation="scale"] .tlg-item--hidden.tlg-item--visible {
    opacity: 1;
    transform: scale(1);
}

/* Sin animación */
.tlg-wrapper[data-animation="none"] .tlg-item--hidden.tlg-item--visible {
    opacity: 1;
}

/* ===================================
   Botón Cargar Más
   =================================== */
.tlg-load-more-wrapper {
    margin-top: 30px;
    text-align: center;
}

.tlg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--tlg-button-color);
    background-color: var(--tlg-button-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    gap: 8px;
}

.tlg-button:hover {
    background-color: var(--tlg-button-bg-hover);
    transform: translateY(-2px);
}

.tlg-button:focus {
    outline: 2px solid var(--tlg-button-bg);
    outline-offset: 2px;
}

.tlg-button:active {
    transform: translateY(0);
}

/* Icono del botón */
.tlg-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tlg-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.tlg-icon i {
    font-size: inherit;
}

.tlg-icon--before {
    margin-right: 8px;
}

.tlg-icon--after {
    margin-left: 8px;
}

/* Spinner del botón (oculto por defecto) */
.tlg-button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tlg-spin 0.8s linear infinite;
}

@keyframes tlg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Estado: Botón cargando */
.tlg-button--loading {
    pointer-events: none;
    cursor: default;
}

.tlg-button--loading .tlg-button-text,
.tlg-button--loading .tlg-icon {
    display: none;
}

.tlg-button--loading .tlg-button-spinner {
    display: inline-block;
}

/* Estado: Botón deshabilitado (después de cargar) */
.tlg-button--disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.tlg-button--disabled:hover {
    transform: none;
    background-color: var(--tlg-button-bg);
}

/* Estado: Botón ocultándose */
.tlg-load-more-wrapper.tlg-hiding {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.tlg-load-more-wrapper.tlg-hidden {
    display: none;
}

/* ===================================
   Mensaje de Error / Sin Contenido
   =================================== */
.tlg-no-template,
.tlg-no-posts {
    padding: 40px 20px;
    text-align: center;
    background-color: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 8px;
    color: #666;
}

.tlg-no-template p,
.tlg-no-posts p {
    margin: 0;
    font-size: 14px;
}

/* ===================================
   Preview en Editor
   =================================== */
.tlg-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background-color: var(--tlg-placeholder-bg);
    border: 1px dashed #ccc;
    border-radius: 4px;
    color: #999;
    gap: 10px;
}

.tlg-placeholder i {
    font-size: 32px;
    opacity: 0.5;
}

.tlg-placeholder span {
    font-size: 14px;
    font-weight: 500;
}

.tlg-item--preview {
    background-color: #fff;
    border-radius: 4px;
}

/* ===================================
   Responsive - Tablet
   =================================== */
@media screen and (max-width: 1024px) {
    .tlg-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .tlg-button {
        padding: 10px 20px;
        font-size: 15px;
    }

    .tlg-load-more-wrapper {
        margin-top: 25px;
    }
}

/* ===================================
   Responsive - Mobile
   =================================== */
@media screen and (max-width: 767px) {
    .tlg-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .tlg-button {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    .tlg-load-more-wrapper {
        margin-top: 20px;
    }

    .tlg-placeholder {
        min-height: 150px;
    }
}

/* ===================================
   Accesibilidad - Focus Visible
   =================================== */
@media (prefers-reduced-motion: reduce) {
    .tlg-item,
    .tlg-button,
    .tlg-load-more-wrapper {
        transition: none !important;
    }

    .tlg-wrapper[data-animation="fade"] .tlg-item--hidden.tlg-item--showing,
    .tlg-wrapper[data-animation="slide-up"] .tlg-item--hidden.tlg-item--showing,
    .tlg-wrapper[data-animation="scale"] .tlg-item--hidden.tlg-item--showing {
        opacity: 1;
        transform: none;
    }

    .tlg-button-spinner {
        animation: none;
    }
}

/* Focus visible para navegación por teclado */
.tlg-button:focus-visible {
    outline: 3px solid var(--tlg-button-bg);
    outline-offset: 3px;
}

/* ===================================
   Print Styles
   =================================== */
@media print {
    .tlg-item--hidden {
        display: block !important;
        opacity: 1 !important;
    }

    .tlg-load-more-wrapper {
        display: none !important;
    }
}
