/* X-Blog 完整样式 - 仿 X.com */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1d9bf0;
    --primary-hover: #1a8cd8;
    --bg-primary: #ffffff;
    --bg-secondary: #f7f9f9;
    --bg-hover: rgba(15, 20, 25, 0.03);
    --text-primary: #0f1419;
    --text-secondary: #536471;
    --border: #eff3f4;
    --border-strong: #cfd9de;
    --error: #f4212e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* 三栏布局 */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* 左侧导航栏 */
.sidebar {
    width: 275px;
    padding: 0 12px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 12px;
    font-size: 32px;
    color: var(--text-primary);
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 4px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px;
    border-radius: 9999px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 20px;
    transition: background 0.2s;
    margin: 4px 0;
}

.nav-item:hover {
    background: var(--bg-hover);
}

.nav-item.active {
    font-weight: 700;
}

.nav-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-post-btn {
    margin: 20px 0;
}

.btn-post {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    display: block;
    transition: background 0.2s;
}

.btn-post:hover {
    background: var(--primary-hover);
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 275px;
    margin-right: 350px;
    border-right: 1px solid var(--border);
    min-height: 100vh;
}

.content-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    z-index: 100;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    padding: 16px 0;
}

/* 分类标签栏 */
.category-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.category-tab {
    flex: 1;
    padding: 16px;
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
    transition: background 0.2s;
}

.category-tab:hover {
    background: var(--bg-hover);
}

.category-tab.active {
    color: var(--text-primary);
    font-weight: 700;
}

.category-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 4px;
    background: var(--primary);
    border-radius: 9999px;
}

/* 文章列表 */
.posts-feed {
    background: var(--bg-primary);
}

.post-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.post-card:hover {
    background: var(--bg-hover);
}

.post-card:last-child {
    border-bottom: none;
}

.post-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.post-author {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.post-category {
    color: var(--text-secondary);
    font-size: 15px;
}

.post-time {
    color: var(--text-secondary);
    font-size: 15px;
    margin-left: auto;
}

.post-title {
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 4px 0 12px;
}

/* 媒体网格 */
.post-media {
    margin: 12px 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
}

.post-media-grid {
    display: grid;
    gap: 2px;
}

.post-media-grid.single {
    grid-template-columns: 1fr;
}

.post-media-grid.double {
    grid-template-columns: repeat(2, 1fr);
}

.post-media-grid.triple {
    grid-template-columns: repeat(3, 1fr);
}

.post-media-grid.quad {
    grid-template-columns: repeat(2, 1fr);
}

.media-item {
    position: relative;
    background: var(--bg-secondary);
    overflow: hidden;
}

.media-item img,
.media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-item.single img,
.media-item.single video {
    max-height: 500px;
    object-fit: contain;
    background: #000;
}

/* 操作栏 */
.post-actions {
    display: flex;
    justify-content: space-between;
    max-width: 425px;
    margin-top: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 9999px;
    transition: color 0.2s, background 0.2s;
}

.action-btn:hover {
    color: var(--primary);
    background: rgba(29, 155, 240, 0.1);
}

/* 右侧边栏 */
.right-sidebar {
    width: 350px;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    padding: 12px 24px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
}

.search-box {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    padding-bottom: 12px;
    z-index: 10;
}

.search-input {
    width: 100%;
    padding: 12px 48px 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 9999px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.search-input:focus {
    background: var(--bg-primary);
    border-color: var(--primary);
}

/* 文章详情页 */
.post-detail {
    padding: 16px;
}

.post-detail-header {
    margin-bottom: 16px;
}

.post-detail-title {
    font-size: 23px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
}

.post-detail-meta {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 16px;
}

.post-detail-body {
    font-size: 15px;
    line-height: 1.625;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-detail-media {
    margin: 16px 0;
}

.post-detail-media img,
.post-detail-media video {
    max-width: 100%;
    border-radius: 16px;
    margin-bottom: 8px;
    display: block;
}

/* 登录页面 */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 40px;
}

.login-logo {
    font-size: 48px;
    text-align: center;
    margin-bottom: 32px;
}

.login-title {
    font-size: 31px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 17px;
    font-weight: 700;
}

.form-input {
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 17px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
}

.btn-login {
    padding: 16px;
    background: var(--text-primary);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-login:hover {
    background: #272c30;
}

/* 管理后台 */
.admin-container {
    margin-left: 275px;
    margin-right: 350px;
    padding: 16px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.admin-title {
    font-size: 20px;
    font-weight: 700;
}

.publish-form {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}

.form-field input[type="text"],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 17px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: var(--primary);
}

.form-field textarea {
    min-height: 150px;
    resize: vertical;
}

.file-upload {
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.file-upload input {
    display: none;
}

.uploaded-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.preview-item img,
.preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-publish {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-publish:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* 文章列表（管理后台） */
.posts-list {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.posts-list-header {
    padding: 16px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.post-list-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.post-list-item:hover {
    background: var(--bg-hover);
}

.post-list-item:last-child {
    border-bottom: none;
}

.post-list-info h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.post-list-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.post-list-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 16px;
    font-size: 13px;
}

/* 模式标签 */
.mode-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
}

.mode-tag.novel {
    background: #f91880;
    color: white;
}

.mode-tag.chapter {
    background: #7856ff;
    color: white;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 48px 16px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 31px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-desc {
    color: var(--text-secondary);
    font-size: 15px;
}

/* 消息提示 */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 15px;
    z-index: 1000;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 移动端底部导航 */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    z-index: 100;
}

.mobile-nav-item {
    flex: 1;
    text-align: center;
    padding: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 24px;
    transition: color 0.2s;
}

.mobile-nav-item.active {
    color: var(--primary);
}

/* 响应式 */
@media (max-width: 1280px) {
    .right-sidebar {
        display: none;
    }
    
    .main-content,
    .admin-container {
        margin-right: 0;
    }
}

@media (max-width: 1000px) {
    .sidebar {
        width: 88px;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .btn-post {
        padding: 12px;
        font-size: 0;
    }
    
    .btn-post::after {
        content: '+';
        font-size: 24px;
    }
    
    .main-content,
    .admin-container {
        margin-left: 88px;
    }
}

@media (max-width: 640px) {
    .sidebar {
        display: none;
    }
    
    .main-content,
    .admin-container {
        margin-left: 0;
    }
    
    .mobile-nav {
        display: flex;
    }
    
    body {
        padding-bottom: 60px;
    }
    
    .post-header {
        flex-direction: column;
        gap: 4px;
    }
    
    .post-time {
        margin-left: 0;
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}