/* ═══ 全局组件样式 ═══ */

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  font-weight: 500;
  transition: all var(--transition-fast);
  user-select: none;
  gap: var(--space-xs);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:active { background: var(--color-primary-dark); }

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

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: var(--space-xs) var(--space-sm);
}

.btn-large {
  width: 100%;
  height: 80px;
  font-size: var(--fs-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  font-size: var(--fs-xl);
  margin-right: var(--space-xs);
}

/* ── 输入框 ── */
.form-input,
.form-select {
  width: 100%;
  height: var(--touch-min);
  padding: 0 var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  background: var(--color-bg-white);
  transition: border var(--transition-fast);
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}
.form-input.error {
  border-color: var(--color-danger);
}
.form-error-text {
  color: var(--color-danger);
  font-size: var(--fs-sm);
  margin-top: var(--space-xs);
}

/* ── 表单组 ── */
.form-group {
  margin-bottom: var(--space-lg);
}
.form-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

/* ── 卡片 ── */
.card {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}
.toast {
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: var(--fs-md);
  text-align: center;
  white-space: nowrap;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); color: var(--color-text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal / Sheet ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 960px;
  padding: var(--space-xl);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0));
  animation: sheetUp 0.3s ease;
}
.modal-sheet-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-lg);
}
.modal-sheet-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}
.modal-sheet-actions .btn { flex: 1; }

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── 搜索栏（全局底部） ── */
.global-search-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 960px;
  background: var(--color-bg-white);
  z-index: 150;
  border-top: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-lg);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0));
}
.global-search-bar.hidden { display: none; }
.global-search-bar input {
  width: 100%;
  height: var(--touch-min);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-size: var(--fs-md);
  outline: none;
}

.search-results {
  max-height: 50vh;
  overflow-y: auto;
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-top: var(--space-xs);
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.search-result-item:active { background: var(--color-bg); }

/* ── 提醒面板 ── */
.reminder-panel { margin-bottom: var(--space-xl); }
.reminder-panel:empty { display: none; }

.reminder-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  border-left: 4px solid;
}
.reminder-danger  { border-color: var(--color-danger); background: #FFF1F0; }
.reminder-warning { border-color: var(--color-warning); background: #FFFBE6; }
.reminder-info    { border-color: var(--color-primary); background: #E6F0FA; }

/* ── 骨架屏 ── */
.skeleton {
  background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 空状态 ── */
.empty-state {
  text-align: center;
  padding: var(--space-xxl) var(--space-lg);
  color: var(--color-text-secondary);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-lg);
}
.empty-state-text {
  font-size: var(--fs-md);
  margin-bottom: var(--space-lg);
}

/* ── 标签/Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.badge-danger  { background: #FFF1F0; color: var(--color-danger); }
.badge-warning { background: #FFFBE6; color: #D48806; }
.badge-normal  { background: #F0F0F0; color: var(--color-text-secondary); }

/* ── 折叠面板 ── */
.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
}
.collapse-body { display: none; }
.collapse-body.open { display: block; }

/* ── 余量选择器 ── */
.quantity-selector {
  display: flex;
  gap: var(--space-sm);
}
.quantity-btn {
  flex: 1;
  height: var(--touch-min);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.quantity-btn.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}
.quantity-btn:active { border-color: var(--color-primary); }

/* ── 勾选框行 ── */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
