/* Global CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand Colors (from logo) */
  --primary-color: #00233c;      /* Dark navy blue from logo */
  --primary-dark: #001829;       /* Darker navy for hovers */
  --accent-color: #f38d4b;       /* Orange checkmark from logo */

  /* Semantic Colors */
  --secondary-color: #64748b;    /* Gray/neutral actions */
  --success-color: #10b981;      /* Green for success states */
  --warning-color: #f59e0b;      /* Orange for warnings */
  --error-color: #ef4444;        /* Red for errors */

  /* Background Colors */
  --background-color: #ffffff;   /* Main background */
  --surface-color: #f8fafc;      /* Cards, elevated surfaces */

  /* Text Colors */
  --text-primary: #1e293b;       /* Main text */
  --text-secondary: #64748b;     /* Secondary/muted text */
  --text-light: #94a3b8;         /* Light/disabled text */

  /* Borders */
  --border-color: #cbd2db;       /* Standard borders */
  --border-light: #f1f5f9;       /* Lighter borders */

  /* Design Tokens */
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;

  /* Spacing */
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;    /* 8px */
  --spacing-md: 1rem;      /* 16px */
  --spacing-lg: 1.5rem;    /* 24px */
  --spacing-xl: 2rem;      /* 32px */
  --spacing-2xl: 3rem;     /* 48px */

  /* Breakpoint */
  --breakpoint-mobile: 768px;

  /* Responsive spacing */
  --padding-mobile: 0.5rem;
  --padding-desktop: 1rem;
  --gap-mobile: 0.5rem;
  --gap-desktop: 2rem;

  /* iOS Safe Areas */
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);

  /* Form Field Widths */
  --form-field-max-width: 500px;      /* Standard input max width on desktop */
  --form-field-small-max-width: 200px; /* For short inputs (times, numbers) */
  --form-field-medium-max-width: 350px; /* For medium inputs (names, etc) */

  /* Help Content Colors */
  --help-bg-color: #eff6ff;           /* Light blue background */
  --help-border-color: #bfdbfe;       /* Blue border */
  --help-title-color: var(--primary-color);
  --help-text-color: var(--text-secondary);
  --help-example-bg: #f8fafc;         /* Light gray for code examples */

  /* Alert Box Colors */
  --alert-info-bg: #eff6ff;
  --alert-info-border: #bfdbfe;
  --alert-info-text: #1e40af;

  --alert-warning-bg: #fef3c7;
  --alert-warning-border: #fbbf24;
  --alert-warning-text: #92400e;

  --alert-error-bg: #fee2e2;
  --alert-error-border: #ef4444;
  --alert-error-text: #991b1b;

  --alert-success-bg: #f0fdf4;
  --alert-success-border: #bbf7d0;
  --alert-success-text: #065f46;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
    monospace;
}

/* Layout utilities */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.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-4 {
  gap: 1rem;
}

.gap-8 {
  gap: 2rem;
}

/* Spacing utilities */
.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.m-4 {
  margin: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-8 {
  margin-top: 2rem;
}

/* Typography */
.text-center {
  text-align: center;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.text-xl {
  font-size: 1.25rem;
  line-height: 1.75rem;
}

.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

/* Cards and surfaces */
.card {
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.surface {
  background-color: var(--surface-color);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

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

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

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

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

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

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

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
select.form-input,
textarea.form-input {
  width: 100%;
  padding: 0.75rem;
  min-height: 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  background-color: var(--background-color);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

/* Extra right padding for select dropdowns to accommodate arrow */
select.form-input {
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.form-input:focus,
select.form-input:focus,
textarea.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(0 35 60 / 0.1);
}

.form-input:disabled,
select.form-input:disabled,
textarea.form-input:disabled {
  background-color: var(--surface-color);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Semantic width classes for form inputs */
.form-input-small {
  max-width: var(--form-field-small-max-width);  /* 200px */
}

.form-input-medium {
  max-width: var(--form-field-medium-max-width);  /* 350px */
}

.form-input-full {
  max-width: var(--form-field-max-width);  /* 500px */
}

/* Mobile: override max-widths, let fields stretch */
@media (max-width: 768px) {
  .form-input-small,
  .form-input-medium,
  .form-input-full {
    max-width: 100%;
  }
}

/* Loading and states */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

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

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 0 0.5rem;
  }

  .card {
    margin: 0.5rem;
  }

  /* Responsive utility classes */
  .hide-mobile {
    display: none !important;
  }

  .stack-mobile {
    flex-direction: column !important;
  }

  /* Touch-friendly interactive elements */
  button,
  .btn,
  a.btn,
  input[type="submit"],
  input[type="button"] {
    min-height: 40px;  /* Apple HIG + WCAG AAA */
    min-width: 40px;
  }

  /* Form inputs - also prevents iOS zoom on focus */
  input,
  select,
  textarea {
    min-height: 40px;
    font-size: 16px; /* ≥16px prevents iOS Safari auto-zoom */
  }

  /* Ensure links are tappable */
  a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  /* Table action buttons */
  td button,
  td a {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
}

/* Navigation Tab States - Use !important to override dark mode extensions */
.nav-tab-base {
  border-bottom: 2px solid transparent !important;
}

.nav-tab-active {
  border-bottom: 2px solid var(--primary-color) !important;
}