/**
 * Estilo Forum para wpForo Topics
 * Diseño similar a wpForo nativo
 * VERSIÓN RESPONSIVE: Desktop y Mobile con estructuras diferentes
 */

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.asf-results-grid.forum-style {
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: grid;
    gap: 24px;
    margin-bottom: 40px;
}

/* ============================================
   ESTILOS BASE COMPARTIDOS
   ============================================ */
.asf-forum-topic-card {
    transition: background-color 0.2s ease;
    position: relative;
}

.asf-forum-topic-card a {
    text-decoration: none !important;
}

.asf-forum-topic-card:hover {
    background-color: #f8f9fa;
}

.asf-forum-topic-card:last-child {
    border-bottom: none;
}

/* ============================================
   LAYOUT DESKTOP (Mayor a 768px)
   ============================================ */
@media (min-width: 769px) {
    article.asf-forum-topic-card.asf-mobile-layout {display: none;}
    /* Tarjeta de topic individual - DESKTOP */
    .asf-forum-topic-card.asf-desktop-layout,
    .asf-forum-topic-card:not(.asf-mobile-layout) {
        display: grid;
        grid-template-columns: 60px 1fr auto auto auto;
        gap: 15px;
        padding: 20px;
        align-items: center;
        box-shadow: 0 0px 5px -4px #0D0A2C;
        border-radius: 15px;
    }

    /* Icono del topic */
    .asf-topic-icon {
        width: 50px;
        height: 50px;
        background: rgba(118, 184, 42, 0.2);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        padding: 15px;
    }

    .asf-topic-icon svg {
        width: 28px;
        height: 28px;
        fill: #fff;
    }

    /* Contenido del topic */
    .asf-topic-content {
        min-width: 0;
    }

    .asf-topic-title {
        margin: 0 0 8px 0;
        font-size: 16px !important;
        font-weight: 600;
        line-height: 1.4;
    }

    .asf-topic-title a {
        color: #333 !important;
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .asf-topic-title a:hover {
        color: #7cb342;
    }

    .asf-topic-meta {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 13px;
        color: #666;
    }

    .asf-topic-author,
    .asf-topic-date {
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .asf-topic-author svg,
    .asf-topic-date svg {
        width: 14px;
        height: 14px;
        opacity: 0.7;
    }

    .asf-topic-category {
        background: #e3f2fd;
        color: #1976d2;
        padding: 3px 10px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 500;
    }

    /* Excerpt del topic */
    .asf-topic-excerpt {
        color: #666;
        font-size: 14px;
        line-height: 1.5;
        margin: 5px 0 0 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Estadísticas */
    .asf-topic-stats {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        min-width: 60px;
    }

    .asf-stat-number {
        font-size: 18px;
        font-weight: 600;
        color: #333;
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .asf-stat-label {
        font-size: 11px;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Vistas/Likes */
    .asf-topic-views,
    .asf-topic-likes {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        min-width: 60px;
    }

    .asf-views-icon {
        width: 20px;
        height: 20px;
        opacity: 0.5;
    }

    /* Último autor */
    .asf-topic-last-user {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 150px;
    }

    .asf-user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        overflow: hidden;
        flex-shrink: 0;
        background: #7cb342;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        color: #fff;
        font-size: 14px;
    }

    .asf-user-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .asf-user-info {
        flex: 1;
        min-width: 0;
    }

    .asf-user-name {
        font-size: 13px;
        font-weight: 500;
        color: #333;
        margin: 0 0 3px 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    .asf-user-date {
        font-size: 12px;
        color: #666;
    }

    /* Botón de comentar */
    .asf-topic-action {
        min-width: 100px;
    }

    .asf-comment-button {
        background: transparent;
        border: 1.5px solid #7cb342;
        color: #7cb342 !important;
        padding: 8px 16px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 6px;
        transition: all 0.2s ease;
        text-decoration: none;
    }

    .asf-comment-button:hover {
        background: #7cb342;
        color: #fff !important;
    }

    .asf-comment-button svg {
        width: 16px;
        height: 16px;
    }

    /* Badge de "nuevo" o "popular" */
    .asf-topic-badge {
        display: none;
        position: absolute;
        top: 10px;
        right: 10px;
        background: #ff5722;
        color: #fff;
        padding: 3px 8px;
        border-radius: 4px;
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
    }

    .asf-topic-badge.hot {
        background: #ff9800;
    }

    .asf-topic-badge.new {
        background: #4caf50;
    }

    /* Ocultar elementos mobile en desktop */
    .asf-mobile-header,
    .asf-mobile-author,
    .asf-mobile-date,
    .asf-mobile-stats,
    .asf-mobile-action {
        display: none !important;
    }
}

/* ============================================
   LAYOUT MOBILE (Hasta 768px)
   ============================================ */
@media (max-width: 768px) {
    article.asf-forum-topic-card.asf-desktop-layout {display: none;}
    .asf-search-filter-wrapper {
        margin: 0;
    }
    .asf-search-main-row {
        gap: 0;
    }
    .asf-search-icon {
        left: 10px;
    }
    .asf-search-bar {
        border: 1px solid #CED4DA !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
     .asf-search-bar button.asf-filters-button {
        padding: 7px !important;
        display: flex;
        justify-items: center;
        align-items: center;
        background: #F3F4F6 !important;
        border: 0;
    }
    .asf-search-bar button.asf-filters-button span {
        display: none;
        padding: 0 !important;
    }
    .asf-search-bar .asf-search-input-wrapper {
        border: 0;
    }
    .asf-search-input-wrapper button.asf-search-button {
        border: 0;
        background: #F3F4F6;
        margin: 0;
        color: #637381;
        padding: 11px 15px;
    }

    /* Tarjeta de topic - MOBILE */
    .asf-forum-topic-card.asf-mobile-layout,
    .asf-forum-topic-card {
        display: flex;
        flex-direction: column;
        padding: 16px;
        gap: 12px;
        box-shadow: 0 0px 5px -4px #0D0A2C;
        border-radius: 15px;
    }

    /* Header con icono y título */
    .asf-mobile-header {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    .asf-mobile-icon {
        width: 40px;
        height: 40px;
        background: rgba(118, 184, 42, 0.2);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .asf-mobile-icon svg {
        width: 20px;
        height: 20px;
    }

    .asf-mobile-title {
        flex: 1;
        margin: 0;
        font-size: 16px !important;
        font-weight: 600;
        line-height: 1.4 !important;
    }

    .asf-mobile-title a {
        color: #333;
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .asf-mobile-title a:hover {
        color: #7cb342;
    }

    /* Autor */
    .asf-mobile-author {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-left: 50px;
    }

    .asf-mobile-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #7cb342;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 12px;
        flex-shrink: 0;
        overflow: hidden;
    }

    .asf-mobile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .asf-mobile-author-info {
        flex: 1;
    }

    .asf-mobile-author-name {
        font-size: 14px;
        font-weight: 500;
        color: #333;
    }

    /* Fecha */
    .asf-mobile-date {
        font-size: 13px;
        color: #666;
        margin-left: 50px;
        margin-top: -4px;
    }

    /* Estadísticas en línea */
    .asf-mobile-stats {
        display: flex;
        align-items: center;
        gap: 16px;
        padding-top: 8px;
        margin-left: 50px;
    }

    .asf-mobile-stat-item {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 14px;
        font-weight: 500;
        color: #333;
    }

    .asf-mobile-stat-item svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    /* Botón comentar (full width) */
    .asf-mobile-action {
        padding-top: 8px;
    }

    .asf-mobile-comment-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px;
        background: transparent;
        color: #7cb342;
        border: 1.5px solid #7cb342;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .asf-mobile-comment-button:hover,
    .asf-mobile-comment-button:active {
        background: #7cb342;
        color: white;
    }

    .asf-mobile-comment-button svg {
        width: 20px;
        height: 20px;
    }

    /* Ocultar elementos desktop en mobile */
    .asf-topic-icon,
    .asf-topic-content,
    .asf-topic-stats,
    .asf-topic-views,
    .asf-topic-likes,
    .asf-topic-last-user,
    .asf-topic-action {
        display: none !important;
    }
}

/* ============================================
   TABLETS (1024px o menos)
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
    .asf-forum-topic-card {
        grid-template-columns: 50px 1fr auto;
        gap: 12px;
    }
    
    .asf-topic-stats,
    .asf-topic-views,
    .asf-topic-likes {
        display: none;
    }
    
    .asf-topic-last-user {
        min-width: auto;
    }
}

/* ============================================
   MÓVILES PEQUEÑOS (640px o menos)
   ============================================ */
@media (max-width: 640px) {
    .asf-mobile-title {
        font-size: 15px !important;
    }
    
    .asf-mobile-comment-button {
        font-size: 13px;
        padding: 10px;
    }
    
    .asf-mobile-stats {
        gap: 12px;
    }
}

/* ============================================
   MÓVILES MUY PEQUEÑOS (380px o menos)
   ============================================ */
@media (max-width: 380px) {
    .asf-forum-topic-card.asf-mobile-layout,
    .asf-forum-topic-card {
        padding: 12px;
    }
    
    .asf-mobile-title {
        font-size: 14px !important;
    }
    
    .asf-mobile-icon {
        width: 36px;
        height: 36px;
    }
    
    .asf-mobile-icon svg {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   HEADER DE LA LISTA (opcional)
   ============================================ */
.asf-forum-header {
    display: grid;
    grid-template-columns: 60px 1fr auto auto auto;
    gap: 15px;
    padding: 15px 20px;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.asf-forum-header > div {
    text-align: center;
}

.asf-forum-header > div:nth-child(2) {
    text-align: left;
}

@media (max-width: 768px) {
    .asf-forum-header {
        display: none;
    }
}

/* ============================================
   MENSAJE SIN RESULTADOS
   ============================================ */
.asf-no-results-forum {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.asf-no-results-forum svg {
    width: 80px;
    height: 80px;
    opacity: 0.3;
    margin-bottom: 20px;
}

.asf-no-results-forum h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: #333;
}

.asf-no-results-forum p {
    margin: 0;
    font-size: 14px;
}

@media (max-width: 640px) {
    .asf-no-results-forum {
        padding: 40px 20px;
    }
    
    .asf-no-results-forum svg {
        width: 60px;
        height: 60px;
    }
    
    .asf-no-results-forum h3 {
        font-size: 18px;
    }
    
    .asf-no-results-forum p {
        font-size: 13px;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.asf-forum-topic-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.asf-forum-topic-card.loading .asf-topic-title,
.asf-forum-topic-card.loading .asf-topic-meta,
.asf-forum-topic-card.loading .asf-stat-number,
.asf-forum-topic-card.loading .asf-mobile-title {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   UTILIDADES ADICIONALES
   ============================================ */

/* Asegurar que los enlaces no rompan el layout */
.asf-forum-topic-card a {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mejorar el touch en dispositivos móviles */
@media (max-width: 768px) {
    .asf-forum-topic-card {
        -webkit-tap-highlight-color: rgba(124, 179, 66, 0.1);
    }
    
    .asf-mobile-comment-button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Accesibilidad - Focus states */
.asf-comment-button:focus,
.asf-mobile-comment-button:focus {
    outline: 2px solid #7cb342;
    outline-offset: 2px;
}

.asf-topic-title a:focus {
    outline: 2px solid #7cb342;
    outline-offset: 2px;
    border-radius: 2px;
}