/* APO Newsroom Plugin Frontend Styles */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Archivo:wght@400;500;600&display=swap');

/* Reset and Base Styles */
.apo-newsroom-widget * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.apo-newsroom-widget {
    font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

/* Header Section */
.apo-widget-header {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    padding: 40px 30px;
    position: relative;
    overflow: hidden;
}

.apo-widget-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: apo-pulse 8s ease-in-out infinite;
}

@keyframes apo-pulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.5; }
    50% { transform: scale(1.2) rotate(45deg); opacity: 0.8; }
}

.apo-header-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.apo-header-left {
    flex: 1;
    min-width: 250px;
}

.apo-widget-title {
    font-family: 'Sora', sans-serif;
    font-size: 36px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.apo-live-pulse {
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    animation: apo-live-pulse 2s infinite;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

@keyframes apo-live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.apo-widget-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.apo-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.apo-refresh-info {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.apo-countdown {
    font-family: 'Sora', monospace;
    font-weight: 700;
    color: #10b981;
}

.apo-refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    font-family: 'Sora', sans-serif;
}

.apo-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.apo-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.apo-refresh-icon {
    display: inline-block;
    transition: transform 0.6s ease;
    font-size: 18px;
}

.apo-refresh-btn.loading .apo-refresh-icon {
    animation: apo-rotate 1s linear infinite;
}

@keyframes apo-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Stats Bar */
.apo-stats-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 20px 30px;
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    align-items: center;
}

.apo-stat-item {
    display: flex;
    flex-direction: column;
}

.apo-stat-value {
    font-family: 'Sora', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: #047857;
    line-height: 1;
}

.apo-stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
    font-weight: 500;
}

.apo-last-updated {
    margin-left: auto;
    font-size: 13px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.apo-update-time {
    font-weight: 600;
    color: #047857;
}

/* Filter Tabs */
.apo-filter-tabs {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 30px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.apo-filter-tab {
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Sora', sans-serif;
}

.apo-filter-tab:hover {
    color: #047857;
}

.apo-filter-tab.active {
    color: #047857;
    border-bottom-color: #047857;
}

/* News Content */
.apo-news-content {
    padding: 30px;
    background: #f8fafc;
    min-height: 400px;
}

.apo-news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.apo-layout-list .apo-news-grid {
    grid-template-columns: 1fr;
}

.apo-news-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    animation: apo-fade-in-up 0.5s ease;
    position: relative;
}

@keyframes apo-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.apo-news-card.new-article {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.apo-news-card.new-article::before {
    content: 'NEW';
    position: absolute;
    top: 12px;
    right: 12px;
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    z-index: 10;
    animation: apo-new-badge-pulse 2s infinite;
    font-family: 'Sora', sans-serif;
    letter-spacing: 1px;
}

@keyframes apo-new-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.apo-news-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
    border-color: #047857;
}

.apo-news-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.apo-news-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.apo-news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 12px;
}

.apo-news-source {
    color: #047857;
    font-weight: 700;
    font-family: 'Sora', sans-serif;
}

.apo-news-date {
    color: #94a3b8;
    font-weight: 500;
}

.apo-news-title {
    font-family: 'Sora', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
    line-height: 1.4;
}

.apo-news-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.apo-news-title a:hover {
    color: #047857;
}

.apo-news-excerpt {
    color: #64748b;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
}

.apo-news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.apo-news-tag {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Sora', sans-serif;
}

.apo-tag-climate { background: #dbeafe; color: #1e40af; }
.apo-tag-energy { background: #fef3c7; color: #92400e; }
.apo-tag-environment { background: #d1fae5; color: #065f46; }
.apo-tag-renewable { background: #fce7f3; color: #831843; }

.apo-read-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #047857;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    transition: gap 0.2s ease;
    font-family: 'Sora', sans-serif;
}

.apo-read-more:hover {
    gap: 10px;
}

/* Loading State */
.apo-loading-state {
    padding: 80px;
    text-align: center;
}

.apo-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: #047857;
    border-radius: 50%;
    animation: apo-spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes apo-spin {
    to { transform: rotate(360deg); }
}

.apo-loading-text {
    font-size: 16px;
    color: #64748b;
    font-weight: 600;
    font-family: 'Sora', sans-serif;
}

/* Empty State */
.apo-empty-state {
    padding: 80px;
    text-align: center;
    color: #64748b;
}

.apo-empty-state svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.apo-empty-state p {
    font-size: 16px;
    font-weight: 600;
    font-family: 'Sora', sans-serif;
}

/* Error State */
.apo-error-state {
    padding: 60px;
    text-align: center;
    color: #ef4444;
}

.apo-error-state svg {
    margin-bottom: 20px;
}

.apo-error-state p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.apo-error-state button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Sora', sans-serif;
}

/* Widget Styles */
.apo-widget-articles {
    list-style: none;
}

.apo-widget-article {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.apo-widget-article:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.apo-widget-image {
    margin-bottom: 12px;
}

.apo-widget-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
}

.apo-widget-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.apo-widget-title a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.apo-widget-title a:hover {
    color: #047857;
}

.apo-widget-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
}

.apo-widget-source {
    color: #047857;
    font-weight: 700;
}

.apo-widget-date {
    color: #94a3b8;
}

.apo-widget-excerpt {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .apo-widget-header {
        padding: 30px 20px;
    }
    
    .apo-widget-title {
        font-size: 28px;
    }
    
    .apo-stats-bar {
        padding: 16px 20px;
        gap: 24px;
    }
    
    .apo-news-content {
        padding: 20px;
    }
    
    .apo-news-grid {
        grid-template-columns: 1fr;
    }
    
    .apo-filter-tabs {
        padding: 0 20px;
    }
    
    .apo-header-actions {
        width: 100%;
    }
    
    .apo-refresh-info {
        flex: 1;
        justify-content: center;
    }
}