/* ============================================================
   Lframe v3.1.0 - Luopu Framework
   原生 CSS · 零依赖 · 主题化 · 响应式 · 强大的可访问性
   全新一代架构
   作者：@Chenianlaocu | 洛璃科技设计团队洛浦瑟湾
   官网：https://hiluoli.cn/LframeNG
   ============================================================ */

/* ==================== 1. 设计 Token ==================== */
:root {
  /* 品牌色 */
  --primary: #1565c0;
  --primary-hover: #0d47a1;
  --primary-light: #80b3e5;
  --primary-rgb: 21, 101, 192;

  /* 语义色 */
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --info: #2196f3;
  --success-rgb: 76, 175, 80;
  --warning-rgb: 255, 152, 0;
  --error-rgb: 244, 67, 54;
  --info-rgb: 33, 150, 243;

  /* 文本 / 背景 / 表面 / 边框 */
  --text: #222222;
  --text-light: #666666;
  --text-faint: #888888;
  --bg: #cfdff5;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --surface-hover: #fafafa;
  --border: #dddddd;
  --border-strong: #c5c5c5;

  /* 几何 */
  --radius: 4px;
  --radius-sm: 3px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* 阴影 */
  --shadow: 0 2px 4px rgba(0, 0, 0, .1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .15);

  /* 动效 */
  --ease: cubic-bezier(.25, .1, .25, 1);
  --duration-fast: .16s;
  --duration: .25s;

  /* 层级 */
  --z-dropdown: 900;
  --z-drawer: 1000;
  --z-modal: 1100;
  --z-toast: 1200;
  --z-alert: 1300;

  /* 字体（系统字体栈，不加载字体文件） */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 保留旧变量名，避免已有页面主题覆盖失效 */
  --alert-bg: #ffffff;
  --alert-border: #e0e0e0;
  --alert-title: #1a1a1a;
  --alert-content: #333333;

  /* 可选玻璃增强 token（随主题变化，仅 .glass-subtle 使用） */
  --glass-bg: rgba(255, 255, 255, .45);
  --glass-border: rgba(255, 255, 255, .5);
}

/* ==================== 2. 主题覆盖 ==================== */

/* 系统暗色偏好（手动亮色时排除） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #e0e0e0;
    --text-light: #aaaaaa;
    --text-faint: #8d99a6;
    --bg: #1a2a3d;
    --surface: #1e2d40;
    --surface-muted: #24364b;
    --surface-hover: #28405a;
    --border: #334455;
    --border-strong: #496078;
    --primary: #42a5f5;
    --primary-hover: #90caf9;
    --primary-light: #90caf9;
    --shadow: 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-lg: 0 6px 16px rgba(0, 0, 0, .4);
    --alert-bg: #1e2d40;
    --alert-border: #334455;
    --alert-title: #e0e0e0;
    --alert-content: #aaaaaa;
    --glass-bg: rgba(30, 45, 64, .5);
    --glass-border: rgba(255, 255, 255, .12);
    color-scheme: dark;
  }
}

/* 手动暗色主题（优先级高于系统偏好） */
:root[data-theme="dark"] {
  --text: #e0e0e0;
  --text-light: #aaaaaa;
  --text-faint: #8d99a6;
  --bg: #1a2a3d;
  --surface: #1e2d40;
  --surface-muted: #24364b;
  --surface-hover: #28405a;
  --border: #334455;
  --border-strong: #496078;
  --primary: #42a5f5;
  --primary-hover: #90caf9;
  --primary-light: #90caf9;
  --shadow: 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, .4);
  --alert-bg: #1e2d40;
  --alert-border: #334455;
  --alert-title: #e0e0e0;
  --alert-content: #aaaaaa;
  --glass-bg: rgba(30, 45, 64, .5);
  --glass-border: rgba(255, 255, 255, .12);
  color-scheme: dark;
}

/* 手动亮色主题（压过系统暗色偏好） */
:root[data-theme="light"] { color-scheme: light; }

/* ==================== 3. Reset 与基础元素 ==================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--primary-hover); }

button, input, select, textarea { font: inherit; color: inherit; }

hr {
  border: none;
  height: 1px;
  margin: var(--sp-5) 0;
  background: var(--border);
}

::selection {
  background: rgba(var(--primary-rgb), .22);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* ==================== 4. 容器、Flex、Grid ==================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; justify-content: center; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--sp-4);
}

/* ==================== 5. 排版 ==================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  margin: var(--sp-4) 0 var(--sp-2);
  font-weight: 500;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
p { margin: var(--sp-3) 0; font-size: 1rem; }
.flow-text { font-size: 2rem; font-weight: 300; margin: 0; }
small { font-size: .875rem; color: var(--text-light); }

code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 2px 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

pre {
  margin: var(--sp-4) 0;
  padding: var(--sp-4);
  overflow-x: auto;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  line-height: 1.7;
}
pre code {
  background: none;
  border: none;
  padding: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-light { color: var(--text-light); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

/* ==================== 6. 按钮与交互状态 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 var(--sp-4);
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition:
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform var(--duration-fast) var(--ease);
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

/* 尺寸 */
.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: .84rem; }
.btn-lg { min-height: 44px; padding: 0 var(--sp-5); font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }

/* 变体 */
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(var(--primary-rgb), .1); }

/* 加载态（不依赖 JS） */
.btn-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  animation: lf-spin .7s linear infinite;
}
@keyframes lf-spin {
  to { transform: rotate(360deg); }
}

/* ==================== 7. 表单控件与验证状态 ==================== */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 10px;
  margin: var(--sp-2) 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), .2);
}
textarea {
  resize: vertical;
  min-height: 80px;
}

/* 只读 */
input[readonly],
textarea[readonly] { background: var(--surface-muted); }

/* 禁用 */
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--surface-muted);
  cursor: not-allowed;
  opacity: .7;
}

/* 占位符 */
::placeholder { color: var(--text-faint); opacity: 1; }

/* 验证状态（!important 保证聚焦时错误色仍可见） */
.is-invalid,
[aria-invalid="true"] { border-color: var(--error) !important; }
.is-invalid:focus,
[aria-invalid="true"]:focus { box-shadow: 0 0 0 2px rgba(var(--error-rgb), .2); }
.is-valid { border-color: var(--success); }
.is-valid:focus { box-shadow: 0 0 0 2px rgba(var(--success-rgb), .2); }

/* 原生 Checkbox / Radio（保留键盘与高对比度支持） */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  margin: 0 var(--sp-2) 0 0;
  cursor: pointer;
  accent-color: var(--primary);
}
label { display: inline-flex; align-items: center; cursor: pointer; }

/* ==================== 8. 卡片、面板和表面 ==================== */
.card,
.card-panel {
  background: var(--surface);
  padding: 20px;
  margin: var(--sp-4) 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow var(--duration) var(--ease);
}
.card:hover,
.card-panel:hover { box-shadow: var(--shadow-lg); }

.card-panel .date {
  display: block;
  font-weight: bold;
  color: var(--text-light);
  margin-bottom: var(--sp-2);
  font-size: .9rem;
}
.card-panel p { font-size: 1.4rem; margin: var(--sp-3) 0; }
.card-panel a { color: var(--primary); font-weight: 500; }

/* 仅显式声明可交互的卡片才启用 hover */
.card-interactive {
  transition: box-shadow var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}

/* ==================== 9. 通知、徽章和标签 ==================== */
.notification {
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-3) 0;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: var(--radius);
  font-weight: 500;
}
.success {
  color: var(--success);
  background: rgba(var(--success-rgb), .12);
  border-color: var(--success);
}
.error {
  color: var(--error);
  background: rgba(var(--error-rgb), .12);
  border-color: var(--error);
}
.warning {
  color: var(--warning);
  background: rgba(var(--warning-rgb), .12);
  border-color: var(--warning);
}
.info {
  color: var(--info);
  background: rgba(var(--info-rgb), .12);
  border-color: var(--info);
}

/* 标签（实心，非玻璃） */
.label {
  display: inline-block;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.6;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  vertical-align: middle;
}
.label-success { background: var(--success); }
.label-warning { background: var(--warning); color: #222; }
.label-error { background: var(--error); }
.label-info { background: var(--info); }

/* ==================== 10. 列表与表格 ==================== */
ul {
  list-style: none;
  padding: 0;
  margin: var(--sp-4) 0;
}
ul li {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
ul li:last-child { border-bottom: none; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-4) 0;
}
table th,
table td {
  padding: var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table th {
  background: var(--surface-muted);
  font-weight: 500;
  color: var(--text);
}
table tr:hover td { background: var(--surface-hover); }

/* ==================== 11. 模态框 ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(0, 0, 0, .5);
}
.modal.active { display: flex; }

.modal-content {
  width: min(90vw, 420px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  padding: var(--sp-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: lf-modal-in var(--duration) var(--ease);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.modal-title { font-size: 1.25rem; font-weight: 500; }
.close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-light);
}
.close:hover { color: var(--text); }
.close:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}
@keyframes lf-modal-in {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ==================== 12. 友好点击、分页、进度 ==================== */
.friendly-click {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-drawer);
}
.friendly-click a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  font-size: 1.2rem;
  transition: background var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}
.friendly-click a:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.pagination {
  display: flex;
  gap: var(--sp-1);
  margin: var(--sp-4) 0;
  list-style: none;
  padding: 0;
}
.pagination-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.pagination-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.pagination-item[aria-current="page"],
.pagination-item.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.progress {
  width: 100%;
  height: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: var(--sp-3) 0;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  width: var(--progress, 25%);
  transition: width var(--duration) var(--ease);
}

/* ==================== 13. 工具类 ==================== */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: var(--sp-2); }
.mb-1 { margin-bottom: var(--sp-2); }
.mt-2 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-4); }
.mt-3 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-5); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.p-0 { padding: 0; }
.p-1 { padding: var(--sp-2); }
.p-2 { padding: var(--sp-4); }
.p-3 { padding: var(--sp-5); }
.round { border-radius: var(--radius); }
.round-lg { border-radius: var(--radius-lg); }
.round-full { border-radius: var(--radius-pill); }
.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }
.hidden { display: none; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.list-plain li { padding: 0; border-bottom: none; }

/* ==================== 14. 滚动条 ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ==================== 15. 兼容性降级与可选增强 ==================== */
/* 先给纯色降级，再在支持 backdrop-filter 时增强 */
.glass-subtle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
@supports (backdrop-filter: blur(1px)) {
  .glass-subtle {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
  }
}
/* 模态框遮罩模糊：仅作可选增强，不作为默认依赖 */
@supports (backdrop-filter: blur(1px)) {
  .modal { background: rgba(0, 0, 0, .4); }
  .modal { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
}

/* ==================== 16. 减少动态效果 ==================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== 17. 高对比度模式 ==================== */
@media (forced-colors: active) {
  .card, .card-panel, .btn, .notification, .modal-content, table {
    background: Canvas;
    color: CanvasText;
    border: 1px solid CanvasText;
    box-shadow: none;
  }
}

/* ==================== 18. 打印样式 ==================== */
@media print {
  *, *::before, *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  .modal, .friendly-click, .pagination { display: none !important; }
  .card, .card-panel, table, .notification {
    border: 1px solid #999;
    break-inside: avoid;
  }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: .85em;
    color: #555 !important;
  }
}

/* ==================== 19. 响应式 ==================== */
@media (max-width: 480px) {
  .container { padding: 0 var(--sp-3); }
  h1 { font-size: 1.875rem; }
  .btn { min-height: 40px; font-size: .875rem; padding: 0 var(--sp-3); }
  .card, .card-panel, .modal-content { padding: var(--sp-4); }
  .close { width: 40px; height: 40px; }
  .friendly-click { bottom: var(--sp-4); right: var(--sp-4); }
  .btn:hover, .card:hover, .card-panel:hover { transform: none; }
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
@media (min-width: 481px) and (max-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card, .card-panel { padding: var(--sp-4); }
}
@media (min-width: 769px) {
  .grid { gap: var(--sp-5); }
}
@media (hover: none) {
  .btn:hover, .card:hover, .card-panel:hover { transform: none; }
}

