/**
 * XNForums 扩展功能样式
 * 用户统计、积分等级、私信系统、草稿管理
 */

/* ==================== 用户统计组件 ==================== */
.xnforums-user-statistics {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.xnforums-user-statistics .statistics-title {
    font-size: 20px;
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #2271b1;
    padding-bottom: 10px;
}

.xnforums-user-statistics .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.stat-card .stat-icon {
    font-size: 36px;
    line-height: 1;
}

.stat-card .stat-content {
    flex: 1;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.9;
}

/* 不同颜色主题 */
.stat-card.stat-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-card.stat-success { background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); }
.stat-card.stat-info { background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%); }
.stat-card.stat-warning { background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%); }
.stat-card.stat-purple { background: linear-gradient(135deg, #a044ff 0%, #6a3093 100%); }
.stat-card.stat-teal { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-card.stat-orange { background: linear-gradient(135deg, #ff6a00 0%, #ee0979 100%); }
.stat-card.stat-pink { background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%); }

.detailed-stats {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.detailed-stats h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #333;
}

.activity-chart {
    background: #f9fafb;
    border-radius: 8px;
    padding: 20px;
    min-height: 250px;
}

.popular-topics-section {
    margin-top: 24px;
}

.popular-topics-section h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #333;
}

.popular-topics-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.popular-topic-item {
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 8px;
    transition: background 0.2s ease;
}

.popular-topic-item:hover {
    background: #f3f4f6;
}

.popular-topic-item .topic-link {
    font-weight: 500;
    color: #2271b1;
    text-decoration: none;
    display: block;
    margin-bottom: 6px;
}

.popular-topic-item .topic-link:hover {
    color: #135e96;
}

.popular-topic-item .topic-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #6b7280;
}

/* ==================== 积分等级徽章 ==================== */
.xnforums-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fff;
    border: 2px solid var(--level-color, #999);
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.xnforums-level-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.xnforums-level-badge .level-icon {
    font-size: 20px;
    line-height: 1;
}

.xnforums-level-badge .level-name {
    font-weight: bold;
    color: var(--level-color);
}

.xnforums-level-badge .level-points {
    font-size: 12px;
    color: #666;
    padding-left: 8px;
    border-left: 1px solid #ddd;
}

.xnforums-level-badge.level-badge-small {
    padding: 4px 10px;
    font-size: 12px;
    gap: 4px;
}

.xnforums-level-badge.level-badge-small .level-icon {
    font-size: 16px;
}

.xnforums-level-badge.level-badge-large {
    padding: 12px 24px;
    font-size: 16px;
}

.level-progress-wrapper {
    width: 100%;
    margin-top: 12px;
}

.level-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}

.level-progress-fill {
    height: 100%;
    background: var(--level-color);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.level-progress-text {
    font-size: 12px;
    color: #6b7280;
}

/* ==================== 私信系统 ==================== */
.xnforums-messages-page {
    padding: 20px 0;
}

.xnforums-messages-page .page-title {
    font-size: 28px;
    margin: 0 0 24px 0;
    color: #1f2937;
}

.messages-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    min-height: 600px;
}

@media (max-width: 768px) {
    .messages-layout {
        grid-template-columns: 1fr;
    }
    
    .conversations-sidebar {
        max-height: 400px;
    }
}

/* 会话列表 */
.conversations-sidebar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.btn-new-message {
    padding: 8px 16px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s ease;
}

.btn-new-message:hover {
    background: #135e96;
}

.conversations-list {
    overflow-y: auto;
    flex: 1;
}

.no-conversations {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

.no-conversations .hint {
    font-size: 13px;
    color: #9ca3af;
}

.conversation-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
    position: relative;
}

.conversation-item:hover {
    background: #f9fafb;
}

.conversation-item.active {
    background: #eff6ff;
    border-left: 3px solid #2271b1;
}

.conversation-item.unread {
    background: #fef3c7;
}

.conversation-item .user-avatar {
    position: relative;
}

.conversation-item .user-avatar img {
    border-radius: 50%;
}

.conversation-item .unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-info .user-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.conversation-info .last-message {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.conversation-info .message-time {
    font-size: 12px;
    color: #9ca3af;
}

/* 消息内容区 */
.messages-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversation-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.conversation-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-header .user-info img {
    border-radius: 50%;
}

.conversation-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.conversation-header .view-profile {
    font-size: 13px;
    color: #2271b1;
    text-decoration: none;
}

.messages-thread {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: 500px;
}

.message-item {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.message-item.mine {
    flex-direction: row-reverse;
}

.message-item .message-avatar img {
    border-radius: 50%;
}

.message-bubble {
    background: #f3f4f6;
    border-radius: 16px;
    padding: 12px 16px;
    max-width: 70%;
}

.message-item.mine .message-bubble {
    background: #2271b1;
    color: #fff;
}

.message-bubble .message-subject {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 14px;
}

.message-bubble .message-content {
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble .message-meta {
    margin-top: 8px;
    font-size: 11px;
    color: #6b7280;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.message-item.mine .message-meta {
    color: rgba(255,255,255,0.7);
}

.message-compose {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.message-compose textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.message-compose .form-actions {
    margin-top: 12px;
    text-align: right;
}

.btn-send {
    padding: 10px 24px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.btn-send:hover {
    background: #135e96;
}

.no-conversation-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.empty-state {
    text-align: center;
    color: #6b7280;
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    color: #1f2937;
}

/* 新消息弹窗 */
.xnforums-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.1);
}

.search-results {
    margin-top: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.user-result-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-result-item:hover {
    background: #f3f4f6;
}

.no-results {
    padding: 10px 12px;
    color: #9ca3af;
    text-align: center;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel {
    padding: 10px 20px;
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-cancel:hover {
    background: #e5e7eb;
}

/* ==================== 草稿管理 ==================== */
.xnforums-draft-manager {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.draft-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #2271b1;
}

.draft-header h3 {
    margin: 0;
    font-size: 20px;
    color: #1f2937;
}

.draft-count {
    font-size: 14px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 12px;
    border-radius: 12px;
}

.no-drafts {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.no-drafts .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.no-drafts .hint {
    font-size: 14px;
    color: #9ca3af;
}

.drafts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.draft-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.2s ease;
}

.draft-item:hover {
    border-color: #2271b1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.draft-content {
    flex: 1;
    min-width: 0;
}

.draft-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #1f2937;
}

.draft-preview {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 12px;
}

.draft-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: #9ca3af;
}

.draft-meta > span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.draft-status.published {
    color: #10b981;
    font-weight: 500;
}

.draft-actions {
    display: flex;
    gap: 8px;
}

.btn-restore-draft,
.btn-delete-draft {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-restore-draft:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.btn-delete-draft:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* 自动保存状态 */
.auto-save-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.auto-save-status.saving {
    background: #fbbf24;
    color: #78350f;
}

.auto-save-status.saved {
    background: #10b981;
    color: #fff;
}

.auto-save-status.error {
    background: #ef4444;
    color: #fff;
}

.auto-save-status .status-icon {
    font-size: 18px;
}

/* 通知提示 */
.xnforums-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.xnforums-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.xnforums-notification.success {
    border-left: 4px solid #10b981;
}

.xnforums-notification.error {
    border-left: 4px solid #ef4444;
}

.xnforums-notification.warning {
    border-left: 4px solid #f59e0b;
}

/* 响应式 */
@media (max-width: 640px) {
    .xnforums-user-statistics .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .draft-item {
        flex-direction: column;
    }
    
    .draft-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .btn-restore-draft,
    .btn-delete-draft {
        flex: 1;
    }
}

