/* assets/css/frontend.css - Complete Grid Layout Styles */

/* Main Widget Styles */
.tpa-main-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 30px;
}

.tpa-header {
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.tpa-title-section {
    text-align: left;
}

.tpa-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.tpa-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Grid Layout */
.tpa-trending-grid {
    min-height: 300px;
    position: relative;
}

.tpa-grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    animation: fadeIn 0.3s ease-in;
}

/* Grid Items */
.tpa-grid-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 140px;
}

.tpa-grid-item:hover {
    border-color: #4a90e2;
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.12);
    transform: translateY(-2px);
}

/* Featured first item */
.tpa-grid-item.featured {
    grid-column: span 1;
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
    border-color: #4a90e2;
}

.tpa-grid-rank {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 6px;
}

.tpa-grid-rank.top-rank {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #8b6914;
    font-size: 18px;
}

.tpa-grid-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tpa-grid-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 12px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    flex: 1;
}

.tpa-grid-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    margin-top: auto;
}

.tpa-grid-category {
    display: inline-block;
    padding: 3px 8px;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

/* Category Colors */
.tpa-grid-category.news {
    background: #e3f2fd;
    color: #1565c0;
}

.tpa-grid-category.tech {
    background: #f3e5f5;
    color: #7b1fa2;
}

.tpa-grid-category.politics {
    background: #fce4ec;
    color: #c2185b;
}

.tpa-grid-category.government {
    background: #e8f5e9;
    color: #2e7d32;
}

.tpa-grid-category.uncategorized {
    background: #f3f4f6;
    color: #6b7280;
}

.tpa-grid-active {
    color: #10b981;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Loading State */
.tpa-loading {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 14px;
}

/* Sidebar Widget Styles */
.tpa-sidebar-widget {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 20px;
    margin-bottom: 24px;
}

.tpa-sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f2f5;
}

.tpa-sidebar-list {
    min-height: 200px;
}

.tpa-sidebar-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tpa-sidebar-item:hover {
    padding-left: 8px;
}

.tpa-sidebar-item:last-child {
    border-bottom: none;
}

.tpa-sidebar-rank {
    min-width: 28px;
    font-size: 16px;
    font-weight: 700;
    color: #4a90e2;
    margin-right: 12px;
    text-align: center;
}

.tpa-sidebar-rank.top-3 {
    color: #f59e0b;
}

.tpa-sidebar-content {
    flex: 1;
}

.tpa-sidebar-post-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 4px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tpa-sidebar-category {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Grid Configurations */
.tpa-trending-grid[data-columns="2"] .tpa-grid-container {
    grid-template-columns: repeat(2, 1fr);
}

.tpa-trending-grid[data-columns="4"] .tpa-grid-container {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .tpa-trending-grid[data-columns="4"] .tpa-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .tpa-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tpa-trending-grid[data-columns="4"] .tpa-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tpa-header {
        padding-bottom: 16px;
        margin-bottom: 20px;
    }
    
    .tpa-title {
        font-size: 24px;
    }
    
    .tpa-grid-container,
    .tpa-trending-grid[data-columns="2"] .tpa-grid-container,
    .tpa-trending-grid[data-columns="3"] .tpa-grid-container,
    .tpa-trending-grid[data-columns="4"] .tpa-grid-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .tpa-grid-item {
        padding: 16px;
        min-height: 120px;
    }
    
    .tpa-grid-item.featured {
        grid-column: span 1;
    }
    
    .tpa-grid-title {
        font-size: 14px;
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 480px) {
    .tpa-main-widget {
        padding: 16px;
    }
    
    .tpa-title {
        font-size: 20px;
    }
    
    .tpa-subtitle {
        font-size: 13px;
    }
    
    .tpa-grid-container {
        gap: 12px;
    }
    
    .tpa-grid-item {
        padding: 14px;
        min-height: 100px;
    }
    
    .tpa-grid-rank {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .tpa-grid-rank.top-rank {
        font-size: 16px;
    }
}

/* Animation */
@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Print Styles */
@media print {
    .tpa-main-widget {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
    
    .tpa-grid-item {
        break-inside: avoid;
    }
}