/* ============================================================
   common.css — 全站公共样式
   依赖: basic.css（CSS 变量定义）
   ============================================================ */

/* ── 全局重置 ────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
}

/* ── 字体导入 ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');
@import url('/static/toast.css');

/* ── Body 基础 ────────────────────────────────────────────── */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(at 0% 0%, rgba(128, 128, 128, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(128, 128, 128, 0.03) 0px, transparent 50%);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.5s ease, color 0.5s ease;
}

.dark body {
    background-image:
        radial-gradient(at 0% 0%, rgba(255, 255, 255, 0.02) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(255, 255, 255, 0.02) 0px, transparent 50%);
}

/* ── 滚动条 ───────────────────────────────────────────────── */
body::-webkit-scrollbar {
    width: 6px;
}

body::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── 字体辅助类 ───────────────────────────────────────────── */
.font-serif {
    font-family: 'Playfair Display', serif;
}

/* ── 毛玻璃效果 ───────────────────────────────────────────── */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.glass:hover {
    background: var(--glass-hover);
}

/* ── 主题过渡 ─────────────────────────────────────────────── */
.theme-transition {
    transition: background-color 0.5s ease, color 0.5s ease,
                border-color 0.5s ease, box-shadow 0.5s ease;
}

/* ── 按钮系统 ─────────────────────────────────────────────── */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(128, 128, 128, 0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background-color: var(--accent-bg);
    color: var(--accent-text);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px var(--shadow-color);
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    transform: translateY(-2px);
}

.btn-danger {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.btn-danger:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

/* ── 滚动进度条 ───────────────────────────────────────────── */
#scrollProgress {
    background: linear-gradient(90deg, var(--text-muted), var(--text-primary));
}

/* ── 加载动画 ─────────────────────────────────────────────── */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 小尺寸 spinner（用于按钮内联）*/
.loading-spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Modal 对话框 ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 480px;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1);
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

/* ── GSAP 入场动画初始状态 ────────────────────────────────── */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
}

/* ── 输入框下划线样式（create/edit 共用）────────────────────── */
.input-underline {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.input-underline:focus {
    border-bottom-color: var(--border-focus);
    border-bottom-width: 2px;
}

.input-underline::placeholder {
    color: var(--text-muted);
}

select.input-underline {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23737373' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
    padding-right: 20px;
}

/* ── 卡片字段（create/edit 共用）──────────────────────────── */
.field-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 16px;
    position: relative;
    transition: all 0.4s cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
    touch-action: pan-y;
}

.field-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -15px var(--shadow-color);
    border-color: rgba(128, 128, 128, 0.3);
    background: var(--glass-hover);
}

.field-card.sortable-ghost {
    opacity: 0.3;
    background: linear-gradient(135deg, var(--info-bg) 0%, transparent 100%);
    border: 2px dashed var(--info-text);
    transform: scale(0.98);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.field-card.sortable-drag {
    opacity: 0.95;
    transform: scale(1.03) rotate(1deg);
    box-shadow:
        0 25px 50px -12px var(--shadow-color),
        0 0 0 1px rgba(128, 128, 128, 0.1);
    cursor: grabbing;
    z-index: 1000;
    animation: dragPulse 2s ease-in-out infinite;
}

.field-card.sortable-drag::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

@keyframes dragPulse {
    0%, 100% { box-shadow: 0 25px 50px -12px var(--shadow-color); }
    50%       { box-shadow: 0 30px 60px -15px var(--shadow-color), 0 0 20px rgba(128, 128, 128, 0.1); }
}

@media (hover: none) and (pointer: coarse) {
    .field-card.sortable-drag {
        opacity: 0.98;
        transform: scale(1.02);
        box-shadow: 0 20px 40px -10px var(--shadow-color);
        animation: none;
    }
}

/* ── 拖拽手柄 ─────────────────────────────────────────────── */
.drag-handle {
    cursor: grab;
    padding: 8px;
    margin: -8px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.drag-handle:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

.drag-handle:active {
    cursor: grabbing;
    transform: scale(0.95);
}

@media (hover: none) and (pointer: coarse) {
    .drag-handle {
        padding: 12px;
        margin: -12px;
    }

    .drag-handle svg {
        width: 20px;
        height: 20px;
    }
}

/* ── 自定义 Checkbox ──────────────────────────────────────── */
.checkbox-custom {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-custom:checked {
    background-color: var(--accent-bg);
    border-color: var(--accent-bg);
}

.checkbox-custom:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: 2px solid var(--accent-text);
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* ── 导航栏链接（面包屑风格）──────────────────────────────── */
.nav-link {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.2s;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--text-primary);
}
