/* ============================================
 公共样式 - 全局组件样式
 ============================================ */

/* 导入组件样式 */
/* 全局背景：跟随主题变量，兜底为浅色（系统默认浅色，防止白屏/闪烁）
   注意：这里不能写死颜色，否则会盖掉所有主题切换 */
html, body {
  background: var(--bg-primary, #ffffff) !important;
  color: var(--text-primary, #111827);
  min-height: 100vh;
  margin: 0;
  /* P1: 全站字体栈。此前 common.css 无任何 font-family，
     导致 16/36 页 body 回退到 Times New Roman / 宋体（衬线体）。
     emoji 回退不可省：本站大量使用 🌱 ⚠️ 📋 🔬 等图标字符。 */
  font-family: var(--font-sans,
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", "Source Han Sans SC",
    "Noto Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji");
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@import url('./header.css');
@import url('./footer.css');
@import url('./sidebar.css');

/* ===== Toast 提示 ===== */
:root {
 --toast-bg: var(--bg-card, #ffffff);
 --toast-border: var(--border-color, #e5e7eb);
 --toast-shadow: 0 8px 24px rgba(0,0,0,0.4);
 --toast-success: #10b981;
 --toast-error: #ef4444;
 --toast-warning: #f59e0b;
 --toast-info: #3b82f6;
}

.toast-container {
 position: fixed;
 bottom: 24px;
 right: 24px;
 z-index: 99999;
 display: flex;
 flex-direction: column;
 gap: 10px;
 pointer-events: none;
}

.toast {
 background: var(--toast-bg);
 color: var(--text-primary, #f0f4f8);
 padding: 12px 16px;
 border-radius: 8px;
 border-left: 4px solid var(--toast-info);
 box-shadow: var(--toast-shadow);
 font-size: 0.88rem;
 min-width: 240px;
 max-width: 380px;
 display: flex;
 align-items: center;
 gap: 10px;
 opacity: 0;
 transform: translateX(400px);
 transition: all 0.3s cubic-bezier(0.68, -0.15, 0.265, 1.2);
 pointer-events: all;
}

.toast.show {
 opacity: 1;
 transform: translateX(0);
}

.toast-success { border-left-color: var(--toast-success); }
.toast-error { border-left-color: var(--toast-error); }
.toast-warning { border-left-color: var(--toast-warning); }
.toast-info { border-left-color: var(--toast-info); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.5; }

.toast-loading { border-left-color: var(--toast-info); }
.toast-loading .toast-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
 .toast-container { bottom: 12px; right: 12px; left: 12px; }
 .toast { min-width: 0; max-width: 100%; }
}

/* ===== 确认对话框 ===== */
.modal-overlay-confirm {
 position: fixed;
 top: 0; left: 0; right: 0; bottom: 0;
 background: rgba(0,0,0,0.75);
 z-index: 99998;
 display: flex;
 align-items: center;
 justify-content: center;
 padding: 16px;
 opacity: 0;
 transition: opacity 0.25s;
}

.modal-overlay-confirm.show { opacity: 1; }

.modal-confirm-box {
 background: var(--bg-card, #ffffff);
 border: 1px solid var(--border-color, #e5e7eb);
 border-radius: 12px;
 padding: 28px;
 max-width: 400px;
 width: 100%;
 text-align: center;
 transform: scale(0.9);
 transition: transform 0.25s;
 box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-overlay-confirm.show .modal-confirm-box {
 transform: scale(1);
}

.modal-confirm-icon {
 font-size: 3rem;
 margin-bottom: 16px;
}

.modal-confirm-title {
 font-size: 1.2rem;
 font-weight: 600;
 margin-bottom: 10px;
 color: var(--text-primary, #f0f4f8);
}

.modal-confirm-msg {
 font-size: 0.9rem;
 color: var(--text-secondary, #a0aec0);
 line-height: 1.6;
 margin-bottom: 24px;
}

.modal-confirm-actions {
 display: flex;
 gap: 12px;
 justify-content: center;
}

.modal-confirm-actions .btn {
 flex: 1;
 justify-content: center;
 padding: 10px 16px;
 font-size: 0.9rem;
}

/* ===== 页面容器 ===== */
.page-wrapper {
 min-height: 100vh;
 display: flex;
 flex-direction: column;
}

.page-content {
 flex: 1;
 padding: 24px;
 max-width: 1400px;
 width: 100%;
 margin: 0 auto;
}

.main-content.has-sidebar {
 margin-left: 0;
 padding-left: 16px;
}

/* ===== 加载状态 ===== */
.loading-overlay {
 position: fixed;
 top: 0; left: 0; right: 0; bottom: 0;
 background: rgba(10,15,28,0.85);
 z-index: 99990;
 display: flex;
 align-items: center;
 justify-content: center;
 flex-direction: column;
 gap: 16px;
}

.loading-spinner {
 width: 48px;
 height: 48px;
 border: 3px solid var(--border-color, #e5e7eb);
 border-top-color: var(--accent-primary, #3b82f6);
 border-radius: 50%;
 animation: spin 0.8s linear infinite;
}

.loading-text {
 color: var(--text-secondary, #a0aec0);
 font-size: 0.9rem;
}

/* ===== 空状态 ===== */
.empty-state {
 text-align: center;
 padding: 60px 24px;
 color: var(--text-muted, #718096);
}

.empty-state-icon {
 font-size: 4rem;
 margin-bottom: 16px;
 opacity: 0.5;
}

.empty-state-title {
 font-size: 1.2rem;
 font-weight: 600;
 color: var(--text-secondary, #a0aec0);
 margin-bottom: 8px;
}

.empty-state-desc {
 font-size: 0.9rem;
 line-height: 1.6;
 max-width: 360px;
 margin: 0 auto 20px;
}

/* ===== 工具函数 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* 移动端隐藏 */
@media (max-width: 768px) {
 .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
 .hide-desktop { display: none !important; }
}
