/* ========== EMS 后台管理面板 - 响应式样式 ========== */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --text: #1e293b;
    --text-muted: #64748b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.10);
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

/* ========== Admin Layout ========== */
.admin-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.admin-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.admin-brand .badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary);
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-nav a {
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.admin-nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

.admin-nav a.active {
    color: var(--primary);
    background: var(--primary-light);
}

.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

/* ========== Page Header ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

/* ========== Card ========== */
.card-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* ========== Article Table ========== */
.article-list-wrap {
    overflow-x: auto;
}

.article-table {
    width: 100%;
    border-collapse: collapse;
}

.article-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.article-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.article-table tr:last-child td {
    border-bottom: none;
}

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

.thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
}

.type-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.type-badge.article {
    background: var(--success-light);
    color: var(--success);
}

.type-badge.link {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.status-badge.published {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.draft {
    background: var(--bg);
    color: var(--text-muted);
}

.action-group {
    display: flex;
    gap: 6px;
}

.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-message p {
    margin-bottom: 16px;
    font-size: 1rem;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.form-label .required {
    color: var(--danger);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row > .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ========== Cover Preview ========== */
.cover-preview {
    margin-top: 8px;
}

.cover-preview img {
    width: 200px;
    height: 113px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ========== Radio Group ========== */
.radio-group {
    display: flex;
    gap: 16px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-weight: 500;
}

.radio-item:hover {
    border-color: var(--primary);
}

.radio-item input {
    margin: 0;
}

.radio-item.checked {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ========== Alert ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid #fde68a;
}

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.login-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .admin-header-inner {
        padding: 0 16px;
        height: 52px;
    }

    .admin-brand {
        font-size: 1rem;
    }

    .admin-brand .badge {
        display: none;
    }

    .admin-nav a {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .admin-main {
        padding: 16px 14px 48px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .article-table {
        font-size: 0.8rem;
    }

    .article-table th {
        padding: 8px 10px;
    }

    .article-table td {
        padding: 8px 10px;
    }

    .thumb,
    .thumb-placeholder {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .hide-mobile {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .login-box {
        padding: 28px 24px;
    }

    .login-title {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .action-group {
        flex-direction: column;
        gap: 4px;
    }

    .radio-group {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========== Pinned Badge / Category / Tags ========== */
.pinned-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f59e0b;
    color: #fff;
    letter-spacing: 0.5px;
}
.cat-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: #ede9fe;
    color: #7c3aed;
}
.tag-label {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Category management item */
.cat-item {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.cat-item form { flex: 1; display: flex; gap: 8px; align-items: center; }
.cat-item .btn { flex-shrink: 0; }

/* Categories layout */
@media (max-width: 768px) {
    .cats-layout {
        grid-template-columns: 1fr !important;
    }
}

/* ========== Quill 编辑器适配 ========== */
.ql-toolbar {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
    border-bottom: none !important;
}

.ql-container {
    border: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
    font-family: inherit !important;
    font-size: 0.9rem !important;
}

.ql-editor {
    min-height: 300px;
    line-height: 1.7;
}

.ql-editor img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.ql-editor h2 { font-size: 1.4rem; margin: 16px 0 8px; }
.ql-editor h3 { font-size: 1.2rem; margin: 14px 0 6px; }
.ql-editor blockquote {
    border-left: 4px solid var(--primary);
    padding: 8px 16px;
    margin: 12px 0;
    color: var(--text-muted);
}

/* 降级 textarea 模式 */
#content.form-textarea {
    min-height: 300px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
}

/* ========== 编辑器扩展工具栏 ========== */
.editor-extra-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.btn-toggle-mode,
.btn-insert-code {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-toggle-mode:hover,
.btn-insert-code:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.btn-toggle-mode.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-toggle-mode svg,
.btn-insert-code svg {
    flex-shrink: 0;
}

/* HTML 源码编辑器样式 */
#html-source-editor {
    width: 100%;
    min-height: 300px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.7;
    tab-size: 2;
    resize: vertical;
    outline: none;
}
#html-source-editor:focus {
    border-color: var(--primary);
}

/* Quill 编辑器内代码块预览 */
.ql-editor pre.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px 20px;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    margin: 12px 0;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.84rem;
    white-space: pre;
}

/* ========== 后台导航更多项 ========== */
.admin-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ========== 响应式补充 ========== */
@media (max-width: 768px) {
    .admin-nav {
        gap: 2px;
    }
    .admin-nav a {
        padding: 4px 6px;
        font-size: 0.72rem;
    }
}

@media (max-width: 600px) {
    /* 轮播图/导航管理双栏变单栏 */
    .card-box + .card-box,
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    .admin-brand .badge { display: none; }
    .admin-nav a { font-size: 0.7rem; padding: 3px 5px; }
}

/* ========== Quill 工具栏自定义按钮图标 ========== */
.ql-toolbar .ql-frame-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ql-toolbar .ql-frame-btn::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 3px;
    box-sizing: border-box;
}
.ql-toolbar .ql-frame-btn.ql-active::before {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.08);
}

/* 表格按钮 */
.ql-toolbar .ql-table-btn,
.ql-toolbar .ql-video-btn,
.ql-toolbar .ql-audio-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ql-toolbar .ql-table-btn::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23443' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='1'/%3E%3Cline x1='3' y1='9' x2='21' y2='9'/%3E%3Cline x1='3' y1='15' x2='21' y2='15'/%3E%3Cline x1='9' y1='3' x2='9' y2='21'/%3E%3Cline x1='15' y1='3' x2='15' y2='21'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* 视频按钮 */
.ql-toolbar .ql-video-btn::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23443' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='23 7 16 12 23 17 23 7'/%3E%3Crect x='1' y='5' width='15' height='14' rx='2' ry='2'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* 音频按钮 */
.ql-toolbar .ql-audio-btn::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23443' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18V5l12-2v13'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Ccircle cx='18' cy='16' r='3'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Quill 编辑器内框架预览 */
.ql-editor .content-frame {
    border: 2px solid #b8a07a;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 16px 0;
    background: #faf8f5;
}

/* Quill 颜色选择器适配 */
.ql-toolbar.ql-snow .ql-color-picker {
    width: 28px;
    height: 28px;
}
