/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --aq-bg: #f4f6f8;
  --aq-surface: #ffffff;
  --aq-ink: #0f172a;
  --aq-muted: #64748b;
  --aq-border: #e2e8f0;
  --aq-accent: #0369a1;
  --aq-accent-ink: #ffffff;
  --aq-alert: #b91c1c;
  --aq-notice: #047857;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--aq-ink);
  background: var(--aq-bg);
  line-height: 1.5;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--aq-surface);
  border-bottom: 1px solid var(--aq-border);
}

.app-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--aq-accent);
  text-decoration: none;
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-user { color: var(--aq-muted); font-size: 0.85rem; }

.app-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--aq-border);
  color: var(--aq-ink);
}
.app-role--admin { background: #fde68a; }
.app-role--analyst { background: #bfdbfe; }
.app-role--field { background: #bbf7d0; }

.app-signout button,
.app-signout {
  border: 1px solid var(--aq-border);
  background: var(--aq-surface);
  color: var(--aq-ink);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash--alert { background: #fee2e2; color: var(--aq-alert); }
.flash--notice { background: #d1fae5; color: var(--aq-notice); }

.home h1 { margin-top: 0; }
.home__lead { font-size: 1.05rem; }
.home__muted { color: var(--aq-muted); }

/* Sign-in form (sessions/new, passwords) */
.auth-card {
  max-width: 360px;
  margin: 3rem auto;
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 1.5rem;
}
.auth-card h1 { margin-top: 0; font-size: 1.25rem; }
.auth-card input[type="email"],
.auth-card input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  margin: 0.35rem 0 0.9rem;
  border: 1px solid var(--aq-border);
  border-radius: 8px;
  font-size: 1rem;
}
.auth-card input[type="submit"] {
  width: 100%;
  padding: 0.65rem;
  background: var(--aq-accent);
  color: var(--aq-accent-ink);
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
.auth-card a { color: var(--aq-accent); }

/* Header nav */
.app-nav { margin-right: auto; margin-left: 1rem; }
.app-nav__link {
  color: var(--aq-ink);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
.app-nav__link:hover { background: var(--aq-border); }

/* Page headers */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head--sub { margin-top: 2rem; align-items: center; }
.page-head--sub h2 { margin: 0; font-size: 1.2rem; }
.breadcrumb { margin: 0 0 0.25rem; font-size: 0.85rem; }
.breadcrumb a { color: var(--aq-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--aq-accent); }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--aq-border);
  border-radius: 8px;
  background: var(--aq-surface);
  color: var(--aq-ink);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { border-color: var(--aq-muted); }
.btn--primary { background: var(--aq-accent); color: var(--aq-accent-ink); border-color: var(--aq-accent); }
.btn--primary:hover { filter: brightness(1.05); border-color: var(--aq-accent); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--aq-muted); }
.btn--danger { color: var(--aq-alert); border-color: #fca5a5; background: var(--aq-surface); }
.btn--block { display: block; width: 100%; }

/* Station list */
.station-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.station-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
}
.station-card__link { display: block; padding: 1rem; text-decoration: none; color: inherit; }
.station-card__link:hover { background: #f8fafc; }
.station-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.station-card__name { font-weight: 600; font-size: 1.05rem; }
.station-card__code { font-size: 0.8rem; color: var(--aq-muted); font-variant-numeric: tabular-nums; }
.station-card__meta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.35rem; font-size: 0.85rem; color: var(--aq-muted); }
.station-card__empty { color: var(--aq-accent); }

/* Station detail */
.station-code { font-size: 0.9rem; color: var(--aq-muted); font-weight: 400; }
.station-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0 0 1rem;
  padding: 1rem;
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
}
.station-facts dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--aq-muted); }
.station-facts dd { margin: 0.15rem 0 0; font-weight: 500; }

/* Reading list */
.reading-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.reading {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.reading--flagged { border-color: #fcd34d; background: #fffbeb; }
.reading__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.reading__time { font-weight: 600; font-size: 0.9rem; }
.reading__metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem 1rem;
  margin-top: 0.6rem;
}
.metric { display: flex; flex-direction: column; }
.metric__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--aq-muted); }
.metric__value { font-weight: 600; font-variant-numeric: tabular-nums; }
.metric--derived .metric__value { color: var(--aq-accent); }
.reading__notes { margin: 0.6rem 0 0; font-size: 0.9rem; color: var(--aq-ink); }
.reading__by { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--aq-muted); }

.badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge--flagged { background: #fde68a; color: #92400e; }

/* Forms */
.form { max-width: 480px; }
.form--entry { max-width: 420px; }
.field { margin-bottom: 1rem; }
.field-row { display: flex; gap: 1rem; }
.field-row .field { flex: 1; }
.field label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.3rem; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="datetime-local"],
.field input[type="month"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--aq-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--aq-surface);
}
.form--entry .field input { font-size: 1.15rem; padding: 0.7rem; }
.field__hint { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--aq-muted); }
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.5rem; }
.form--entry .form-actions { flex-direction: column-reverse; align-items: stretch; }

.form-errors {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.form-errors__title { margin: 0 0 0.4rem; font-weight: 600; color: var(--aq-alert); }
.form-errors ul { margin: 0; padding-left: 1.1rem; color: var(--aq-alert); font-size: 0.9rem; }

.empty-state { color: var(--aq-muted); }

/* Fleet overview chips */
.station-card--stale { border-color: #fca5a5; }
.station-card__chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.chip {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.chip--fresh { background: #d1fae5; color: var(--aq-notice); }
.chip--stale { background: #fee2e2; color: var(--aq-alert); }
.chip--flagged { background: #fde68a; color: #92400e; }

/* Trend charts */
.trends { margin-top: 2rem; }
.trends__title { font-size: 1.2rem; margin: 0 0 0.75rem; }
.chart-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.chart-card__title { margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 600; }
.chart-card__unit { color: var(--aq-muted); font-weight: 400; font-size: 0.82rem; }

/* Reports */
.report-form-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 2rem;
}
.report-form-card__title { margin: 0 0 1rem; font-size: 1.1rem; }
.report-form { max-width: none; }
.report-form__stations { border: none; padding: 0; margin: 0 0 0.5rem; }
.report-form__stations legend { font-weight: 500; font-size: 0.9rem; padding: 0; }
.report-form__station {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-weight: 400;
}
.report-form__station input { width: auto; }

.report-history { margin-top: 1rem; }
.report-history h2 { font-size: 1.2rem; }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.report-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
}
.report-card__link { display: block; padding: 1rem; text-decoration: none; color: inherit; }
.report-card__link:hover { background: #f8fafc; }
.report-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.report-card__period { font-weight: 600; font-size: 1.05rem; }
.report-card__date { font-size: 0.8rem; color: var(--aq-muted); }
.report-card__meta { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-top: 0.35rem; font-size: 0.85rem; color: var(--aq-muted); }

.report-downloads { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.report-stations { display: grid; gap: 0.75rem; margin: 1.5rem 0; }
.report-station {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 1rem;
}
.report-station__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.report-station__name { margin: 0; font-size: 1.05rem; }
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
}
.report-summary dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--aq-muted); }
.report-summary dd { margin: 0.15rem 0 0; font-weight: 500; }

/* Accounts */
.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.user-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-border);
  border-radius: 12px;
  padding: 1rem;
}
.user-card--inactive { opacity: 0.7; }
.user-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.user-card__email { font-weight: 600; word-break: break-all; }
.user-card__you {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--aq-muted);
  border: 1px solid var(--aq-border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  margin-left: 0.4rem;
}
.user-card__tags { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.user-card__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.user-card__actions .btn:disabled { opacity: 0.4; cursor: not-allowed; }
