/* Ability Plus Maintenance — Design System (legacy)
 * Phase 6 (L-UI-UNIFORM). Additive: complements existing per-page inline styles.
 * Provides: palette / typography baseline / utility classes / mobile + tablet basics / iOS safe-area-inset
 *
 * Existing per-page styles WIN over these (loaded first, inline styles override).
 * To opt into the design system: use .ap-* class names on new markup.
 */

/* === Color palette === */
:root {
  --ap-red: #be0707;
  --ap-red-bg: #b71c1c;   /* used by ticket email header */
  --ap-red-dark: #9b0606;
  --ap-text: #222222;
  --ap-text-muted: #555555;
  --ap-text-light: #888888;
  --ap-border: #e5e7eb;
  --ap-bg: #f4f6f8;
  --ap-card-bg: #ffffff;
  --ap-label-bg: #f9fafb;
  --ap-success: #218838;
  --ap-success-dark: #1c6f2d;
  --ap-error: #f8d7da;
  --ap-error-border: #f5c6cb;
  --ap-error-text: #721c24;
}

/* === Reset/normalize basics (minimal — don't disturb existing) === */
* { box-sizing: border-box; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* === Safe-area-inset for iPhone notch === */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .ap-header, .ap-page-header { padding-top: max(12px, env(safe-area-inset-top)); }
  .ap-footer, .ap-bottom-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* === Container widths === */
.ap-container { max-width: 720px; margin: 0 auto; padding: 16px; }
.ap-container-narrow { max-width: 520px; margin: 0 auto; padding: 16px; }
.ap-container-kiosk { max-width: 720px; margin: 0 auto; padding: 20px 16px; }

/* === Cards === */
.ap-card { background: var(--ap-card-bg); border: 1px solid var(--ap-border); border-radius: 12px; padding: 24px; box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.ap-card-header { font-size: 20px; font-weight: 700; color: var(--ap-text); margin: 0 0 12px; }

/* === Buttons === */
.ap-btn, .ap-btn-primary {
  display: inline-block;
  background: var(--ap-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 48px;
  line-height: 20px;
  text-align: center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.ap-btn:hover, .ap-btn:focus, .ap-btn-primary:hover, .ap-btn-primary:focus { background: var(--ap-red-dark); outline: none; }
.ap-btn-secondary { background: #e5e5e5; color: var(--ap-text); }
.ap-btn-secondary:hover, .ap-btn-secondary:focus { background: #d0d0d0; }
.ap-btn-success { background: var(--ap-success); color: #fff; }
.ap-btn-success:hover, .ap-btn-success:focus { background: var(--ap-success-dark); }
.ap-btn-block { display: block; width: 100%; }

/* === Form fields === */
.ap-form-group { margin: 0 0 16px; }
.ap-form-group label { display: block; margin: 0 0 6px; font-weight: 600; color: var(--ap-text); }
.ap-input, .ap-textarea, .ap-select {
  width: 100%; padding: 12px 14px;
  border: 1px solid #ccc; border-radius: 8px;
  font-size: 16px; /* 16px+ prevents iOS zoom-on-focus */
  font-family: inherit; color: var(--ap-text);
  background: #fff;
}
.ap-input:focus, .ap-textarea:focus, .ap-select:focus { outline: none; border-color: var(--ap-red); box-shadow: 0 0 0 3px rgba(190,7,7,0.15); }
.ap-hint { font-size: 13px; color: var(--ap-text-light); margin: 4px 0 0; }

/* === Alerts === */
.ap-alert { padding: 12px 16px; border-radius: 8px; margin: 0 0 12px; font-weight: 600; }
.ap-alert-info { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }
.ap-alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.ap-alert-error { background: var(--ap-error); color: var(--ap-error-text); border: 1px solid var(--ap-error-border); }

/* === Field grid (used in branded emails AND for read-only key-value displays) === */
.ap-field-grid { width: 100%; border-collapse: collapse; border: 1px solid var(--ap-border); }
.ap-field-grid th, .ap-field-grid td { padding: 10px 14px; border-bottom: 1px solid var(--ap-border); text-align: left; font-size: 14px; }
.ap-field-grid th { background: var(--ap-label-bg); font-weight: 700; color: var(--ap-text); width: 30%; }
.ap-field-grid tr:last-child th, .ap-field-grid tr:last-child td { border-bottom: 0; }

/* === Responsive: 8" tablet kiosk === */
@media (min-width: 720px) {
  .ap-input, .ap-textarea, .ap-select { font-size: 18px; padding: 14px 16px; }
  .ap-btn, .ap-btn-primary, .ap-btn-secondary { font-size: 17px; padding: 16px 32px; min-height: 52px; }
  .ap-container-kiosk { max-width: 720px; }
}

/* === Mobile === */
@media (max-width: 480px) {
  .ap-container, .ap-container-narrow, .ap-container-kiosk { padding: 12px; }
  .ap-card { padding: 20px 16px; border-radius: 8px; }
  .ap-btn, .ap-btn-primary, .ap-btn-secondary { font-size: 15px; padding: 12px 20px; min-height: 44px; }
}

/* === Print === */
@media print {
  .ap-btn, .ap-no-print { display: none; }
  .ap-card { box-shadow: none; border: 1px solid #999; }
}

/* === Brand header bar (matches ticket email red banner) === */
.ap-header-bar { background: var(--ap-red-bg); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.ap-header-bar img { height: 32px; width: auto; display: block; }
.ap-header-bar .title { color: #fff; font-weight: 700; font-size: 17px; flex: 1; text-align: center; }

/* === Footer bar === */
.ap-footer-bar { padding: 12px 16px; border-top: 1px solid var(--ap-border); background: var(--ap-label-bg); color: var(--ap-text-light); font-size: 12px; text-align: center; }

/* === Accessibility — visible focus === */
:focus-visible { outline: 2px solid var(--ap-red); outline-offset: 2px; }

/* === Touch target minimum (Apple HIG) === */
a, button, [role=button], input[type=submit], input[type=button] { min-height: 44px; }
@media (pointer: coarse) {
  a, button, [role=button] { min-height: 44px; }
}
