/**
 * News Display Widgets - Estilos principales
 * 
 * CSS optimizado para los widgets de noticias
 * Totalmente responsive
 *
 * @package News_Display_Widgets
 * @since 1.0.0
 */

/* ==========================================================================
   Variables CSS
   ========================================================================== */
:root {
    --ndw-primary-color: #2563eb;
    --ndw-primary-hover: #1d4ed8;
    --ndw-text-color: #1f2937;
    --ndw-text-light: #6b7280;
    --ndw-border-color: #e5e7eb;
    --ndw-background: #ffffff;
    --ndw-background-light: #f9fafb;
    --ndw-spacing-xs: 0.5rem;
    --ndw-spacing-sm: 1rem;
    --ndw-spacing-md: 1.5rem;
    --ndw-spacing-lg: 2rem;
    --ndw-border-radius: 8px;
    --ndw-transition: 0.3s ease;
}

/* ==========================================================================
   Estilos base
   ========================================================================== */
.ndw-widget-container {
    font-family: inherit;
    line-height: 1.6;
    color: var(--ndw-text-color);
}

.ndw-widget-container * {
    box-sizing: border-box;
}

.ndw-widget-container a {
    text-decoration: none;
    transition: color var(--ndw-transition);
}

.ndw-no-posts {
    text-align: center;
    padding: var(--ndw-spacing-lg);
    color: var(--ndw-text-light);
    font-style: italic;
}

/* ==========================================================================
   Placeholder de imagen
   ========================================================================== */
.ndw-placeholder-image,
.ndw-placeholder-image-small {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ndw-background-light);
    color: var(--ndw-text-light);
    width: 100%;
    height: 100%;
    min-height: 150px;
}

.ndw-placeholder-image-small {
    min-height: 80px;
}

.ndw-placeholder-image span,
.ndw-placeholder-image-small span {
    font-size: 14px;
}

/* ==========================================================================
   Widget 1: Noticia Destacada (Featured News)
   ========================================================================== */
.ndw-featured-news {
    display: flex;
    flex-direction: column;
}

.ndw-featured-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--ndw-border-radius);
}

.ndw-featured-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--ndw-transition);
}

.ndw-featured-image-container a:hover img {
    transform: scale(1.05);
}

.ndw-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

.ndw-featured-content {
    padding: var(--ndw-spacing-md) 0;
}

.ndw-featured-title {
    margin: 0 0 var(--ndw-spacing-sm);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.ndw-featured-title a {
    color: inherit;
}

.ndw-featured-title a:hover {
    color: var(--ndw-primary-color);
}

.ndw-featured-button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--ndw-primary-color);
    color: #ffffff;
    border-radius: var(--ndw-border-radius);
    font-weight: 600;
    transition: background-color var(--ndw-transition), transform var(--ndw-transition);
}

.ndw-featured-button:hover {
    background: var(--ndw-primary-hover);
    color: #ffffff;
    transform: translateY(-2px);
}

/* ==========================================================================
   Widget 2: Listado de Noticias (News List)
   ========================================================================== */
.ndw-news-list {
    display: flex;
    flex-direction: column;
}

.ndw-news-item {
    display: flex;
    gap: var(--ndw-spacing-md);
    align-items: flex-start;
}

.ndw-news-image {
    flex-shrink: 0;
    overflow: hidden;
    border-radius: var(--ndw-border-radius);
}

.ndw-news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--ndw-transition);
}

.ndw-news-image a:hover img {
    transform: scale(1.05);
}

.ndw-news-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.ndw-news-title {
    margin: 0 0 var(--ndw-spacing-xs);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.ndw-news-title a {
    color: inherit;
}

.ndw-news-title a:hover {
    color: var(--ndw-primary-color);
}

.ndw-news-excerpt-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--ndw-spacing-xs);
}

.ndw-news-excerpt {
    margin: 0;
    color: var(--ndw-text-light);
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
}

.ndw-news-readmore {
    color: var(--ndw-primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.ndw-news-readmore:hover {
    color: var(--ndw-primary-hover);
    text-decoration: underline;
}

/* News List - Responsive (móvil) */
@media (max-width: 767px) {
    .ndw-news-item {
        flex-direction: column;
    }

    .ndw-news-image {
        width: 100% !important;
        height: 200px !important;
    }

    .ndw-news-content {
        width: 100%;
    }
}

/* ==========================================================================
   Widget 3: Feed de Noticias con Infinite Scroll
   ========================================================================== */
.ndw-news-feed {
    display: flex;
    flex-direction: column;
}

/* Barra de filtros */
.ndw-feed-filters {
    margin-bottom: var(--ndw-spacing-lg);
    padding: var(--ndw-spacing-md);
    background: var(--ndw-background-light);
    border-radius: var(--ndw-border-radius);
}

.ndw-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ndw-spacing-sm);
    align-items: center;
}

.ndw-filter-group {
    display: flex;
    gap: var(--ndw-spacing-xs);
    align-items: center;
}

.ndw-search-group {
    flex: 1;
    min-width: 200px;
}

.ndw-search-wrapper {
    position: relative;
    width: 100%;
}

.ndw-filter-input,
.ndw-filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--ndw-border-color);
    border-radius: var(--ndw-border-radius);
    font-size: 0.9rem;
    background: var(--ndw-background);
    transition: border-color var(--ndw-transition), box-shadow var(--ndw-transition);
    width: 100%;
}

.ndw-filter-input:focus,
.ndw-filter-select:focus {
    outline: none;
    border-color: var(--ndw-primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ndw-date-group .ndw-filter-input {
    width: 150px;
}

.ndw-category-select {
    min-width: 180px;
}

.ndw-filter-button {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--ndw-border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--ndw-transition), transform var(--ndw-transition);
}

.ndw-filter-apply {
    background: var(--ndw-primary-color);
    color: #ffffff;
}

.ndw-filter-apply:hover {
    background: var(--ndw-primary-hover);
}

.ndw-filter-reset {
    background: var(--ndw-border-color);
    color: var(--ndw-text-color);
}

.ndw-filter-reset:hover {
    background: #d1d5db;
}

/* Sugerencias de búsqueda */
.ndw-search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ndw-background);
    border: 1px solid var(--ndw-border-color);
    border-top: none;
    border-radius: 0 0 var(--ndw-border-radius) var(--ndw-border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.ndw-suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color var(--ndw-transition);
    border-bottom: 1px solid var(--ndw-border-color);
}

.ndw-suggestion-item:last-child {
    border-bottom: none;
}

.ndw-suggestion-item:hover,
.ndw-suggestion-item.active {
    background: var(--ndw-background-light);
}

.ndw-suggestion-loading,
.ndw-suggestion-empty {
    padding: 0.75rem 1rem;
    color: var(--ndw-text-light);
    font-style: italic;
    text-align: center;
}

/* Grid del feed */
.ndw-feed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--ndw-spacing-md);
}

/* Feed items */
.ndw-feed-item {
    display: flex;
    flex-direction: column;
    background: var(--ndw-background);
    border-radius: var(--ndw-border-radius);
    overflow: hidden;
    transition: box-shadow var(--ndw-transition), transform var(--ndw-transition);
}

.ndw-feed-item:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.ndw-feed-image {
    width: 100%;
    overflow: hidden;
}

.ndw-feed-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--ndw-transition);
}

.ndw-feed-image a:hover img {
    transform: scale(1.05);
}

.ndw-feed-item-content {
    padding: var(--ndw-spacing-md);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ndw-feed-title {
    margin: 0 0 var(--ndw-spacing-xs);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.ndw-feed-title a {
    color: inherit;
}

.ndw-feed-title a:hover {
    color: var(--ndw-primary-color);
}

.ndw-feed-excerpt {
    margin: 0 0 var(--ndw-spacing-sm);
    color: var(--ndw-text-light);
    font-size: 0.9rem;
    flex: 1;
}

.ndw-feed-button {
    display: inline-block;
    align-self: flex-start;
    padding: 0.5rem 1rem;
    background: var(--ndw-primary-color);
    color: #ffffff;
    border-radius: var(--ndw-border-radius);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color var(--ndw-transition);
}

.ndw-feed-button:hover {
    background: var(--ndw-primary-hover);
    color: #ffffff;
}

/* Loader */
.ndw-feed-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--ndw-spacing-sm);
    padding: var(--ndw-spacing-lg);
    color: var(--ndw-text-light);
}

.ndw-loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--ndw-border-color);
    border-top-color: var(--ndw-primary-color);
    border-radius: 50%;
    animation: ndw-spin 0.8s linear infinite;
}

@keyframes ndw-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mensaje de fin */
.ndw-feed-end {
    text-align: center;
    padding: var(--ndw-spacing-lg);
    color: var(--ndw-text-light);
    font-style: italic;
}

/* Feed - Responsive */
@media (max-width: 1024px) {
    .ndw-feed-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .ndw-feed-grid {
        grid-template-columns: 1fr;
    }

    .ndw-filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ndw-filter-group {
        width: 100%;
    }

    .ndw-search-group {
        min-width: 100%;
    }

    .ndw-date-group {
        flex-direction: column;
    }

    .ndw-date-group .ndw-filter-input {
        width: 100%;
    }

    .ndw-category-select {
        width: 100%;
    }

    .ndw-actions-group {
        justify-content: center;
    }
}

/* ==========================================================================
   Animaciones de entrada
   ========================================================================== */
.ndw-feed-item.ndw-fade-in {
    animation: ndw-fadeIn 0.5s ease forwards;
}

@keyframes ndw-fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Modo oscuro (si el tema lo soporta)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .ndw-widget-container {
        --ndw-text-color: #f3f4f6;
        --ndw-text-light: #9ca3af;
        --ndw-border-color: #374151;
        --ndw-background: #1f2937;
        --ndw-background-light: #111827;
    }
}

/* ==========================================================================
   Accesibilidad
   ========================================================================== */
.ndw-widget-container a:focus,
.ndw-widget-container button:focus,
.ndw-widget-container input:focus,
.ndw-widget-container select:focus {
    outline: 2px solid var(--ndw-primary-color);
    outline-offset: 2px;
}

/* Reducir movimiento para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
    .ndw-widget-container *,
    .ndw-widget-container *::before,
    .ndw-widget-container *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Utilidades
   ========================================================================== */
.ndw-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
