/* ============================================
   TRAIN HVPT — Design Tokens + Base Styles
   ============================================ */

:root {
  /* Brand colours */
  --blue: #003E63;
  --blue-light: #005a8f;
  --blue-dark: #002d49;
  --red: #ad0005;
  --red-light: #d4000a;
  --red-dark: #8a0004;
  --white: #FFFFFF;
  --off-white: #F5F5F5;
  --gray-50: #FAFAFA;
  --gray-100: #F0F0F0;
  --gray-200: #E0E0E0;
  --gray-300: #CCCCCC;
  --gray-400: #999999;
  --gray-500: #666666;
  --gray-600: #444444;
  --gray-700: #333333;
  --gray-800: #222222;
  --gray-900: #111111;

  --teal: #0D9488;
  --teal-light: #14b8a6;
  --teal-dark: #0a7a70;

  /* Semantic colours */
  --green: #1B9E3E;
  --green-light: #E8F5EC;
  --amber: #E6960A;
  --amber-light: #FFF8E8;
  --danger: #DC2626;
  --danger-light: #FEE2E2;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* App-specific */
  --nav-height: 64px;
  --header-height: 56px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 1.75rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* ============================================
   Reset
   ============================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--gray-800);
  background-color: var(--off-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Prevent background scroll when modals are open (iOS scroll-through fix) */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--blue);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
}

/* ============================================
   Base Typography
   ============================================ */

h1, h2, h3, h4 {
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  color: var(--gray-900);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-base); font-weight: var(--font-weight-semibold); }

p {
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

/* ============================================
   App Layout
   ============================================ */

.app-body {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-md);
  background: var(--white);
  color: var(--blue);
  border-bottom: 1px solid var(--gray-200);
}

.app-header__logo {
  height: 32px;
}

.app-header__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--blue);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.app-header__action:hover {
  background: var(--gray-100);
}

.app-header__action svg {
  width: 22px;
  height: 22px;
}

#appView {
  padding: var(--space-md);
  overflow-x: hidden;
}

/* ============================================
   Auth Layout
   ============================================ */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--white);
  padding: var(--space-2xl) var(--space-md);
}

.auth-logo {
  width: 120px;
  margin-bottom: var(--space-lg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-title {
  text-align: center;
  margin-bottom: var(--space-xs);
  color: var(--blue);
}

.auth-subtitle {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: var(--space-xl);
  font-size: var(--font-size-sm);
}

/* ============================================
   Utilities
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-muted { color: var(--gray-500); }
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
