/* Reusable UI Components - sanfen-h5-native */

/* ========================================
   Tab Bar
   ======================================== */
#tab-bar-container {
  position: fixed;
  bottom: calc(var(--space-md) + var(--safe-bottom));
  left: var(--space-lg);
  right: var(--space-lg);
  height: var(--tab-bar-height);
  max-width: 382px;
  margin: 0 auto;
  z-index: 100;
  pointer-events: none;
}

.tab-bar {
  width: 100%;
  height: 100%;
  background: #ffffff; /* fallback for browsers without backdrop-filter */
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-tab-bar);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 var(--space-sm);
  pointer-events: auto;
}

.tab-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px; /* 3px is intentional for compact icon-label spacing */
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  flex: 1;
  transition: color var(--transition-fast);
  background: none;
  border: none;
}

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

.tab-bar__icon {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-bar__fab {
  position: relative;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(140deg, var(--fab-start) 0%, var(--fab-mid) 50%, var(--fab-end) 100%);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--fab-offset);
  border: none;
  cursor: pointer;
  /* Multi-layer shadow: notch ring cutout + key shadow + ambient + inner top highlight + inner bottom depth */
  box-shadow:
    0 0 0 4px var(--bg),
    0 10px 24px -6px rgba(37, 99, 235, 0.55),
    0 4px 8px -2px rgba(37, 99, 235, 0.25),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    inset 0 -3px 6px rgba(29, 78, 216, 0.3);
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar__fab::before {
  /* Soft outer glow halo */
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.35) 0%, rgba(59, 130, 246, 0) 70%);
  z-index: -1;
  opacity: 0.6;
  filter: blur(6px);
  animation: fab-pulse 2.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes fab-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.08);
  }
}

.tab-bar__fab svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
  position: relative;
  z-index: 1;
  transition: transform 200ms ease;
}

.tab-bar__fab:active {
  transform: scale(0.92);
  box-shadow:
    0 0 0 4px var(--bg),
    0 6px 14px -4px rgba(37, 99, 235, 0.45),
    0 2px 4px -1px rgba(37, 99, 235, 0.2),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(29, 78, 216, 0.25);
}

.tab-bar__fab:active::before {
  animation: none;
  opacity: 0.3;
}

.tab-bar__fab:active svg {
  transform: scale(0.9);
}

@media (prefers-reduced-motion: reduce) {
  .tab-bar__fab::before {
    animation: none;
  }
  .tab-bar__fab {
    transition: none;
  }
}

/* ========================================
   Toast
   ======================================== */
#toast-container {
  position: fixed;
  top: max(calc(var(--space-xl) + var(--safe-top)), 60px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--text-on-primary);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  pointer-events: auto;
  max-width: min(320px, calc(100vw - var(--space-xl)));
  text-align: center;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   Skeleton
   ======================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 0%,
    var(--skeleton-shine) 50%,
    var(--border) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton--text {
  height: 1em;
  margin-bottom: var(--space-xs);
}

.skeleton--title {
  height: 1.2em;
  width: 60%;
  margin-bottom: var(--space-sm);
}

.skeleton--card {
  height: 80px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.skeleton--circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton--list {
  height: 48px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

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

.empty-state__icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-md);
  color: var(--neutral);
}

.empty-state__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-xs);
}

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

.empty-state__action {
  padding: var(--space-sm) var(--space-lg);
  background: var(--primary);
  color: var(--text-on-primary);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: background var(--transition-fast);
}

.empty-state__action:active {
  background: var(--primary-dark);
}

/* ========================================
   Captcha Modal (短信发送前验证)
   ======================================== */
.captcha-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: captcha-modal-fade-in 0.2s ease;
}
@keyframes captcha-modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.captcha-modal__panel {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 12px;
  padding: 20px 20px 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  animation: captcha-modal-pop 0.2s ease;
}
@keyframes captcha-modal-pop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.captcha-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #1E293B);
  margin-bottom: 6px;
}
.captcha-modal__desc {
  font-size: 13px;
  color: #64748B;
  margin-bottom: 14px;
  line-height: 1.5;
}
.captcha-modal__desc strong {
  color: var(--text-primary, #1E293B);
  font-weight: 600;
}
.captcha-modal__row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.captcha-modal__input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  color: var(--text-primary, #1E293B);
  outline: none;
}
.captcha-modal__input:focus {
  border-color: var(--primary, #3B82F6);
}
.captcha-modal__img-wrap {
  position: relative;
  width: 120px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border, #E2E8F0);
  background: #F8FAFC;
}
.captcha-modal__img {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  object-fit: contain;
  opacity: 1;
  transition: opacity 0.15s;
}
.captcha-modal__img--loading {
  opacity: 0.3;
}
.captcha-modal__refresh {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #475569;
  line-height: 1;
  padding: 0;
}
.captcha-modal__refresh:hover {
  background: #fff;
  color: var(--primary, #3B82F6);
}
.captcha-modal__msg {
  font-size: 12px;
  color: #EF4444;
  min-height: 16px;
  margin-bottom: 4px;
  line-height: 1.4;
}
.captcha-modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.captcha-modal__btn {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.captcha-modal__btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.captcha-modal__btn--ghost {
  background: #F1F5F9;
  color: #475569;
}
.captcha-modal__btn--ghost:hover {
  background: #E2E8F0;
}
.captcha-modal__btn--primary {
  background: var(--primary, #3B82F6);
  color: #fff;
}
.captcha-modal__btn--primary:hover {
  background: var(--primary-dark, #2563EB);
}
