/**
 * 新闻管理页面优化样式
 * 包含：表格优化、编辑器样式、交互动画、响应式布局
 */

/* ===========================
   新闻列表表格优化
   =========================== */
.news-table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0.75rem 1.5rem rgba(18,38,63,.03);
}

.news-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.news-table thead th {
    border: none;
    padding: 15px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
}

.news-table tbody tr:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

/* 新闻缩略图 */
.news-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.news-thumbnail-placeholder {
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 24px;
}

.news-title-cell {
    display: flex;
    align-items: center;
    gap: 15px;
}

.news-title-info {
    flex: 1;
}

.news-title {
    font-weight: 500;
    color: #32325d;
    margin-bottom: 4px;
    line-height: 1.4;
}

.news-title mark {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
}

/* 分类标签 */
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.category-badge.category-company {
    background: #e3f2fd;
    color: #1976d2;
}

.category-badge.category-industry {
    background: #f3e5f5;
    color: #7b1fa2;
}

.category-badge.category-product {
    background: #e8f5e9;
    color: #388e3c;
}

.category-badge.category-technology {
    background: #fff3e0;
    color: #f57c00;
}

.category-badge.category-event {
    background: #fce4ec;
    color: #c2185b;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.status-published {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-draft {
    background: #fff3cd;
    color: #856404;
}

.status-badge.status-archived {
    background: #f8d7da;
    color: #721c24;
}

/* 统计信息 */
.news-stats {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: #6c757d;
}

.news-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===========================
   搜索和筛选区域
   =========================== */
.news-toolbar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 0.75rem 1.5rem rgba(18,38,63,.03);
}

.news-search-box {
    position: relative;
}

.news-search-box input {
    padding-left: 40px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.news-search-box input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.news-search-box::before {
    content: '\F52A'; /* Bootstrap Icons search */
    font-family: 'Bootstrap Icons';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
}

/* 搜索建议 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.search-suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-suggestion-item:hover {
    background: #f8f9fa;
}

.search-suggestion-item mark {
    background: #fff3cd;
    font-weight: 600;
}

/* 筛选器 */
.news-filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    margin: 0;
}

.filter-group select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 6px 30px 6px 12px;
    font-size: 14px;
}

/* ===========================
   新闻编辑器样式
   =========================== */
.news-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

/* Quill富文本编辑器样式优化 */
#newsContentEditor {
    overflow: hidden;
}

#newsContentEditor .ql-container {
    overflow-x: hidden;
    word-wrap: break-word;
}

#newsContentEditor .ql-editor {
    overflow-x: hidden;
    word-wrap: break-word;
}

/* 确保编辑器中的图片不会超出容器 */
#newsContentEditor .ql-editor img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 10px auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 确保编辑器容器本身不会溢出 */
#newsContentEditor .ql-container,
#newsContentEditor .ql-editor {
    max-width: 100%;
    box-sizing: border-box;
}

/* 处理可能存在的内联样式覆盖 */
#newsContentEditor .ql-editor img[style*="width"],
#newsContentEditor .ql-editor img[style*="height"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

.news-editor-container {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.news-editor-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.news-editor-body {
    padding: 20px;
}

.editor-toolbar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    padding: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editor-toolbar button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.editor-toolbar button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.editor-content {
    min-height: 300px;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 15px;
    font-size: 16px;
    line-height: 1.6;
}

.editor-content:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 图片上传区域 */
.image-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.image-upload-area:hover {
    border-color: #667eea;
    background: #f8f9fa;
}

.image-upload-area.dragging {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.image-preview {
    max-width: 100%;
    max-height: 200px;
    margin-top: 15px;
    border-radius: 8px;
}

/* 自动保存指示器 */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInRight 0.3s ease;
    z-index: 1000;
}

.auto-save-indicator.saving {
    background: #ffc107;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.auto-save-indicator.saving::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* ===========================
   批量操作栏
   =========================== */
.batch-actions-bar {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

.batch-actions-bar.hidden {
    display: none;
}

.batch-selection-info {
    font-size: 14px;
    color: #6c757d;
}

.batch-selection-info strong {
    color: #667eea;
    font-weight: 600;
}

.batch-action-buttons {
    display: flex;
    gap: 10px;
}

/* ===========================
   空状态样式
   =========================== */
.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-state i {
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-state h5 {
    color: #6c757d;
    margin-bottom: 10px;
}

.empty-state p {
    color: #adb5bd;
    margin-bottom: 20px;
}

/* ===========================
   骨架屏样式
   =========================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.skeleton-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
}

.skeleton-text {
    height: 16px;
    border-radius: 4px;
}

.skeleton-badge {
    width: 80px;
    height: 24px;
    border-radius: 12px;
}

.skeleton-actions {
    width: 100px;
    height: 30px;
    border-radius: 4px;
}

/* ===========================
   动画效果
   =========================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* ===========================
   响应式布局
   =========================== */
@media (max-width: 1200px) {
    .news-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group select {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .news-table {
        font-size: 14px;
    }
    
    .news-thumbnail {
        width: 40px;
        height: 40px;
    }
    
    .news-title-cell {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .batch-actions-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .batch-action-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .news-editor-container {
        width: 95%;
        border-radius: 0;
        max-height: 100vh;
    }
}

@media (max-width: 576px) {
    .news-table thead {
        display: none;
    }
    
    .news-table tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 15px;
    }
    
    .news-table tbody td {
        display: block;
        text-align: left;
        padding: 5px 0;
        border: none;
    }
    
    .news-table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 10px;
        color: #6c757d;
    }
}