/**
 * Twingital Grid Pro - Main Styles
 * Version: 1.0.4 - FIXED para conflictos de CSS
 * 
 * CAMBIOS EN ESTA VERSIÓN:
 * ✅ Agregado !important a estilos críticos de layout
 * ✅ Aumentada especificidad con selectores más específicos
 * ✅ Prevención de conflictos con temas de WordPress
 */

/* ============================================================================
   RESET Y BASE - Con !important para prevenir conflictos
   ========================================================================= */

.tgp-container,
.tgp-grid,
.tgp-masonry,
.tgp-list,
.tgp-carousel,
.tgp-layout-carousel,
.tgp-layout-coverflow,
.tgp-layout-grid,
.tgp-layout-masonry,
.tgp-layout-list {
    box-sizing: border-box !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.tgp-container *,
.tgp-grid *,
.tgp-masonry *,
.tgp-list *,
.tgp-carousel * {
    box-sizing: border-box;
}

/* ============================================================================
   GRID LAYOUT - Con !important en display
   ========================================================================= */

.tgp-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--tgp-columns, 3), 1fr) !important;
    gap: var(--tgp-gap, 30px) !important;
    width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Responsive Grid */
@media (max-width: 1024px) {
    .tgp-grid {
        grid-template-columns: repeat(var(--tgp-columns-tablet, 2), 1fr) !important;
    }
}

@media (max-width: 768px) {
    .tgp-grid {
        grid-template-columns: repeat(var(--tgp-columns-mobile, 1), 1fr) !important;
    }
}

/* ============================================================================
   MASONRY LAYOUT
   ========================================================================= */

.tgp-masonry {
    display: block !important;
    width: 100% !important;
}

.tgp-masonry::after {
    content: '';
    display: block;
    clear: both;
}

.tgp-masonry .tgp-card {
    float: left;
    width: calc((100% - (var(--tgp-gap, 30px) * (var(--tgp-columns, 3) - 1))) / var(--tgp-columns, 3));
    margin-bottom: var(--tgp-gap, 30px);
}

/* ============================================================================
   LIST LAYOUT - ✅ CORREGIDO: Imágenes con tamaño fijo
   ========================================================================= */

.tgp-list {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--tgp-gap, 30px) !important;
    width: 100% !important;
}

.tgp-list .tgp-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start; /* ✅ Alinear arriba */
    min-height: 200px; /* ✅ Altura mínima */
}

.tgp-list .tgp-card-image {
    flex: 0 0 300px !important; /* ✅ Tamaño fijo */
    max-width: 300px !important;
    height: 200px !important; /* ✅ Altura fija */
    overflow: hidden !important;
}

/* ✅ CRÍTICO: Evitar que el ratio empuje contenido */
.tgp-list .tgp-card-image.tgp-ratio-16-9,
.tgp-list .tgp-card-image.tgp-ratio-4-3,
.tgp-list .tgp-card-image.tgp-ratio-1-1,
.tgp-list .tgp-card-image.tgp-ratio-21-9 {
    padding-bottom: 0 !important; /* ✅ Remover padding del ratio */
    height: 200px !important; /* ✅ Forzar altura fija */
}

.tgp-list .tgp-card-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.tgp-list .tgp-card-content {
    flex: 1 !important;
    padding: 0 0 0 24px !important; /* ✅ Padding solo izquierda */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
}

@media (max-width: 768px) {
    .tgp-list .tgp-card {
        flex-direction: column !important;
        min-height: auto;
    }
    
    .tgp-list .tgp-card-image {
        flex: 0 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 250px !important;
    }
    
    .tgp-list .tgp-card-content {
        padding: 20px !important;
    }
}

/* ============================================================================
   CARD STYLES - Con !important en display y visibilidad
   ========================================================================= */

.tgp-card {
    display: block !important;
    position: relative;
    background: var(--tgp-card-bg, #ffffff) !important;
    border-radius: var(--tgp-border-radius, 8px);
    overflow: hidden !important;
    transition: all 0.3s ease;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Card Styles */
.tgp-card.tgp-style-classic {
    border: 1px solid var(--tgp-border-color, #e5e7eb);
    background: var(--tgp-card-bg, #ffffff);
}

.tgp-card.tgp-style-modern {
    border: none;
    background: var(--tgp-card-bg, #ffffff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tgp-card.tgp-style-minimal {
    border: none;
    background: transparent;
}

.tgp-card.tgp-style-minimal .tgp-card-content {
    padding: 16px 0 !important;
}

.tgp-card.tgp-style-overlay .tgp-card-inner {
    position: relative;
}

.tgp-card.tgp-style-overlay .tgp-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    color: #ffffff;
    padding: 24px !important;
}

.tgp-card.tgp-style-overlay .tgp-card-title,
.tgp-card.tgp-style-overlay .tgp-card-title a,
.tgp-card.tgp-style-overlay .tgp-card-excerpt,
.tgp-card.tgp-style-overlay .tgp-card-meta {
    color: #ffffff !important;
}

.tgp-card.tgp-style-overlay .tgp-category-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    backdrop-filter: blur(10px);
}

.tgp-card.tgp-style-bordered {
    border: 1px solid var(--tgp-border-color, #e5e7eb);
}

.tgp-card.tgp-style-shadowed {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.tgp-card.tgp-style-elevated {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Equal Height */
.tgp-equal-height .tgp-card {
    height: 100%;
    display: flex !important;
    flex-direction: column !important;
}

.tgp-equal-height .tgp-card-inner {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
}

.tgp-equal-height .tgp-card-content {
    flex: 1;
}

/* ============================================================================
   CARD INNER
   ========================================================================= */

.tgp-card-inner {
    display: block !important;
    width: 100% !important;
    height: 100%;
}

/* Image Positions */
.tgp-card-inner.tgp-image-top {
    display: flex !important;
    flex-direction: column !important;
}

.tgp-card-inner.tgp-image-left {
    display: flex !important;
    flex-direction: row !important;
}

.tgp-card-inner.tgp-image-right {
    display: flex !important;
    flex-direction: row-reverse !important;
}

.tgp-card-inner.tgp-image-left .tgp-card-image,
.tgp-card-inner.tgp-image-right .tgp-card-image {
    flex: 0 0 40%;
    max-width: 40%;
}

.tgp-card-inner.tgp-image-left .tgp-card-content,
.tgp-card-inner.tgp-image-right .tgp-card-content {
    flex: 1;
}

/* ============================================================================
   CARD IMAGE
   ========================================================================= */

.tgp-card-image {
    position: relative;
    overflow: hidden;
    width: 100% !important;
    display: block !important;
}

.tgp-card-image a {
    display: block !important;
    width: 100%;
    height: 100%;
}

.tgp-card-image img {
    width: 100% !important;
    height: 100%;
    object-fit: cover;
    display: block !important;
    transition: transform 0.3s ease;
}

/* Image Ratios */
.tgp-ratio-16-9 {
    padding-bottom: 56.25%;
}

.tgp-ratio-4-3 {
    padding-bottom: 75%;
}

.tgp-ratio-1-1 {
    padding-bottom: 100%;
}

.tgp-ratio-21-9 {
    padding-bottom: 42.857%;
}

.tgp-card-image.tgp-ratio-16-9,
.tgp-card-image.tgp-ratio-4-3,
.tgp-card-image.tgp-ratio-1-1,
.tgp-card-image.tgp-ratio-21-9 {
    position: relative;
    height: 0;
}

.tgp-card-image.tgp-ratio-16-9 a,
.tgp-card-image.tgp-ratio-4-3 a,
.tgp-card-image.tgp-ratio-1-1 a,
.tgp-card-image.tgp-ratio-21-9 a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================================================
   CARD CONTENT
   ========================================================================= */

.tgp-card-content {
    padding: var(--tgp-card-padding, 20px) !important;
    display: block !important;
}

/* ✅ CORREGIR: Reducir margen superior si hay imagen arriba */
.tgp-card-inner.tgp-image-top .tgp-card-content {
    padding-top: 16px !important;
}

/* Category */
.tgp-card-category {
    margin-bottom: 8px; /* ✅ Reducido de 10px */
}

.tgp-category-badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--tgp-category-bg, #f3f4f6);
    color: var(--tgp-category-color, #6b7280);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tgp-category-badge:hover {
    background: var(--tgp-category-hover-bg, #e5e7eb);
}

/* Title */
.tgp-card-title {
    margin: 0 0 8px 0 !important; /* ✅ Reducido de 10px */
    font-size: var(--tgp-title-size, 20px);
    font-weight: 700;
    line-height: 1.3;
    color: var(--tgp-title-color, #1f2937);
}

.tgp-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tgp-card-title a:hover {
    color: var(--tgp-title-hover-color, #3b82f6);
}

/* Meta */
.tgp-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px; /* ✅ Reducido de 12px */
    font-size: 14px;
    color: var(--tgp-meta-color, #6b7280);
}

.tgp-meta-author,
.tgp-meta-date,
.tgp-meta-comments {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tgp-meta-author a {
    color: inherit;
    text-decoration: none;
}

.tgp-meta-author a:hover {
    color: var(--tgp-title-hover-color, #3b82f6);
}

/* Excerpt */
.tgp-card-excerpt {
    margin: 0 0 12px 0; /* ✅ Reducido de 15px */
    font-size: 15px;
    line-height: 1.6;
    color: var(--tgp-excerpt-color, #6b7280);
}

/* Button */
.tgp-card-button {
    margin-top: auto;
}

.tgp-button {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.tgp-button-solid {
    background: var(--tgp-button-bg, #3b82f6);
    color: var(--tgp-button-text, #ffffff);
}

.tgp-button-solid:hover {
    background: var(--tgp-button-hover-bg, #2563eb);
    transform: translateY(-1px);
}

.tgp-button-outline {
    background: transparent;
    color: var(--tgp-button-bg, #3b82f6);
    border: 2px solid var(--tgp-button-bg, #3b82f6);
}

.tgp-button-outline:hover {
    background: var(--tgp-button-bg, #3b82f6);
    color: #ffffff;
}

.tgp-button-ghost {
    background: transparent;
    color: var(--tgp-button-bg, #3b82f6);
}

.tgp-button-ghost:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* ============================================================================
   HOVER ANIMATIONS
   ========================================================================= */

.tgp-card.tgp-hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.tgp-card.tgp-hover-scale:hover {
    transform: scale(1.02);
}

.tgp-card.tgp-hover-shadow:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.tgp-card.tgp-hover-zoom:hover .tgp-card-image img {
    transform: scale(1.1);
}

.tgp-card.tgp-hover-rotate:hover {
    transform: rotate(2deg);
}

/* ============================================================================
   CAROUSEL LAYOUT
   ========================================================================= */

.tgp-layout-carousel,
.tgp-layout-coverflow {
    position: relative;
    width: 100% !important;
    overflow: hidden;
}

.tgp-layout-carousel .swiper,
.tgp-layout-coverflow .swiper {
    width: 100%;
    padding: 10px 0;
}

.tgp-layout-carousel .swiper-slide,
.tgp-layout-coverflow .swiper-slide {
    height: auto;
}

/* Swiper Navigation */
.swiper-button-next,
.swiper-button-prev {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 20px;
    color: #3b82f6;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: #ffffff;
}

/* Swiper Pagination */
.swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: #d1d5db;
    opacity: 1;
}

.swiper-pagination-bullet-active {
    background: #3b82f6;
    width: 24px;
    border-radius: 5px;
}

/* ============================================================================
   FLIP CARDS
   ========================================================================= */

.tgp-layout-flip-cards .tgp-card {
    perspective: 1000px;
    min-height: 400px;
}

.tgp-flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.tgp-card:hover .tgp-flip-card-inner {
    transform: rotateY(180deg);
}

.tgp-flip-card-front,
.tgp-flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
}

.tgp-flip-card-back {
    transform: rotateY(180deg);
    background: var(--tgp-card-bg, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

/* ============================================================================
   ROTATE BOX
   ========================================================================= */

.tgp-layout-rotate-box .tgp-card {
    perspective: 1000px;
    min-height: 350px;
}

.tgp-rotate-box-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.tgp-card:hover .tgp-rotate-box-inner {
    transform: rotateX(180deg);
}

.tgp-rotate-box-front,
.tgp-rotate-box-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
}

.tgp-rotate-box-back {
    transform: rotateX(180deg);
    background: var(--tgp-card-bg, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

/* ============================================================================
   TIMELINE
   ========================================================================= */

.tgp-layout-timeline {
    position: relative;
    padding: 40px 0;
}

.tgp-layout-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
    transform: translateX(-50%);
}

.tgp-timeline-item {
    position: relative;
    margin-bottom: 40px;
}

.tgp-timeline-item:nth-child(odd) {
    padding-right: calc(50% + 30px);
}

.tgp-timeline-item:nth-child(even) {
    padding-left: calc(50% + 30px);
}

.tgp-timeline-dot {
    position: absolute;
    left: 50%;
    top: 0;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border: 3px solid #ffffff;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 0 4px #e5e7eb;
}

@media (max-width: 768px) {
    .tgp-layout-timeline::before {
        left: 20px;
    }
    
    .tgp-timeline-item:nth-child(odd),
    .tgp-timeline-item:nth-child(even) {
        padding-left: 50px;
        padding-right: 0;
    }
    
    .tgp-timeline-dot {
        left: 20px;
    }
}

/* ============================================================================
   ZIGZAG
   ========================================================================= */

.tgp-layout-zigzag .tgp-card {
    display: flex !important;
    gap: 30px;
    margin-bottom: 40px;
}

.tgp-layout-zigzag .tgp-card:nth-child(even) {
    flex-direction: row-reverse;
}

.tgp-layout-zigzag .tgp-card-image {
    flex: 0 0 50%;
}

.tgp-layout-zigzag .tgp-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .tgp-layout-zigzag .tgp-card,
    .tgp-layout-zigzag .tgp-card:nth-child(even) {
        flex-direction: column !important;
    }
    
    .tgp-layout-zigzag .tgp-card-image {
        flex: 0 0 auto;
    }
}

/* ============================================================================
   PAGINATION
   ========================================================================= */

.tgp-pagination {
    margin-top: 40px;
    text-align: center;
}

.tgp-pagination ul {
    display: inline-flex;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tgp-pagination li {
    margin: 0;
}

.tgp-pagination a,
.tgp-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tgp-pagination a:hover {
    color: #3b82f6;
    border-color: #3b82f6;
}

.tgp-pagination .current {
    color: #ffffff;
    background: #3b82f6;
    border-color: #3b82f6;
}

/* Load More */
.tgp-load-more-wrapper {
    text-align: center;
    margin-top: 40px;
}

.tgp-load-more {
    padding: 12px 32px;
    font-size: 16px;
}

/* Loader */
.tgp-loader {
    margin: 20px auto;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: tgp-spin 1s linear infinite;
}

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

/* ============================================================================
   NO POSTS MESSAGE
   ========================================================================= */

.tgp-no-posts {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

/* ============================================================================
   ANIMATIONS
   ========================================================================= */

.tgp-fade-in {
    animation: tgp-fadeIn 0.6s ease-out;
}

@keyframes tgp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tgp-slide-up {
    animation: tgp-slideUp 0.6s ease-out;
}

@keyframes tgp-slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tgp-zoom-in {
    animation: tgp-zoomIn 0.6s ease-out;
}

@keyframes tgp-zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   UTILITY CLASSES
   ========================================================================= */

.tgp-hidden {
    display: none !important;
}

.tgp-text-center {
    text-align: center;
}

.tgp-text-left {
    text-align: left;
}

.tgp-text-right {
    text-align: right;
}

/* ============================================================================
   ICONS (Simple CSS icons)
   ========================================================================= */

.tgp-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
}

.tgp-icon-calendar::before {
    content: "📅";
}

.tgp-icon-user::before {
    content: "👤";
}

.tgp-icon-comment::before {
    content: "💬";
}