/**
 * Unified Card Styles - Clean & Optimized
 * 
 * Sistema de cards unificado para todo o tema.
 * Remove redundâncias e consolida estilos de todos os tipos de cards.
 * 
 * @package Informativo_Angolano
 * @since 2.0.0
 */

/* ==========================================================================
   BASE CARD STYLES
   ========================================================================== */

/* Card base - todos os cards herdam estes estilos */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ==========================================================================
   NEWS CARD - Principal card de notícias
   ========================================================================== */

.card--news,
.news-card,
.news-post-card,
.related-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Thumbnail */
.card--news .card__thumbnail,
.news-card .news-thumbnail,
.news-post-card .news-post-thumbnail,
.related-card .news-thumbnail {
    position: relative;
    overflow: hidden;
    padding-top: 66.67%;
    background: var(--bg-light);
}

.card--news .card__thumbnail img,
.news-card .news-thumbnail img,
.news-post-card .news-post-thumbnail img,
.related-card .news-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content */
.card--news .card__content,
.news-card .news-content,
.news-post-card .news-post-content,
.related-card .news-content {
    padding: var(--space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Category */
.card--news .card__category,
.news-card .news-category,
.news-post-card .news-category-tag,
.related-card .news-category {
    display: inline-block;
    background: var(--primary-color);
    color: var(--bg-white);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    align-self: flex-start;
}

/* Title */
.card--news .card__title,
.news-card .news-title,
.news-post-card .news-post-title,
.related-card .news-title {
    font-size: var(--text-lg);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--space-2);
    color: var(--secondary-color);
}

.card--news .card__title a,
.news-card .news-title a,
.news-post-card .news-post-title a,
.related-card .news-title a {
    color: inherit;
}

/* Excerpt */
.card--news .card__excerpt,
.news-card .news-excerpt,
.news-post-card .news-post-excerpt,
.related-card .related-excerpt {
    font-size: var(--text-sm);
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: var(--space-3);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta */
.card--news .card__meta,
.news-card .news-meta,
.news-post-card .news-post-meta,
.related-card .related-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.card--news .card__author,
.news-card .news-author,
.related-card .related-author {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: 500;
}

/* ==========================================================================
   FEATURED CARD - Card de destaque/hero
   ========================================================================== */

.card--featured,
.featured-main-post {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-size: cover;
    background-position: center;
    min-height: 350px;
}

@media (min-width: 768px) {
    .card--featured,
    .featured-main-post {
        min-height: 450px;
    }
}

@media (min-width: 1200px) {
    .card--featured,
    .featured-main-post {
        min-height: 500px;
    }
}

.card--featured::before,
.featured-main-post::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.4) 50%,
        rgba(0,0,0,0.1) 100%
    );
    z-index: 1;
}

.card--featured .card__link,
.featured-link {
    display: block;
    height: 100%;
    position: relative;
}

.card--featured .card__overlay,
.featured-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-6);
    z-index: 2;
}

@media (min-width: 768px) {
    .card--featured .card__overlay,
    .featured-overlay {
        padding: var(--space-8);
    }
}

.card--featured .card__category,
.featured-category,
.category-tag {
    display: inline-block;
    background: var(--gradient-primary);
    color: var(--bg-white);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-full);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-primary);
}

.card--featured .card__title,
.featured-title {
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.3;
    color: var(--bg-white);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .card--featured .card__title,
    .featured-title {
        font-size: var(--text-2xl);
    }
}

@media (min-width: 992px) {
    .card--featured .card__title,
    .featured-title {
        font-size: var(--text-3xl);
    }
}

.card--featured .card__meta,
.featured-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.9);
}

.card--featured .card__meta span,
.featured-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* ==========================================================================
   SIDEBAR NUMBER/RANKING BADGE - Unified Design System
   ========================================================================== */

/* Base styles for ranking numbers in sidebar */
.trending-number,
.sidebar-number,
.rank-number,
.post-number {
    /* Layout */
    position: absolute;
    left: 0;
    top: 0;
    
    /* Dimensions */
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    
    /* Flex centering */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    /* Typography */
    font-size: 14px;
    font-weight: 800;
    font-family: var(--font-primary, -apple-system, BlinkMacSystemFont, sans-serif);
    line-height: 1;
    letter-spacing: 0;
    text-align: center;
    
    /* Colors */
    background: var(--primary-color, #e63946);
    color: #ffffff;
    
    /* Borders */
    border: none;
    border-radius: var(--radius-sm, 6px);
    
    /* Effects */
    transition: all var(--transition-fast, 150ms ease);
    box-shadow: none;
    
    /* Z-index */
    z-index: 1;
    
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
}

/* First position - Gold/Primary */
.trending-post-item:first-child .trending-number,
.sidebar-number[data-rank="1"],
.rank-number.rank-1,
.post-number.position-1 {
    background: var(--primary-color, #e63946);
}

/* Second position - Darker shade */
.trending-post-item:nth-child(2) .trending-number,
.sidebar-number[data-rank="2"],
.rank-number.rank-2,
.post-number.position-2 {
    background: var(--primary-dark, #c1121f);
}

/* Third position - Alternative shade */
.trending-post-item:nth-child(3) .trending-number,
.sidebar-number[data-rank="3"],
.rank-number.rank-3,
.post-number.position-3 {
    background: #c8102e;
}

/* Fourth and beyond - Light gray */
.trending-post-item:nth-child(n+4) .trending-number,
.sidebar-number[data-rank="4"],
.sidebar-number[data-rank="5"],
.sidebar-number[data-rank="6"],
.sidebar-number[data-rank="7"],
.sidebar-number[data-rank="8"],
.sidebar-number[data-rank="9"],
.sidebar-number[data-rank="10"],
.rank-number.rank-4,
.rank-number.rank-5,
.post-number.position-4,
.post-number.position-5 {
    background: var(--bg-light, #f8f9fa);
    color: var(--text-color, #2d2d2d);
}

/* Hover effects */
.trending-post-item:hover .trending-number,
.sidebar-number:hover,
.rank-number:hover,
.post-number:hover {
    background: var(--primary-color, #e63946) !important;
    color: #ffffff !important;
    transform: scale(1.1);
}

/* ==========================================================================
   SIDEBAR POST WITH NUMBER - Container Styles
   ========================================================================== */

/* Trending post item with number */
.trending-post-item,
.sidebar-post-with-number,
.post-with-rank {
    position: relative;
    padding-left: 36px;
    padding-top: 2px;
    padding-bottom: 2px;
    min-height: 36px;
}

.trending-post-item:first-child,
.sidebar-post-with-number:first-child,
.post-with-rank:first-child {
    padding-top: 0;
}

.trending-post-item:last-child,
.sidebar-post-with-number:last-child,
.post-with-rank:last-child {
    padding-bottom: 0;
}

/* Content within numbered post */
.trending-content,
.sidebar-number-content,
.rank-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ==========================================================================
   SIDEBAR WIDGET - Container Styles
   ========================================================================== */

/* Trending widget container */
.trending-widget,
.sidebar-ranking-widget {
    background: var(--bg-light, #f8f9fa);
    border-radius: var(--radius-md, 10px);
    padding: 20px;
    border: 1px solid var(--border-color, #e5e5e5);
}

.trending-widget .trending-posts-list,
.sidebar-ranking-widget .ranking-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ==========================================================================
   DARK MODE - Number Styles
   ========================================================================== */
body.dark-mode .trending-number,
body.dark-mode .sidebar-number,
body.dark-mode .rank-number,
body.dark-mode .post-number {
    background: var(--primary-color, #e63946);
    color: #ffffff;
}

body.dark-mode .trending-post-item:nth-child(n+4) .trending-number,
body.dark-mode .sidebar-number[data-rank="4"],
body.dark-mode .sidebar-number[data-rank="5"],
body.dark-mode .sidebar-number[data-rank="6"],
body.dark-mode .rank-number.rank-4,
body.dark-mode .rank-number.rank-5,
body.dark-mode .post-number.position-4,
body.dark-mode .post-number.position-5 {
    background: #333333;
    color: #e5e5e5;
}

body.dark-mode .trending-widget,
body.dark-mode .sidebar-ranking-widget {
    background: #252525;
    border-color: #333333;
}

body.dark-mode .trending-widget .trending-post-item,
body.dark-mode .sidebar-ranking-widget .sidebar-post-with-number {
    border-color: #333333;
}

/* ==========================================================================
   RESPONSIVE - Mobile Styles
   ========================================================================== */
@media (max-width: 479px) {
    .trending-number,
    .sidebar-number,
    .rank-number,
    .post-number {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        font-size: 12px;
    }
    
    .trending-post-item,
    .sidebar-post-with-number,
    .post-with-rank {
        padding-left: 30px;
        padding-top: 1px;
        padding-bottom: 1px;
        min-height: 30px;
    }
}

@media (min-width: 480px) and (max-width: 767px) {
    .trending-number,
    .sidebar-number,
    .rank-number,
    .post-number {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
        font-size: 13px;
    }
    
    .trending-post-item,
    .sidebar-post-with-number,
    .post-with-rank {
        padding-left: 32px;
    }
}

/* ==========================================================================
   SIDEBAR CARD - Card compact para sidebar
   ========================================================================== */

.card--sidebar,
.featured-sidebar-post,
.cat-post-small,
.widget-post {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.card--sidebar .card__thumbnail,
.featured-sidebar-post .sidebar-post-thumb,
.cat-post-small .cat-post-thumb-sm,
.widget-post .widget-post-thumb {
    width: 80px;
    height: 60px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-light);
}

@media (min-width: 768px) {
    .card--sidebar .card__thumbnail,
    .featured-sidebar-post .sidebar-post-thumb {
        width: 100px;
        height: 75px;
    }
}

.card--sidebar .card__thumbnail img,
.featured-sidebar-post .sidebar-post-thumb img,
.cat-post-small .cat-post-thumb-sm img,
.widget-post .widget-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card--sidebar .card__content,
.featured-sidebar-post .sidebar-post-content,
.cat-post-small .cat-post-content-sm,
.widget-post .widget-post-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card--sidebar .card__title,
.featured-sidebar-post .sidebar-post-title,
.cat-post-small .cat-post-title-sm,
.widget-post .widget-post-title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.4;
    color: var(--secondary-color);
    margin-bottom: var(--space-1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card--sidebar .card__meta,
.featured-sidebar-post .post-date-sm,
.cat-post-small .cat-post-date-sm,
.widget-post .widget-post-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ==========================================================================
   LATEST CARD - Card para widget de posts recentes
   ========================================================================== */

.card--latest,
.latest-post-item {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-3);
}

.card--latest:last-child,
.latest-post-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.card--latest:last-child,
.latest-post-item:last-child {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.card--latest .card__content,
.latest-post-item .latest-post-content {
    display: flex;
    gap: var(--space-3);
}

.card--latest .card__thumbnail,
.latest-post-item .latest-post-thumbnail {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.card--latest .card__thumbnail img,
.latest-post-item .latest-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card--latest .card__title,
.latest-post-item .latest-post-title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--space-1);
}

.card--latest .card__title a,
.latest-post-item .latest-post-title a {
    color: var(--secondary-color);
}

.card--latest .card__date,
.latest-post-item .latest-post-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 767px) {
    .card--news {
        flex-direction: row;
    }
    
    .card--news .card__thumbnail,
    .news-card .news-thumbnail {
        width: 120px;
        height: 90px;
        padding-top: 0;
        flex-shrink: 0;
        background: var(--bg-light);
    }
    
    .card--news .card__thumbnail img,
    .news-card .news-thumbnail img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 1 !important;
    }
    
    .card--news .card__content,
    .news-card .news-content {
        padding: var(--space-3);
        flex: 1;
        min-width: 0;
    }
    
    .card--sidebar {
        flex-direction: column;
    }
    
    .card--sidebar .card__thumbnail {
        width: 100%;
        height: 120px;
    }
}

@media (max-width: 479px) {
    .card--featured .card__title,
    .featured-title {
        font-size: var(--text-lg);
    }
    
    .card--sidebar .card__thumbnail {
        width: 50%;
        height: 100px;
    }
}

/* Fallback styles for images - ensure visibility on mobile */
.card__thumbnail img,
.news-thumbnail img,
.news-post-thumbnail img,
.sidebar-post-thumb img,
.cat-post-thumb img,
.cat-post-thumb-sm img,
.widget-post-thumb img,
.latest-post-thumbnail img,
.related-card .news-thumbnail img {
    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

/* Fallback background color when image is loading or not available */
.card__thumbnail,
.news-thumbnail,
.news-post-thumbnail,
.sidebar-post-thumb,
.cat-post-thumb,
.cat-post-thumb-sm,
.widget-post-thumb,
.latest-post-thumbnail {
    background: var(--bg-light);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Ensure images are always visible */
img.card__image,
img.news-thumbnail-img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fallback icon when no image is available - ensure visibility */
.card__thumbnail:empty::before,
.news-thumbnail:empty::before,
.news-post-thumbnail:empty::before,
.sidebar-post-thumb:empty::before,
.cat-post-thumb:empty::before,
.cat-post-thumb-sm:empty::before,
.widget-post-thumb:empty::before,
.latest-post-thumbnail:empty::before {
    content: '';
    display: none;
}

/* Force all thumbnail images to be visible */
.card__thumbnail img,
.news-post-thumbnail img,
.sidebar-post-thumb img,
.cat-post-thumb img,
.cat-post-thumb-sm img,
.latest-post-thumbnail img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    opacity: 1 !important;
    visibility: visible !important;
    clip: auto !important;
}

/* Fallback thumbnail styling - when no image is available */
.news-post-thumbnail-fallback,
.cat-post-thumb-fallback,
.cat-post-thumb-sm-fallback {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--bg-light) !important;
    min-height: 120px !important;
    width: 100% !important;
}

@media (min-width: 768px) {
    .news-post-thumbnail-fallback {
        min-height: 150px !important;
    }
}

/* Mobile responsive fallback */
@media (max-width: 479px) {
    .news-post-card {
        flex-direction: row !important;
    }
    
    .news-post-card .news-post-thumbnail {
        width: 100px !important;
        height: 80px !important;
        flex-shrink: 0 !important;
    }
    
    .news-post-card .news-post-thumbnail img,
    .news-post-card .news-post-thumbnail-fallback {
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT
   ========================================================================== */

body.dark-mode .card,
body.dark-mode .news-card,
body.dark-mode .news-post-card,
body.dark-mode .related-card {
    background: var(--bg-light);
    border-color: var(--border-color);
}

body.dark-mode .card--news .card__title,
body.dark-mode .news-card .news-title,
body.dark-mode .card--sidebar .card__title,
body.dark-mode .featured-sidebar-post .sidebar-post-title {
    color: var(--bg-white);
}

body.dark-mode .card--news .card__excerpt,
body.dark-mode .news-card .news-excerpt {
    color: var(--text-light);
}

body.dark-mode .card--news .card__meta,
body.dark-mode .news-card .news-meta {
    border-color: var(--border-color);
}

body.dark-mode .card--latest,
body.dark-mode .latest-post-item {
    border-color: var(--border-color);
}

