/**
 * Blog Page CSS - Página de Blog
 * Grid de posts elegante con 4 columnas, búsqueda y filtros
 */

/* ==========================================================================
   FONDO GLOBAL PARA PÁGINA DE BLOG
   ========================================================================== */

body.blog-page,
body.blog-page .site,
body.blog-page #page,
body.blog-page .site-content,
body.blog-page #content,
body:has(.blog-page-wrapper),
body:has(.blog-page-wrapper) .site,
body:has(.blog-page-wrapper) #page,
body:has(.blog-page-wrapper) .site-content,
body:has(.blog-page-wrapper) #content {
    background: var(--color-background) !important;
}

/* Sobrescribir contenedores de GeneratePress para permitir ancho completo */
body.blog-page .site-content,
body.blog-page #primary,
body.blog-page .inside-article,
body.blog-page article,
body.blog-page .entry-content,
body.home .site-content,
body.home #primary,
body.home .inside-article,
body.home article,
body.home .entry-content {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Asegurar que no haya padding en el artículo principal */
body.blog-page .generate-columns-container,
body.home .generate-columns-container {
    max-width: none !important;
}

/* Forzar ancho completo en primary */
body.blog-page #primary,
body.home #primary {
    width: 100% !important;
}

/* Ocultar sidebar si existe */
body.blog-page #secondary,
body.home #secondary,
body.blog-page .sidebar,
body.home .sidebar {
    display: none !important;
}

/* Asegurar que content area ocupe 100% */
body.blog-page .site-main,
body.home .site-main {
    width: 100% !important;
    max-width: none !important;
}

/* Forzar ancho completo en grid-container de GeneratePress */
body.blog-page .grid-container,
body.home .grid-container {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
}

/* ==========================================================================
   WRAPPER PRINCIPAL
   ========================================================================== */

.blog-page-wrapper {
    background: var(--color-background);
    min-height: 100vh;
    width: 100%;
}

.blog-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 40px;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */

.blog-hero {
    background: var(--color-background);
    padding: 100px 0 60px 0;
    text-align: center;
}

.blog-title {
    color: var(--color-primary) !important;
    font-size: 48px;
    font-weight: 800;
    margin: 0 0 12px 0;
    line-height: 1.2;
    text-transform: uppercase !important;
    font-family: var(--font-headings) !important;
}

.blog-subtitle {
    color: var(--color-text-light);
    font-size: 20px;
    line-height: 1.6;
    margin: 0 0 20px 0;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Separador Elegante */
.blog-separator {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(200, 200, 200, 0.3) 20%,
        rgba(150, 150, 150, 0.4) 50%,
        rgba(200, 200, 200, 0.3) 80%,
        transparent 100%
    );
    max-width: 600px;
    margin: 40px auto 0;
}

/* ==========================================================================
   LAYOUT CON SIDEBAR
   ========================================================================== */

.blog-posts-section {
    padding: 40px 0 80px 0;
}

/* ==========================================================================
   LAYOUT CON SIDEBAR
   ========================================================================== */

.blog-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 50px;
    align-items: start;
}

.blog-main-content {
    min-width: 0; /* Previene overflow */
}

.blog-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 50px;
    width: 100%;
    max-width: 100%;
}

/* ==========================================================================
   TARJETA DE POST
   ========================================================================== */

.blog-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.blog-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* Imagen */
.blog-card-image {
    position: relative;
    overflow: hidden;
    padding-top: 70%; /* Aspect ratio más vertical */
    background: var(--color-background);
}

.blog-card-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.blog-card:hover .blog-card-image img {
    transform: scale(1.05);
}

/* Imagen por defecto cuando no hay thumbnail */
.blog-card-image img.default-placeholder {
    opacity: 0.85;
}

.blog-card:hover .blog-card-image img.default-placeholder {
    opacity: 1;
}

/* Placeholder cuando no hay imagen */
.blog-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, 
        rgba(30, 168, 148, 0.1) 0%, 
        rgba(56, 189, 248, 0.1) 100%);
    color: var(--color-primary);
    position: absolute;
    top: 0;
    left: 0;
}

.blog-card-placeholder svg {
    opacity: 0.3;
    transition: all 0.4s ease;
}

.blog-card:hover .blog-card-placeholder svg {
    opacity: 0.5;
    transform: scale(1.1);
}

/* Contenido */
.blog-card-content {
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Meta información */
.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 13px;
    color: var(--color-text-light);
}

.blog-card-date,
.blog-card-reading-time {
    display: flex;
    align-items: center;
    gap: 5px;
}

.blog-card-date svg,
.blog-card-reading-time svg {
    opacity: 0.7;
}

/* Título */
.blog-card-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 12px 0;
    color: var(--color-text);
}

.blog-card-title a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.blog-card:hover .blog-card-title a {
    color: var(--color-primary);
}

/* Excerpt */
.blog-card-excerpt {
    color: var(--color-text-light);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: auto;
    padding-bottom: 20px;
}

/* Footer */
.blog-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.blog-card-author {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--color-text);
}

.blog-card-author img {
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.blog-card-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.blog-card-link:hover {
    gap: 8px;
}

.blog-card-link svg {
    transition: transform 0.3s ease;
}

.blog-card-link:hover svg {
    transform: translateX(3px);
}

/* ==========================================================================
   BOTÓN CARGAR MÁS
   ========================================================================== */

.blog-loading-more {
    text-align: center;
    margin-top: 40px;
}

.load-more-button {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(30, 168, 148, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.load-more-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 168, 148, 0.4);
}

.load-more-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Spinner de carga */
.loading-spinner {
    display: inline-block;
}

.spinner {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner .path {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ==========================================================================
   NO POSTS FOUND
   ========================================================================== */

.no-posts-found {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 40px;
}

.no-posts-found svg {
    color: var(--color-text-light);
    opacity: 0.3;
    margin-bottom: 20px;
}

.no-posts-found h3 {
    color: var(--color-text);
    font-size: 24px;
    margin: 0 0 10px 0;
}

.no-posts-found p {
    color: var(--color-text-light);
    font-size: 16px;
    margin: 0;
}

/* ==========================================================================
   SIDEBAR Y WIDGETS
   ========================================================================== */

.blog-sidebar {
    position: sticky;
    top: 100px;
    background: white;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Widget Base */
.blog-widget {
    padding: 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.blog-widget:last-child {
    border-bottom: none;
}

.widget-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-primary);
    display: inline-block;
}

/* Widget Buscador */
.blog-widget-search .search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--color-background);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.blog-widget-search .search-input-wrapper:focus-within {
    border-color: var(--color-primary);
    background: white;
}

.blog-widget-search .search-field {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 15px;
    font-size: 14px;
    color: var(--color-text);
    background: transparent;
}

.blog-widget-search .search-submit {
    background: transparent;
    border: none;
    padding: 12px;
    cursor: pointer;
    color: var(--color-text-light);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.blog-widget-search .search-submit:hover {
    color: var(--color-primary);
    background: transparent;
    transform: none;
    box-shadow: none;
}

/* Widget Categorías */
.widget-categories-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-categories-list li {
    margin-bottom: 8px;
}

.category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 15px;
    background: var(--color-background);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.category-link:hover {
    background: rgba(30, 168, 148, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.category-link.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    border-color: var(--color-primary);
}

.cat-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.category-link:not(.active) .cat-count {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-text-light);
}

/* Widget Tags */
.widget-tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-link {
    display: inline-block;
    padding: 6px 14px;
    background: var(--color-background);
    color: var(--color-text);
    font-size: 13px;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.tag-link:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.no-tags {
    color: var(--color-text-light);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* Widget Posts Recomendados */
.widget-recommended-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recommended-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.recommended-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.recommended-item:first-child {
    padding-top: 0;
}

.recommended-thumb {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
}

.recommended-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.recommended-thumb:hover img {
    transform: scale(1.1);
}

.recommended-content {
    flex: 1;
    min-width: 0;
}

.recommended-title {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

.recommended-title a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recommended-title a:hover {
    color: var(--color-primary);
}

.recommended-rating {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rating-count {
    font-size: 12px;
    color: var(--color-text-light);
}

.no-recommended {
    color: var(--color-text-light);
    font-size: 14px;
    font-style: italic;
}

/* ==========================================================================
   SISTEMA DE RATING CON ESTRELLAS
   ========================================================================== */

/* Rating en Tarjetas */
.blog-card-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 15px 0;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.post-rating-stars {
    display: flex;
    align-items: center;
    gap: 3px;
}

.star {
    color: #fbbf24;
}

.star-full {
    fill: #fbbf24;
}

.star-half {
    fill: url(#half);
    stroke: #fbbf24;
}

.star-empty {
    fill: none;
    stroke: #d1d5db;
}

.rating-text {
    font-size: 14px;
    color: var(--color-text-light);
    font-weight: 500;
}

.rating-text.no-ratings {
    font-style: italic;
    color: var(--color-text-light);
}

/* Formulario Interactivo de Rating */
.rating-interactive {
    display: flex;
    gap: 4px;
}

.star-btn {
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
}

.star-btn svg {
    fill: #d1d5db;
    stroke: #d1d5db;
    transition: all 0.2s ease;
}

.star-btn:hover svg,
.star-btn.hovered svg {
    fill: #fbbf24;
    stroke: #fbbf24;
    transform: scale(1.2);
}

.star-btn:hover {
    transform: scale(1.1);
}

/* ==========================================================================   RESPONSIVE - DESKTOP GRANDE A MEDIO
   ========================================================================== */

@media (max-width: 1400px) {
    .blog-posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================   RESPONSIVE - TABLET
   ========================================================================== */

@media (max-width: 1400px) {
    .blog-posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .blog-container {
        padding: 0 30px;
    }

    .blog-layout {
        grid-template-columns: 1fr 300px;
        gap: 30px;
    }

    .blog-posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .blog-title {
        font-size: 38px;
    }
    
    .blog-sidebar {
        top: 80px;
    }
}

/* ==========================================================================
   RESPONSIVE - TABLET PEQUEÑO
   ========================================================================== */

@media (max-width: 768px) {
    .blog-container {
        padding: 0 20px;
    }

    .blog-hero {
        padding: 60px 0 40px 0;
    }

    .blog-title {
        font-size: 32px;
    }

    .blog-subtitle {
        font-size: 16px;
    }
    
    .blog-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    .blog-sidebar {
        position: static;
        order: 2;
    }

    .blog-posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .search-field {
        font-size: 15px;
        padding: 16px 15px;
    }

    .search-submit {
        padding: 16px 25px;
        font-size: 15px;
    }
}

/* ==========================================================================
   RESPONSIVE - MÓVIL
   ========================================================================== */

@media (max-width: 480px) {
    .blog-hero {
        padding: 60px 0 40px 0;
    }

    .blog-title {
        font-size: 26px;
        margin-bottom: 12px;
    }

    .blog-subtitle {
        font-size: 15px;
        margin-bottom: 24px;
    }

    .blog-posts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .search-icon {
        margin-left: 15px;
    }

    .search-field {
        padding: 14px 12px;
    }

    .search-submit {
        padding: 14px 20px;
        font-size: 14px;
    }

    .blog-card-content {
        padding: 20px;
    }

    .blog-card-title {
        font-size: 18px;
    }

    .blog-card-excerpt {
        font-size: 14px;
    }

    .load-more-button {
        padding: 14px 30px;
        font-size: 15px;
    }
}

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */

.blog-page-wrapper a:focus-visible,
.blog-page-wrapper button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Animación de entrada para tarjetas */
.blog-card {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Delay progresivo para tarjetas */
.blog-card:nth-child(1) { animation-delay: 0.05s; }
.blog-card:nth-child(2) { animation-delay: 0.1s; }
.blog-card:nth-child(3) { animation-delay: 0.15s; }
.blog-card:nth-child(4) { animation-delay: 0.2s; }
.blog-card:nth-child(5) { animation-delay: 0.25s; }
.blog-card:nth-child(6) { animation-delay: 0.3s; }
.blog-card:nth-child(7) { animation-delay: 0.35s; }
.blog-card:nth-child(8) { animation-delay: 0.4s; }

/* Animaciones para notificaciones */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

