/* ================================================================
   Smart Posts Widget — Frontend Styles
   ================================================================ */

/* ── Base reset ─────────────────────────────────────────────── */
.spw-popular-posts *,
.spw-contextual-posts * {
    box-sizing: border-box;
}

/* ================================================================
   POPULAR POSTS
   ================================================================ */
.spw-popular-posts {
    font-family: inherit;
}

.spw-widget-title {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e74c3c;
    color: #1a1a1a;
}

.spw-pp-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.spw-pp-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.spw-pp-item:last-child {
    border-bottom: none;
}

.spw-pp-rank {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    background: #e74c3c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.spw-pp-item:nth-child(2) .spw-pp-rank { background: #e67e22; }
.spw-pp-item:nth-child(3) .spw-pp-rank { background: #f39c12; }
.spw-pp-item:nth-child(n+4) .spw-pp-rank { background: #95a5a6; }

.spw-pp-thumb {
    flex-shrink: 0;
    display: block;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border-radius: 6px;
}

.spw-pp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.spw-pp-thumb:hover img {
    transform: scale(1.08);
}

.spw-pp-info {
    flex: 1;
    min-width: 0;
}

.spw-pp-title {
    display: block;
    font-weight: 600;
    line-height: 1.4;
    color: #1a1a1a;
    text-decoration: none;
    margin-bottom: 5px;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spw-pp-title:hover {
    color: #e74c3c;
}

.spw-pp-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #888;
}

.spw-pp-views,
.spw-pp-date {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ================================================================
   CONTEXTUAL POSTS
   ================================================================ */
.spw-contextual-posts {
    margin: 40px 0;
    font-family: inherit;
}

/* ── Tabs nav ───────────────────────────────────────────────── */
.spw-tabs-nav {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    gap: 0;
    margin-bottom: 0;
}

.spw-tab-btn {
    padding: 12px 22px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    position: relative;
    bottom: -2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    letter-spacing: 0.01em;
}

.spw-tab-btn:hover {
    color: #e74c3c;
}

.spw-tab-btn.spw-active {
    color: #e74c3c;
    border-bottom-color: #e74c3c;
    background: #fff;
}

/* ── Tab panels ─────────────────────────────────────────────── */
.spw-tabs-body {
    padding-top: 20px;
}

.spw-tab-panel {
    display: none;
}

.spw-tab-panel.spw-active {
    display: block;
    animation: spwFadeIn 0.25s ease;
}

@keyframes spwFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Card grid ──────────────────────────────────────────────── */
.spw-cp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.spw-cp-card {
    background: #fff;
    border: 1px solid #ebebeb;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.spw-cp-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.10);
    transform: translateY(-3px);
}

.spw-cp-thumb-link {
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #f5f5f5;
}

.spw-cp-thumb-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.spw-cp-card:hover .spw-cp-thumb-link img {
    transform: scale(1.06);
}

.spw-cp-no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
    font-size: 32px;
    aspect-ratio: 16/9;
}

.spw-cp-body {
    padding: 14px 16px;
}

.spw-cp-cat {
    display: inline-block;
    background: #fff3f3;
    color: #e74c3c;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 7px;
}

.spw-cp-title {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.45;
}

.spw-cp-title a {
    color: #1a1a1a;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spw-cp-title a:hover {
    color: #e74c3c;
}

.spw-cp-excerpt {
    margin: 0 0 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spw-cp-date {
    font-size: 12px;
    color: #999;
}

/* ── Empty states ───────────────────────────────────────────── */
.spw-empty {
    padding: 20px;
    text-align: center;
    color: #aaa;
    font-style: italic;
    font-size: 14px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .spw-cp-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .spw-tab-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    .spw-cp-grid {
        grid-template-columns: 1fr;
    }
}
