/* ============================================
   AIDE Services — Design Tokens & Base Styles
   ============================================ */

:root {
  /* Colors - Design Tokens */
  --color-bg-primary: #87ceea;
  --color-primary: #5D5FEF;
  --color-emergency: #FF4B3E;
  --color-success: #4ADE80;
  --color-surface: #FFFFFF;
  --color-text-primary: #1A1A1A;
  --color-text-secondary: #4B5563;
  --color-border: #D1D5DB;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-h1: 1.5rem;    /* 24pt */
  --font-size-h2: 1.125rem;  /* 18pt */
  --font-size-body: 1rem;    /* 16pt */
  --font-size-small: 0.875rem; /* 14pt */
  --font-size-caption: 0.75rem; /* 12pt */
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-screen: 1.25rem; /* 20px horizontal padding */
  
  /* Border Radius */
  --radius-pill: 25px;
  --radius-card: 20px;
  --radius-input: 15px;
  --radius-sm: 8px;
  
  /* Shadows */
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.12);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App container */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background-color: var(--color-bg-primary);
}

/* ============================================
   Screen Container
   ============================================ */
.screen {
  padding: var(--spacing-screen);
  padding-bottom: 5rem; /* Space for bottom tab bar */
  min-height: 100vh;
  min-height: 100dvh;
}

.screen-no-tab {
  padding-bottom: var(--spacing-screen);
}

/* ============================================
   Typography
   ============================================ */
h1 {
  font-size: var(--font-size-h1);
  font-weight: 700;
  text-align: center;
}

h2 {
  font-size: var(--font-size-h2);
  font-weight: 700;
}

h3 {
  font-size: var(--font-size-body);
  font-weight: 600;
}

p {
  font-size: var(--font-size-small);
  color: var(--color-text-secondary);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-body);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px; /* Touch target */
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-emergency {
  background-color: var(--color-emergency);
  color: white;
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--color-primary);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--font-size-small);
  min-height: 40px;
}

/* ============================================
   Inputs
   ============================================ */
.input-group {
  position: relative;
  margin-bottom: var(--spacing-md);
}

.input-group .icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  width: 20px;
  height: 20px;
}

.input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-small);
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.2s ease;
  min-height: 48px; /* Touch target */
}

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

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

/* ============================================
   Cards
   ============================================ */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-card);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--spacing-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

/* ============================================
   Bottom Tab Bar
   ============================================ */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--color-surface);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem 0;
  padding-bottom: env(safe-area-inset-bottom, 0.5rem);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
  min-height: 60px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
  min-width: 48px;
  min-height: 48px;
  justify-content: center;
  background: none;
  border: none;
  font-family: inherit;
}

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

.tab-item svg {
  width: 24px;
  height: 24px;
}

/* ============================================
   Accordion
   ============================================ */
.accordion-item {
  background-color: var(--color-surface);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  cursor: pointer;
  min-height: 48px;
  font-weight: 600;
  font-size: var(--font-size-small);
}

.accordion-header svg {
  transition: transform 0.2s ease;
}

.accordion-header.open svg {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 1rem 1rem;
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  min-height: 48px;
}

.toggle {
  position: relative;
  width: 50px;
  height: 28px;
  background-color: var(--color-border);
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.toggle.active {
  background-color: var(--color-success);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle.active::after {
  transform: translateX(22px);
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: var(--spacing-lg);
}

.progress-step {
  flex: 1;
  height: 4px;
  background-color: var(--color-border);
  border-radius: 2px;
}

.progress-step.active {
  background-color: var(--color-primary);
}

/* ============================================
   Emergency Button
   ============================================ */
.emergency-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background-color: var(--color-emergency);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 20px rgba(255, 75, 62, 0.4);
  transition: transform 0.1s ease;
  min-width: 120px;
  min-height: 120px;
}

.emergency-btn:active {
  transform: scale(0.95);
}

.emergency-btn.pulsing {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 75, 62, 0.4); }
  50% { box-shadow: 0 4px 40px rgba(255, 75, 62, 0.8); }
}

.emergency-btn .countdown {
  font-size: 2rem;
  font-weight: 700;
}

/* ============================================
   Emergency Overlay
   ============================================ */
.emergency-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-emergency);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing-screen);
  text-align: center;
}

/* ============================================
   Map
   ============================================ */
.map-container {
  width: 100%;
  border-radius: var(--radius-card);
  overflow: hidden;
  height: 150px;
}

.map-container.full {
  height: calc(100vh - 8rem);
  height: calc(100dvh - 8rem);
  border-radius: 0;
}

/* ============================================
    Utilities
    ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.text-center { text-align: center; }
.text-sm { font-size: var(--font-size-small); }
.text-xs { font-size: var(--font-size-caption); }
.text-muted { color: var(--color-text-secondary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ============================================
    Font Size Scaling (Accessibility)
    ============================================ */
.font-size-large {
  font-size: 18px;
}
.font-size-large h1 {
  font-size: 1.75rem;
}
.font-size-large h2 {
  font-size: 1.3rem;
}
.font-size-large .btn {
  font-size: 1.1rem;
  min-height: 52px;
}
.font-size-large .input {
  font-size: 1rem;
  min-height: 52px;
}
.font-size-large .tab-item span,
.font-size-large .text-sm {
  font-size: 1rem;
}
.font-size-large .text-xs {
  font-size: 0.9rem;
}

.font-size-x-large {
  font-size: 20px;
}
.font-size-x-large h1 {
  font-size: 2rem;
}
.font-size-x-large h2 {
  font-size: 1.5rem;
}
.font-size-x-large .btn {
  font-size: 1.2rem;
  min-height: 56px;
}
.font-size-x-large .input {
  font-size: 1.1rem;
  min-height: 56px;
}
.font-size-x-large .tab-item span,
.font-size-x-large .text-sm {
  font-size: 1.1rem;
}
.font-size-x-large .text-xs {
  font-size: 1rem;
}
.font-size-x-large .emergency-btn {
  width: 140px;
  height: 140px;
  min-width: 140px;
  min-height: 140px;
}
.font-size-x-large .card {
  padding: 1.25rem;
}
.font-size-x-large .toggle {
  width: 56px;
  height: 32px;
}
.font-size-x-large .toggle::after {
  width: 28px;
  height: 28px;
}
.font-size-x-large .toggle.active::after {
  transform: translateX(24px);
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 0;
  background: transparent;
}

/* ============================================
   Animations
   ============================================ */
.fade-in {
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

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