/* ============================================================
   FTLS — Flight Training Learning System
   Dark cockpit-friendly theme with iOS safe-area support
   ============================================================ */

:root {
  --bg: #0a0a0f;
  --bg-card: #14141e;
  --bg-elevated: #1e1e2e;
  --accent: #4a9eff;
  --accent-warn: #ffaa00;
  --accent-danger: #ff3b30;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --text-faint: #55556a;
  --border: #2a2a3e;
  --tab-h: 72px;
  --header-h: 52px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- App shell ---- */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---- Top header bar ---- */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#page-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
}

/* ---- Main scrollable view ---- */
#view {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top));
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg);
}

/* ---- Bottom tab bar ---- */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

/* ---- Tab buttons ---- */
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 8px 4px;
}

.tab:active {
  opacity: 0.7;
}

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

.tab-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.tab-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1;
}

/* ---- View placeholder (stub screens) ---- */
.view-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 2rem;
  text-align: center;
}

.view-placeholder p {
  color: var(--text-dim);
  font-size: 1rem;
}

/* ---- Error state ---- */
.error-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--accent-danger);
  font-size: 0.9rem;
  text-align: center;
}

/* ---- Utility: Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

/* ---- Utility: Scrollbar (non-iOS) ---- */
#view::-webkit-scrollbar {
  width: 4px;
}
#view::-webkit-scrollbar-track {
  background: transparent;
}
#view::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
