/* --- 核心变量 (Modern Palette) --- */
:root {
  --primary: #3b82f6; 
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.08);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-bg: rgba(239, 68, 68, 0.05);
  --success: #10b981;
  
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  
  --text-main: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius: 16px;
  --radius-sm: 10px;
}

/* --- 全局重置 --- */
body {
  background-color: var(--bg-body);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; outline: none; }

/* 滚动条美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.container { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem 4rem; }

/* --- 顶部导航栏 --- */
.main-header {
  position: sticky; top: 1rem; z-index: 50;
  display: flex; justify-content: space-between; align-items: center; 
  margin-bottom: 2rem; padding: 0.75rem 1.5rem; 
  background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 99px;
  box-shadow: var(--shadow-md);
}
.main-header h2 { 
  margin: 0; font-size: 1.25rem; font-weight: 700; 
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 0.5rem; }

/* --- 卡片 --- */
.group-card {
  background: var(--bg-card); border-radius: var(--radius); 
  margin-bottom: 1rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: hidden; transition: all 0.2s ease;
}
.group-card:hover { box-shadow: var(--shadow-md); border-color: #d1d5db; transform: translateY(-1px); }

.group-card-header {
  display: flex; align-items: center; padding: 1.25rem 1.5rem;
  cursor: pointer; user-select: none;
}
.group-title { flex: 1; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 0.75rem; }
.id-badge { 
  font-size: 0.75rem; font-weight: 500; background: #f3f4f6; color: var(--text-secondary);
  padding: 0.2rem 0.6rem; border-radius: 6px; font-family: monospace;
}
.toggle-icon-wrap { margin-right: 1rem; color: var(--text-secondary); transition: transform 0.3s; display: flex; }
.group-card.expanded .toggle-icon-wrap { transform: rotate(90deg); color: var(--primary); }

.group-card-body {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: #fcfcfd; border-top: 1px solid transparent;
}
.group-card.expanded .group-card-body { max-height: 2000px; opacity: 1; padding: 1.5rem; border-color: var(--border); }

/* --- 输入框 --- */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 600; font-size: 0.85rem; color: #374151; }

input[type="text"], input[type="password"], input[type="time"], input[type="number"] {
  display: block; width: 100%; height: 42px; padding: 0 1rem;
  font-size: 0.95rem; color: var(--text-main); background: var(--bg-input);
  border: 1px solid transparent; border-radius: 10px; transition: all 0.2s;
  -webkit-appearance: none; appearance: none;
}
input[type="text"]:hover, input:hover { background: #fff; border-color: #d1d5db; }
input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* --- 开关控件 (Switch) - 样式优化版 --- */
.switch-grid { 
  display: grid; 
  /* 调整列宽，避免太窄导致文字拥挤 */
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
  gap: 0.75rem; 
}
.switch-label {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.75rem;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; user-select: none; transition: all 0.2s;
  max-width: 100%; /* 确保不超过父容器 */
}
.switch-label:hover { border-color: #d1d5db; background: #f9fafb; }
.switch-label.checked { background: var(--primary-light); border-color: var(--primary); }
.switch-label input { display: none; }

.slider-track {
  width: 32px; height: 18px; background: #e5e7eb; border-radius: 20px;
  position: relative; transition: 0.3s; flex-shrink: 0; /* 防止滑块被压缩 */
}
.slider-thumb {
  width: 14px; height: 14px; background: white; border-radius: 50%;
  position: absolute; top: 2px; left: 2px; transition: 0.3s; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch-label input:checked + .slider-track { background: var(--primary); }
.switch-label input:checked + .slider-track .slider-thumb { transform: translateX(14px); }

/* ★★★ 关键修改：文本截断 ★★★ */
.switch-text { 
  font-size: 0.85rem; 
  font-weight: 500; 
  /* 强制单行并显示省略号 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1; /* 占据剩余空间 */
  min-width: 0; /* 允许 Flex 子项收缩到内容以下 */
  color: var(--text-main);
}

/* --- 按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 40px; padding: 0 1.25rem; font-size: 0.9rem; font-weight: 600;
  border-radius: 99px; border: 1px solid transparent; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: linear-gradient(to right, #3b82f6, #2563eb); color: #fff; box-shadow: 0 2px 4px rgba(59,130,246,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(59,130,246,0.4); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text-main); }
.btn-secondary:hover { border-color: #d1d5db; background: #f9fafb; }

.btn-icon {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; transition: 0.2s;
}
.btn-icon:hover { background: rgba(0,0,0,0.05); color: var(--text-main); }
.btn-icon-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* --- 弹窗通用样式 --- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  z-index: 100; display: flex; justify-content: center; align-items: center;
  opacity: 0; visibility: hidden; transition: 0.3s;
}
.modal-mask.active { opacity: 1; visibility: visible; }

.modal {
  background: #fff; width: 95%; max-width: 520px; border-radius: 20px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  max-height: 85vh; transform: scale(0.95) translateY(10px); transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-mask.active .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.modal .close { font-size: 1.5rem; background: none; border: none; cursor: pointer; color: #9ca3af; padding: 0.5rem; line-height: 1; border-radius: 50%; }
.modal .close:hover { background: #f3f4f6; color: var(--text-main); }

.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-actions { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #f9fafb; display: flex; justify-content: flex-end; gap: 0.75rem; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }

/* --- 列表卡片 --- */
.list-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; margin-bottom: 0.75rem; position: relative;
  transition: border-color 0.2s;
}
.list-card:hover { border-color: #d1d5db; }

/* 时间段选择器 */
.time-range-group {
  display: flex; align-items: center; background: var(--bg-input);
  border-radius: 10px; padding: 2px; border: 1px solid transparent;
}
.time-range-group:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.time-range-group input { border: none !important; background: transparent !important; box-shadow: none !important; text-align: center; height: 38px; }
.time-separator { color: var(--text-secondary); font-weight: bold; padding: 0 0.5rem; }

/* 登录页 */
.login-body {
  background-color: #f3f4f6;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%), 
    radial-gradient(at 100% 100%, rgba(124, 58, 237, 0.1) 0px, transparent 50%);
  display: flex; justify-content: center; align-items: center; min-height: 100vh;
}
.login-container {
  width: 100%; max-width: 400px; padding: 3rem 2.5rem;
  background: #fff; border-radius: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.8);
  position: relative; overflow: hidden;
}
.login-container::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(to right, #3b82f6, #7c3aed);
}
.login-header { text-align: center; margin-bottom: 2.5rem; }
.login-logo {
  width: 64px; height: 64px; background: rgba(59, 130, 246, 0.1); color: var(--primary);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
}
.login-header h2 { margin: 0 0 0.5rem; font-size: 1.5rem; font-weight: 800; color: var(--text-main); }
.login-header p { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }
.login-footer { margin-top: 2rem; text-align: center; font-size: 0.85rem; color: #9ca3af; }
