/* ============================================================================
   AI & CG Daily News - 样式表
   ============================================================================ */

:root {
    /* 颜色系统 */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-hover: #22222e;

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    /* 间距 */
    --sidebar-width: 280px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================================
   布局
   ============================================================================ */

.app {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.nav-section {
    padding: 0 12px;
}

.nav-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-bottom: 4px;
}

.history-list {
    list-style: none;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--accent-glow);
    color: var(--accent-secondary);
    border-left: 2px solid var(--accent-primary);
}

.history-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.refresh-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.refresh-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.refresh-btn:active .refresh-icon {
    transform: rotate(180deg);
}

/* 主内容区 */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.header-content {
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.beijing-time {
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 500;
}

.date {
    color: var(--text-secondary);
    font-size: 14px;
}

.status {
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
}

.content-wrapper {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.content {
    max-width: 900px;
    margin: 0 auto;
}

/* ============================================================================
   Markdown 渲染样式
   ============================================================================ */

.content h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.content h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.content h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--accent-secondary);
}

.content p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.content blockquote {
    padding: 12px 20px;
    margin: 16px 0;
    border-left: 3px solid var(--accent-primary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.content a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.content a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* 表格 */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.content th {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-hover);
}

.content td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

/* 链接列（最后一列）右对齐 */
.content th:last-child,
.content td:last-child {
    text-align: right;
    white-space: nowrap;
}

.content tr:hover td {
    background: var(--bg-hover);
}

/* 新闻预览图 */
.content img {
    max-width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin: 4px 0 16px 16px;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 图片加载失败时隐藏 */
.content img[src=""] {
    display: none;
}

.content hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 32px 0;
}

/* ============================================================================
   加载动画
   ============================================================================ */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   空状态
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-desc {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================================================
   移动端菜单按钮
   ============================================================================ */

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.menu-btn:hover {
    background: var(--bg-hover);
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================================================
   响应式
   ============================================================================ */

@media (max-width: 768px) {
    .menu-btn {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .header-content {
        padding: 0 16px;
    }

    .page-title {
        font-size: 16px;
    }

    .date {
        display: none;
    }

    .content-wrapper {
        padding: 16px;
    }

    /* ======== 标题适配 ======== */
    .content h1 {
        font-size: 22px;
        line-height: 1.4;
        margin-bottom: 12px;
    }

    .content h2 {
        font-size: 17px;
        margin: 24px 0 12px;
        padding-bottom: 8px;
    }

    .content h3 {
        font-size: 15px;
        margin: 20px 0 10px;
    }

    /* ======== 段落和引用 ======== */
    .content p {
        font-size: 14px;
        line-height: 1.8;
    }

    .content blockquote {
        padding: 12px 14px;
        margin: 14px 0;
        font-size: 13px;
        line-height: 1.6;
    }

    /* ======== 表格 - 完整显示内容 ======== */
    .content table {
        display: block;
        overflow-x: auto;
        font-size: 13px;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
    }

    .content th,
    .content td {
        padding: 10px 12px;
        /* 允许换行，完整显示 */
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        line-height: 1.6;
        vertical-align: top;
    }

    /* 表头样式 */
    .content th {
        font-size: 12px;
        font-weight: 600;
    }

    /* 链接样式 - 强制单行 */
    .content td a {
        display: inline-block;
        padding: 4px 10px;
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
        font-size: 12px;
        white-space: nowrap;
        transition: background 0.2s ease;
    }

    .content td a:hover {
        background: var(--accent-glow);
    }

    /* 最后一列（链接列）强制单行 */
    .content td:last-child {
        white-space: nowrap;
    }

    /* ======== 空状态 ======== */
    .empty-state {
        padding: 48px 20px;
    }

    .empty-icon {
        font-size: 56px;
    }

    .empty-title {
        font-size: 18px;
    }

    .empty-desc {
        font-size: 14px;
        line-height: 1.6;
    }

    /* ======== 加载状态 ======== */
    .loading {
        padding: 60px 20px;
    }
}