/* Neumorphism Theme Variables */
:root {
  --neu-bg: #e0e5ec;
  --neu-shadow-dark: #b8bcc2;
  --neu-shadow-light: #ffffff;
  --neu-text-primary: #2d3748;
  --neu-text-secondary: #718096;
  --neu-text-muted: #a0aec0;
  --neu-accent: #667eea;
}

[data-theme="dark"] {
  --neu-bg: #1e1e2e;
  --neu-shadow-dark: #15151f;
  --neu-shadow-light: #27273d;
  --neu-text-primary: #cdd6f4;
  --neu-text-secondary: #6c7086;
  --neu-text-muted: #45475a;
  --neu-accent: #89b4fa;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  /* iOS scroll fix: ensure document is always scrollable */
  min-height: calc(100% + 1px);
  scroll-behavior: auto; /* Disable smooth scroll for iOS compatibility */
}

body {
  height: 100%;
  /* iOS WebView scroll fix: allow vertical scroll, block horizontal only */
  overflow-x: hidden;
  overflow-y: hidden; /* Scroll happens in .app-container */
  -webkit-overflow-scrolling: touch;
}

body {
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
}

/* App Container */
.app-container {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  /* iOS momentum scrolling */
  -webkit-overflow-scrolling: touch;
}

/* Screen Base */
.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screen-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--tg-theme-text-color);
}

.screen-subtitle {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  margin-bottom: 24px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--tg-theme-button-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: #ffffff;
  margin-top: 16px;
  font-size: 16px;
}

.loading-progress {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

.loading-progress.hidden {
  display: none;
}

.progress-bar {
  height: 100%;
  background: var(--tg-theme-button-color);
  width: 0%;
  transition: width 0.3s ease;
}

/* Error Toast */
.error-toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 16px;
  right: 16px;
  background: var(--tg-theme-destructive-text-color);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 1001;
  animation: slideUp 0.3s ease;
}

.error-toast.hidden {
  display: none;
}

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

/* Utility */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-hint {
  color: var(--tg-theme-hint-color);
}
