/* ============================================
   隐私保护 App - Components
   可复用组件样式库
   ============================================ */

/* ── Tab Bar ── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-bg-card);
  border-top: 0.5px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  z-index: var(--z-sticky);
}

.tab-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 6px;
  gap: 2px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  transition: color var(--duration-fast);
  text-decoration: none;
}

.tab-bar__item--active {
  color: var(--color-primary);
}

.tab-bar__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.tab-bar__label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
}

/* ── Card ── */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card--shadow {
  box-shadow: var(--shadow-sm);
}

.card__header {
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--color-border);
}

.card__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.card__body {
  padding: var(--space-lg);
}

/* ── List Group ── */
.list-group {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-group__title {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  padding: var(--space-xxl) var(--space-lg) var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.list-group__title:first-child {
  padding-top: var(--space-lg);
}

.list-item {
  display: flex;
  align-items: center;
  min-height: var(--list-item-height);
  padding: var(--space-md) var(--space-lg);
  gap: var(--space-md);
  transition: background var(--duration-fast);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.list-item:active {
  background: var(--color-bg-hover);
}

.list-item + .list-item {
  border-top: 0.5px solid var(--color-border);
  margin-left: var(--space-lg);
  padding-left: 0;
}

.list-item--no-indent + .list-item--no-indent {
  margin-left: 0;
  padding-left: var(--space-lg);
}

.list-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.list-item__icon--primary { background: var(--color-primary-light); color: var(--color-primary); }
.list-item__icon--danger { background: var(--color-danger-light); color: var(--color-danger); }
.list-item__icon--success { background: var(--color-success-light); color: var(--color-success); }
.list-item__icon--warning { background: var(--color-warning-light); color: var(--color-warning); }
.list-item__icon--neutral { background: #F5F5F5; color: var(--color-text-secondary); }

.list-item__content {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
  line-height: var(--line-height-tight);
}

.list-item__subtitle {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  margin-top: 2px;
  line-height: var(--line-height-tight);
}

.list-item__value {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.list-item__chevron {
  width: 16px;
  height: 16px;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  font-size: 14px;
}

.list-item__chevron::after {
  content: '›';
  font-size: 18px;
  font-weight: 300;
  color: var(--color-text-tertiary);
}

.list-item--danger .list-item__title {
  color: var(--color-danger);
}

/* ── Button ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--btn-height);
  padding: 0 var(--space-xxl);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  transition: all var(--duration-fast);
  gap: var(--space-sm);
  width: 100%;
  white-space: nowrap;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn--primary:active {
  background: var(--color-primary-active);
}

.btn--secondary {
  background: var(--color-bg-card);
  color: var(--color-primary);
  border: 1px solid var(--color-border-strong);
}
.btn--secondary:active {
  background: var(--color-bg-hover);
}

.btn--danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}
.btn--danger:active {
  background: var(--color-danger-active);
}

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

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

.btn--text-danger {
  background: transparent;
  color: var(--color-danger);
  height: auto;
  padding: var(--space-sm) var(--space-md);
}

.btn--sm {
  height: var(--btn-height-sm);
  font-size: var(--font-size-base);
  padding: 0 var(--space-lg);
  border-radius: var(--radius-sm);
}

.btn--block {
  width: 100%;
}

.btn--round {
  border-radius: var(--radius-full);
}

.btn-group {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
}

.btn-group--vertical {
  flex-direction: column;
}

.btn-group .btn {
  flex: 1;
}

/* ── Input ── */
.input-field {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--space-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast);
}

.input-field:focus {
  border-color: var(--color-primary);
}

.input-field::placeholder {
  color: var(--color-text-placeholder);
}

.input-field--search {
  background: #EFEFF0;
  border: none;
  border-radius: var(--radius-md);
  padding-left: 36px;
  font-size: var(--font-size-base);
  height: 36px;
}

.search-box {
  position: relative;
}

.search-box__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  font-size: 14px;
}

.textarea-field {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
  resize: none;
  line-height: var(--line-height-normal);
}

.textarea-field:focus {
  border-color: var(--color-primary);
}

/* ── Toggle Switch ── */
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle__slider {
  position: absolute;
  inset: 0;
  background: #E5E5EA;
  border-radius: 16px;
  cursor: pointer;
  transition: background var(--duration-normal);
}

.toggle__slider::before {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.toggle input:checked + .toggle__slider {
  background: var(--color-primary);
}

.toggle input:checked + .toggle__slider::before {
  transform: translateX(20px);
}

/* ── Chip / Tag ── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  background: #EFEFF0;
  color: var(--color-text-primary);
  gap: var(--space-xs);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.chip--active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.chip--sm {
  height: 26px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-sm);
}

.chip-group {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm) 0;
  -webkit-overflow-scrolling: touch;
}

.chip-group::-webkit-scrollbar { display: none; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

.badge--primary { background: var(--color-primary); color: white; }
.badge--danger { background: var(--color-danger); color: white; }
.badge--success { background: var(--color-success); color: white; }
.badge--warning { background: var(--color-warning); color: white; }
.badge--neutral { background: #EFEFF0; color: var(--color-text-secondary); }

.badge--dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
  border-radius: 50%;
}

/* ── Progress Bar ── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal);
}

.progress--lg { height: 8px; }

/* ── Segmented Control ── */
.segment-control {
  display: flex;
  background: #EFEFF0;
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 0;
}

.segment-control__item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 6px;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  transition: all var(--duration-normal);
  cursor: pointer;
}

.segment-control__item--active {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Bottom Sheet ── */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: var(--color-mask);
  z-index: var(--z-mask);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}

.sheet-mask.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  background: var(--color-bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: var(--z-sheet);
  padding-bottom: var(--safe-bottom);
  transition: transform var(--duration-slow) var(--ease-out);
  box-shadow: var(--shadow-sheet);
}

.bottom-sheet.active {
  transform: translateX(-50%) translateY(0);
}

.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  margin: var(--space-sm) auto var(--space-lg);
}

.bottom-sheet__header {
  padding: 0 var(--space-lg) var(--space-md);
  border-bottom: 0.5px solid var(--color-border);
}

.bottom-sheet__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.bottom-sheet__subtitle {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.bottom-sheet__body {
  padding: var(--space-lg);
}

.bottom-sheet__footer {
  padding: var(--space-lg);
  border-top: 0.5px solid var(--color-border);
}

/* ── Modal / Dialog ── */
.modal-mask {
  position: fixed;
  inset: 0;
  background: var(--color-mask);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxxl);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}

.modal-mask.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 320px;
  padding: var(--space-xxl);
  text-align: center;
  transform: scale(0.9);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.modal-mask.active .modal {
  transform: scale(1);
}

.modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-sm);
}

.modal__body {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-xl);
}

.modal__actions {
  display: flex;
  gap: var(--space-md);
}

.modal__actions--vertical {
  flex-direction: column;
}

/* ── Info Card ── */
.info-card {
  background: var(--color-primary-light);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  font-size: var(--font-size-md);
  color: var(--color-primary);
  line-height: var(--line-height-normal);
}

.info-card--warning {
  background: var(--color-warning-light);
  color: #D48806;
}

.info-card--danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.info-card__icon {
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 1px;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxxl) var(--space-xl);
  text-align: center;
}

.empty-state__icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--color-text-tertiary);
}

.empty-state__title {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state__desc {
  font-size: var(--font-size-md);
  color: var(--color-text-tertiary);
  line-height: var(--line-height-relaxed);
}

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.stepper__btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: #EFEFF0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-text-primary);
}

.stepper__value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  min-width: 32px;
  text-align: center;
}

/* ── Slider ── */
.range-slider {
  width: 100%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* ── Hint / Note ── */
.hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  padding: var(--space-sm) var(--space-lg);
}

.hint--danger {
  color: var(--color-danger);
}

/* ── Avatar / Thumbnail ── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: #EFEFF0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: var(--color-text-secondary);
  overflow: hidden;
}

.avatar--sm { width: 32px; height: 32px; font-size: 14px; }
.avatar--lg { width: 56px; height: 56px; font-size: 24px; }
.avatar--xl { width: 72px; height: 72px; font-size: 32px; }
.avatar--square { border-radius: var(--radius-md); }

/* ── Grid (Photo Grid) ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.photo-grid__item {
  aspect-ratio: 1;
  background: #EFEFF0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.photo-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-grid__item--selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--color-primary);
}

.photo-grid__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* ── Floating Action Button ── */
.fab {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 16px);
  right: calc(50% - 215px + 16px);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  transition: transform var(--duration-fast);
}

.fab:active {
  transform: scale(0.92);
}

/* ── Section ── */
.section {
  margin-bottom: var(--space-xxl);
}

.section__title {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  padding: 0 var(--space-xs);
  margin-bottom: var(--space-sm);
}

/* ── Checkbox ── */
.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}

.checkbox input {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox input:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox input:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* ── Radio ── */
.radio-item {
  display: flex;
  align-items: center;
  padding: var(--space-md) 0;
  gap: var(--space-md);
  cursor: pointer;
}

.radio-dot {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.radio-dot--active {
  border-color: var(--color-primary);
}

.radio-dot--active::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Toolbar (Bottom) ── */
.toolbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--color-bg-card);
  border-top: 0.5px solid var(--color-border);
  padding: var(--space-sm) var(--space-lg) calc(var(--space-sm) + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: var(--z-sticky);
}

.toolbar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs);
  font-size: 20px;
  color: var(--color-text-secondary);
}

.toolbar__btn--active {
  color: var(--color-primary);
}

/* ── Status Chip ── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.status-chip--idle { background: #EFEFF0; color: var(--color-text-secondary); }
.status-chip--active { background: var(--color-success-light); color: var(--color-success); }
.status-chip--warning { background: var(--color-warning-light); color: #D48806; }
.status-chip--error { background: var(--color-danger-light); color: var(--color-danger); }

.status-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Strength Bar ── */
.strength-bar {
  display: flex;
  gap: 4px;
  height: 4px;
}

.strength-bar__segment {
  flex: 1;
  border-radius: var(--radius-full);
  background: var(--color-border);
}

.strength-bar--weak .strength-bar__segment:nth-child(1) { background: var(--color-danger); }
.strength-bar--medium .strength-bar__segment:nth-child(-n+2) { background: var(--color-warning); }
.strength-bar--strong .strength-bar__segment:nth-child(-n+3) { background: var(--color-success); }
.strength-bar--very-strong .strength-bar__segment { background: var(--color-success); }

/* ── PIN Input ── */
.pin-input {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  transition: all var(--duration-fast);
}

.pin-dot--filled {
  background: var(--color-text-primary);
  border-color: var(--color-text-primary);
}

/* ── Keypad (Calculator / PIN) ── */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 340px;
  margin: 0 auto;
}

.keypad__key {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  background: var(--color-bg-card);
  font-size: var(--font-size-xxl);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  transition: background var(--duration-fast);
  user-select: none;
}

.keypad__key:active {
  background: var(--color-bg-hover);
}

.keypad__key--op {
  background: #F0F0F0;
  color: var(--color-text-primary);
}

.keypad__key--equals {
  background: var(--color-primary);
  color: white;
}

.keypad__key--zero {
  grid-column: span 2;
}

/* ── QR Code placeholder ── */
.qr-placeholder {
  width: 160px;
  height: 160px;
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  font-size: 48px;
  color: var(--color-text-tertiary);
}

/* ── Animation utility ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.animate-slide-up {
  animation: slideUp var(--duration-slow) var(--ease-out);
}

.animate-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}
