/* =====================================================
   公共基础样式 - 全站通用
   包含：字体、重置、背景层、通用组件、CSS变量
   ===================================================== */

/* -------------------- CSS 变量 -------------------- */
:root {
    /* 主色调 - 蓝色系 */
    --primary: #4798E5;
    --primary-dark: #3A80C7;
    --primary-light: #6AB0F0;
    --primary-bg: rgba(71, 152, 229, 0.1);

    /* 功能色 */
    --danger: #EF4444;
    --danger-dark: #DC2626;
    --success: #10B981;
    --warning: #F59E0B;

    /* 文字色 */
    --text-primary: rgba(31, 41, 55, 1);
    --text-secondary: rgba(75, 85, 99, 1);
    --text-muted: rgba(107, 114, 128, 1);
    --text-light: rgba(156, 163, 175, 1);

    /* 背景色 */
    --bg-page: rgba(220, 230, 249, 0.75);
    --bg-overlay: rgba(255, 255, 255, 0.497);
    --bg-card: rgba(255, 255, 255, 0.613);
    --bg-card-solid: rgba(255, 255, 255, 0.95);
    --bg-input: rgba(255, 255, 255, 0.8);
    --bg-hover: rgba(71, 152, 229, 0.05);

    /* 边框 */
    --border-light: rgba(255, 255, 255, 0.586);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(71, 152, 229, 1);

    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-primary: 0 4px 12px rgba(71, 152, 229, 0.35);

    /* 间距 */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* -------------------- 字体 -------------------- */
@font-face {
    font-family: 'Kosugi Maru';
    src: url('/assets/fonts/main-font.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* -------------------- 基础重置 -------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Kosugi Maru', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    min-width: 100vw;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* -------------------- 背景层 -------------------- */
.beijing {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    pointer-events: none;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-overlay);
    z-index: -1;
}

.background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-page);
    z-index: -1;
}

/* -------------------- 通用工具类 -------------------- */
.hidden {
    display: none !important;
}

/* -------------------- 页面头部 -------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px 20px;
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-light);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: color 0.2s ease, background-color 0.2s ease;
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.back-link:hover {
    color: var(--primary-dark);
    background-color: var(--primary-bg);
}

/* -------------------- 通用按钮 -------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

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

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.btn-primary:hover {
    box-shadow: var(--shadow-primary);
}

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

.btn-danger:hover {
    background-color: var(--danger-dark);
}

.btn-secondary {
    background-color: rgba(243, 244, 246, 1);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: rgba(229, 231, 235, 1);
}

/* 图标按钮 */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon-edit {
    background-color: var(--primary-bg);
    color: var(--primary);
}

.btn-icon-edit:hover {
    background-color: rgba(71, 152, 229, 0.2);
}

.btn-icon-delete {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.btn-icon-delete:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* -------------------- 通用表单 -------------------- */
.form-group {
    margin-bottom: 16px;
}

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

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-input);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(71, 152, 229, 0.15);
}

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

/* -------------------- 通用卡片容器 -------------------- */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-light);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* -------------------- 通用表格 -------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--primary-bg);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 2px solid var(--border-light);
}

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

.data-table tbody tr:hover {
    background-color: var(--bg-hover);
}

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

/* -------------------- 通用弹窗 -------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background-color: var(--bg-card-solid);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-light);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-default);
}

.modal-text {
    padding: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* -------------------- 通用空状态/加载 -------------------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(71, 152, 229, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* -------------------- 响应式 -------------------- */
@media (max-width: 768px) {
    .page-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-title {
        order: -1;
        width: 100%;
        margin-bottom: 4px;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
}
