/**
 * DripSafe Design System - Sidebar Widget Components
 * Version: 1.0.0
 * 基于杨过的视觉设计规范
 */

/* ============================
   Sidebar Widget Base Styles
   ============================ */

.ds-widget {
    background: var(--ds-bg-card);
    border-radius: var(--ds-card-radius, 12px);
    padding: var(--ds-widget-padding, 20px);
    margin-bottom: var(--ds-sidebar-gap, 24px);
    box-shadow: var(--ds-shadow-sm);
}

.ds-widget-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ds-text-primary);
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ds-primary);
    display: inline-block;
}

/* ============================
   Popular Posts Widget (热门文章)
   ============================ */

.ds-widget--popular-posts .ds-popular-posts-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ds-popular-post-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ds-border-light);
    transition: background 0.2s ease;
}

.ds-popular-post-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ds-popular-post-item:first-child {
    padding-top: 0;
}

.ds-popular-post-item:hover {
    background: var(--ds-bg-secondary);
    margin: 0 -12px;
    padding: 12px;
    border-radius: 8px;
}

.ds-popular-post-thumb {
    width: 72px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ds-bg-secondary);
}

.ds-popular-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ds-popular-post-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ds-popular-post-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--ds-text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 4px;
    transition: color 0.2s ease;
}

.ds-popular-post-item:hover .ds-popular-post-title {
    color: var(--ds-primary);
}

.ds-popular-post-meta {
    font-size: 12px;
    color: var(--ds-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ds-popular-post-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ds-popular-post-views i {
    font-size: 11px;
}

/* 热门标记 */
.ds-popular-post-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background: var(--ds-error);
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 4px;
}

.ds-popular-post-item:nth-child(1) .ds-popular-post-rank {
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
}

.ds-popular-post-item:nth-child(2) .ds-popular-post-rank {
    background: var(--ds-accent);
}

.ds-popular-post-item:nth-child(3) .ds-popular-post-rank {
    background: var(--ds-primary);
}

/* ============================
   Tag Cloud Widget (标签云)
   ============================ */

.ds-widget--tag-cloud .ds-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.ds-widget--tag-cloud .ds-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--ds-text-secondary);
    background: var(--ds-bg-secondary);
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ds-widget--tag-cloud .ds-tag:hover {
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-secondary));
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

/* 带计数的标签 */
.ds-tag--with-count {
    gap: 6px;
}

.ds-tag--with-count .ds-tag-count {
    font-size: 11px;
    padding-left: 6px;
    border-left: 1px solid currentColor;
    opacity: 0.7;
}

/* 标签云布局变体 */
.ds-tag-cloud--grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.ds-tag-cloud--list {
    flex-direction: column;
    align-items: flex-start;
}

/* ============================
   About Widget (关于卡片)
   ============================ */

.ds-widget--about {
    text-align: center;
    padding: 24px;
}

.ds-about-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--ds-primary);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.ds-about-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ds-about-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--ds-text-primary);
    margin: 0 0 8px;
}

.ds-about-bio {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ds-text-secondary);
    margin: 0 0 16px;
}

.ds-about-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px 0;
    border-top: 1px solid var(--ds-border-light);
    border-bottom: 1px solid var(--ds-border-light);
    margin-bottom: 16px;
}

.ds-about-stat {
    text-align: center;
}

.ds-about-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--ds-primary);
    line-height: 1.2;
}

.ds-about-stat-label {
    font-size: 12px;
    color: var(--ds-text-muted);
}

.ds-about-social {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.ds-about-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 16px;
    color: var(--ds-text-secondary);
    background: var(--ds-bg-secondary);
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ds-about-social-link:hover {
    background: var(--ds-primary);
    color: #ffffff;
    transform: translateY(-2px);
}

/* ============================
   Recent Posts Widget (最新文章)
   ============================ */

.ds-widget--recent-posts .ds-recent-posts-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ds-recent-post-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ds-border-light);
}

.ds-recent-post-item:last-child {
    border-bottom: none;
}

.ds-recent-post-thumbnail {
    width: 56px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.ds-recent-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ds-recent-post-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--ds-text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.ds-recent-post-item:hover .ds-recent-post-title {
    color: var(--ds-primary);
}

/* ============================
   Categories Widget (分类目录)
   ============================ */

.ds-widget--categories .ds-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ds-categories-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--ds-border-light);
}

.ds-categories-list li:last-child {
    border-bottom: none;
}

.ds-categories-list a {
    font-size: 14px;
    color: var(--ds-text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ds-categories-list a:hover {
    color: var(--ds-primary);
    padding-left: 4px;
}

.ds-categories-list .ds-category-count {
    font-size: 12px;
    color: var(--ds-text-muted);
    background: var(--ds-bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ============================
   Search Widget (搜索)
   ============================ */

.ds-widget--search .ds-search-form {
    display: flex;
    gap: 8px;
}

.ds-search-form input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    color: var(--ds-text-primary);
    background: var(--ds-bg-secondary);
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ds-search-form input:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.ds-search-form button {
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    background: var(--ds-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ds-search-form button:hover {
    background: var(--ds-primary-dark);
    transform: translateY(-1px);
}

/* ============================
   Newsletter Widget (订阅)
   ============================ */

.ds-widget--newsletter {
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-secondary));
    color: #ffffff;
    text-align: center;
}

.ds-widget--newsletter .ds-widget-title {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.ds-newsletter-text {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 16px;
    opacity: 0.9;
}

.ds-newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ds-newsletter-form input {
    height: 44px;
    padding: 0 16px;
    font-size: 14px;
    color: var(--ds-text-primary);
    background: #ffffff;
    border: none;
    border-radius: 8px;
}

.ds-newsletter-form input::placeholder {
    color: var(--ds-text-muted);
}

.ds-newsletter-form button {
    height: 44px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ds-primary);
    background: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ds-newsletter-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ============================
   Dark Mode Support
   ============================ */

[data-theme="dark"] .ds-widget {
    background: var(--ds-bg-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ds-widget-title {
    color: var(--ds-text-primary);
}

[data-theme="dark"] .ds-popular-post-item:hover {
    background: var(--ds-bg-secondary);
}

[data-theme="dark"] .ds-tag-cloud .ds-tag {
    background: var(--ds-bg-secondary);
}

[data-theme="dark"] .ds-tag-cloud .ds-tag:hover {
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

[data-theme="dark"] .ds-categories-list .ds-category-count {
    background: var(--ds-bg-secondary);
}

[data-theme="dark"] .ds-search-form input {
    background: var(--ds-bg-secondary);
    border-color: var(--ds-border);
    color: var(--ds-text-primary);
}

/* ============================
   Responsive
   ============================ */

@media (max-width: 767px) {
    .ds-widget {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .ds-widget-title {
        font-size: 16px;
    }
    
    .ds-popular-post-thumb {
        width: 60px;
        height: 40px;
    }
    
    .ds-popular-post-title {
        font-size: 13px;
    }
    
    .ds-about-avatar {
        width: 64px;
        height: 64px;
    }
    
    .ds-about-stats {
        gap: 16px;
    }
    
    .ds-about-stat-value {
        font-size: 18px;
    }
}