/* استایل‌های صفحات لیست خبر و صفحه اصلی */
.news-item { transition: background 0.2s ease; text-decoration: none; color: inherit; }
.news-item:hover { background: #f8fafc; text-decoration: none; }

@keyframes fadeInOpacity {
    from { opacity: 0; }
    to { opacity: 1; }
}
.fade-in { animation: fadeInOpacity 0.35s ease; }
.sidebar-box--settled { animation: none; }

.news-title {
    overflow: hidden;
    margin: 0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .news-title {
        line-height: 1.55;
    }
}

@media (min-width: 641px) {
    .news-title {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
    }
}

@media (min-width: 1024px) {
    .news-item { padding-top: 6px !important; padding-bottom: 6px !important; }
}

.news-source { width: 72px; flex-shrink: 0; }
.news-source span { display: block; text-align: center; }
.news-time { width: auto; min-width: 44px; flex-shrink: 0; text-align: left; }

@media (max-width: 640px) {
    .news-source { width: 58px; }
    .news-time { min-width: 40px; }
    .news-item { padding-top: 4px !important; padding-bottom: 4px !important; }
}

.news-time span,
.text-slate-400 { color: #64748b !important; }

/* سایدبار — باکس‌های رنگی */
.sidebar-box {
    --sb-accent: #2563eb;
    --sb-header-from: #1d4ed8;
    --sb-header-to: #3b82f6;
    --sb-soft: #eff6ff;
    --sb-border: #dbeafe;
    background: #fff;
    border: 1px solid var(--sb-border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.05);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.sidebar-box:hover {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.09);
}
.sidebar-box-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, var(--sb-header-from) 0%, var(--sb-header-to) 100%);
    border-bottom: none;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
}
.sidebar-box-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    font-size: 9px;
}
.sidebar-box-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-box-body {
    background: #fff;
}
.sidebar-box-empty {
    padding: 8px 10px;
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
}
.sidebar-feed-item {
    position: relative;
    padding: 5px 8px 5px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    display: block;
    text-decoration: none;
    transition: background 0.15s ease;
}
.sidebar-feed-item:last-child { border-bottom: none; }
.sidebar-feed-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 2px;
    border-radius: 2px 0 0 2px;
    background: var(--sb-accent);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.sidebar-feed-item:hover {
    background: var(--sb-soft);
}
.sidebar-feed-item:hover::before { opacity: 1; }
.sidebar-feed-line {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}
.sidebar-feed-item .chevron {
    color: var(--sb-accent);
    font-weight: 700;
    font-size: 12px;
    line-height: 1.35;
    margin-left: 2px;
    flex-shrink: 0;
    opacity: 0.85;
}
.sidebar-feed-text {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}
.sidebar-feed-source {
    flex-shrink: 0;
    font-size: 8px;
    font-weight: 600;
    color: var(--sb-accent);
    background: var(--sb-soft);
    border: 1px solid var(--sb-border);
    padding: 0 4px;
    border-radius: 4px;
    line-height: 1.45;
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

/* تم‌های رنگی — هر باکس */
.sidebar-box--t0 { --sb-accent:#2563eb; --sb-header-from:#1d4ed8; --sb-header-to:#3b82f6; --sb-soft:#eff6ff; --sb-border:#bfdbfe; }
.sidebar-box--t1 { --sb-accent:#dc2626; --sb-header-from:#b91c1c; --sb-header-to:#ef4444; --sb-soft:#fef2f2; --sb-border:#fecaca; }
.sidebar-box--t2 { --sb-accent:#059669; --sb-header-from:#047857; --sb-header-to:#10b981; --sb-soft:#ecfdf5; --sb-border:#a7f3d0; }
.sidebar-box--t3 { --sb-accent:#d97706; --sb-header-from:#b45309; --sb-header-to:#f59e0b; --sb-soft:#fffbeb; --sb-border:#fde68a; }
.sidebar-box--t4 { --sb-accent:#7c3aed; --sb-header-from:#6d28d9; --sb-header-to:#8b5cf6; --sb-soft:#f5f3ff; --sb-border:#ddd6fe; }
.sidebar-box--t5 { --sb-accent:#0891b2; --sb-header-from:#0e7490; --sb-header-to:#06b6d4; --sb-soft:#ecfeff; --sb-border:#a5f3fc; }
.sidebar-box--t6 { --sb-accent:#4f46e5; --sb-header-from:#4338ca; --sb-header-to:#6366f1; --sb-soft:#eef2ff; --sb-border:#c7d2fe; }
.sidebar-box--t7 { --sb-accent:#db2777; --sb-header-from:#be185d; --sb-header-to:#ec4899; --sb-soft:#fdf2f8; --sb-border:#fbcfe8; }
.sidebar-box--most-visited {
    --sb-accent:#b45309;
    --sb-header-from:#92400e;
    --sb-header-to:#d97706;
    --sb-soft:#fffbeb;
    --sb-border:#fcd34d;
    position: sticky;
    top: 0.75rem;
    z-index: 2;
    box-shadow: 0 4px 14px rgba(180, 83, 9, 0.18);
}
.sidebar-box--most-visited .sidebar-box-header {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
}
.sidebar-box--most-visited .sidebar-box-period {
    margin-right: auto;
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0.92;
    background: rgba(255,255,255,0.18);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}
.sidebar-most-visited-item .sidebar-feed-source {
    color: var(--sb-accent);
    font-weight: 700;
}
.sidebar-box--sponsor {
    --sb-accent:#ca8a04;
    --sb-header-from:#a16207;
    --sb-header-to:#eab308;
    --sb-soft:#fefce8;
    --sb-border:#fde047;
}
.sidebar-box--sponsor .sidebar-box-header::after {
    content: '★';
    margin-right: auto;
    font-size: 11px;
    opacity: 0.75;
}
.sponsor-item { padding: 6px; text-align: center; background: var(--sb-soft, #fefce8); }
.sponsor-item img { max-width: 100%; height: auto; border-radius: 6px; max-height: 72px; object-fit: contain; }

@media (max-width: 640px) {
    .sidebar-box { margin-bottom: 8px; }
    .sidebar-feed-item { padding: 4px 8px 4px 9px; }
    .sidebar-feed-text { font-size: 10px; -webkit-line-clamp: 2; }
    .sidebar-feed-source { max-width: 46px; font-size: 8px; }
}

/* نوار تاریخ/ساعت */
.top-meta-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin: 0 0 12px;
    padding: 0;
    min-height: 0;
    background: none;
    border: none;
    box-shadow: none;
}
.top-meta-bar-compact { margin-bottom: 10px; }
.top-meta-bar-end { justify-content: flex-start; }

.site-datetime {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 8px;
    font-size: 11px;
    line-height: 1.3;
    color: #64748b;
    user-select: none;
    min-height: 28px;
}
.site-datetime .dt-weekday {
    font-weight: 600;
    color: #475569;
}
.site-datetime .dt-sep {
    color: #94a3b8;
    font-weight: 400;
    padding: 0 2px;
}
.site-datetime .dt-date {
    font-weight: 500;
    color: #64748b;
}
.site-datetime .dt-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    padding: 3px 9px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}
.site-datetime .dt-clock-icon {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}
.site-datetime .dt-time-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* سازگاری با HTML قدیمی — همان استایل site-datetime */
#persian-datetime.datetime-pill,
.datetime-pill {
    display: inline-flex !important;
    align-items: center !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 8px;
    font-size: 11px;
    line-height: 1.3;
    color: #64748b !important;
    background: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
}
.datetime-pill .date-part,
.datetime-pill .time-part {
    background: none !important;
    color: inherit !important;
    box-shadow: none !important;
}

html.is-mobile .news-title,
html.is-mobile .sidebar-feed-text {
    display: block;
    white-space: normal;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.55;
    font-size: 13px;
}

.top-meta-refresh { display: none !important; }

/* اسکلتون — جلوگیری از CLS */
#news-content {
    min-height: 420px;
}
#news-content.news-loaded {
    min-height: 0;
}
.news-skeleton-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    min-height: 420px;
}
@media (min-width: 1024px) {
    .news-skeleton-grid { grid-template-columns: 1fr 1fr; }
}
.news-skeleton-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    min-height: 200px;
    overflow: hidden;
}
.news-skeleton-head {
    height: 40px;
    background: linear-gradient(to left, #cbd5e1, #94a3b8);
}
.news-skeleton-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.news-skeleton-line {
    height: 14px;
    background: #f1f5f9;
    border-radius: 4px;
}

#homepage-sidebar { min-height: 120px; }
#most-visited-box:not(:empty) { min-height: 88px; }
#featured-feeds-boxes:not(:empty) { min-height: 80px; }
#footer-menu { min-height: 36px; }
#sponsors-wrapper.is-empty { visibility: hidden; height: 0; min-height: 0; overflow: hidden; margin: 0; }

/* لایو */
@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.live-dot { animation: livePulse 1.5s ease-in-out infinite; }

.live-auto-refresh-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 9px 12px;
    font-size: 11px;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.live-auto-refresh-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.live-auto-refresh-text {
    line-height: 1.5;
    word-break: break-word;
}
.live-auto-refresh-bar.is-fetching {
    color: #2563eb;
    background: #eff6ff;
}
.live-sync-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}
.live-sync-icon {
    color: #2563eb;
    font-size: 12px;
    animation: liveSpin 3s linear infinite;
}
.live-auto-refresh-bar.is-fetching .live-sync-icon {
    animation-duration: 0.7s;
}
.live-sync-pulse {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.35);
    animation: liveSyncRing 2s ease-out infinite;
}
.live-auto-refresh-bar.is-fetching .live-sync-pulse {
    animation-duration: 0.9s;
}
.live-last-updated {
    color: #94a3b8;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .live-auto-refresh-bar {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 10px 8px;
        gap: 5px;
    }
    .live-auto-refresh-main {
        justify-content: center;
        width: 100%;
    }
    .live-auto-refresh-text {
        font-size: 10px;
        text-align: right;
        flex: 1;
    }
    .live-last-updated {
        width: 100%;
        text-align: center;
        font-size: 9px;
    }
    .live-sync-indicator {
        flex-shrink: 0;
    }
}
@keyframes liveSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes liveSyncRing {
    0% { transform: scale(0.85); opacity: 0.9; }
    100% { transform: scale(1.6); opacity: 0; }
}
@keyframes liveHighlight {
    0% { background-color: #dbeafe; }
    100% { background-color: transparent; }
}
.live-item-new {
    animation: liveHighlight 3s ease-out;
}

.live-page-item { padding-top: 6px; padding-bottom: 6px; }

/* pagination */
.page-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
}
.page-btn.is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.page-btn:hover:not(.is-active) { background: #f1f5f9; }

.page-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: #fff;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 700;
}
.source-website-link {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    font-weight: 400;
}
.source-website-link:hover { background: rgba(255, 255, 255, 0.3); }

.static-page-body { min-height: 120px; }
.static-page-body p:last-child { margin-bottom: 0; }
