/*
  Hand-written, mobile-first, dependency-free CSS for the Mileage
  Reimbursement app. See PLAN.md ("Mobile-First UI") for why this exists
  instead of pulling in a full CSS framework: the app has a handful of
  form-heavy screens, and a single-column phone-first layout with large tap
  targets covers nearly all of it. Widen from here as real screens are
  built (trip entry formset, month dashboard table, PDF-adjacent views).
*/

:root {
  --color-bg: #f7f7f5;
  --color-surface: #ffffff;
  --color-text: #1f2328;
  --color-muted: #6b7280;
  --color-border: #d9dce1;
  --color-primary: #2563eb;
  --color-primary-text: #ffffff;
  --color-danger: #b91c1c;
  --color-success: #166534;
  --radius: 10px;
  --spacing: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.4;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--spacing);
}

@media (min-width: 700px) {
  .app-main {
    max-width: 720px;
  }
}

/* Trip entry: form + map. Map goes below the form on narrow screens
   (nothing usable at phone widths side-by-side), right of it from the
   tablet breakpoint up. */
.trip-entry-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 700px) {
  .app-main:has(.trip-entry-layout) {
    max-width: 960px;
  }
  .trip-entry-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .trip-form-col {
    flex: 1 1 55%;
    min-width: 0;
  }
  .trip-map-col {
    flex: 1 1 45%;
    position: sticky;
    top: calc(3.5rem + var(--spacing));
  }
}

#trip-map {
  height: 320px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}

@media (min-width: 700px) {
  #trip-map {
    height: 420px;
  }
}

.map-legend {
  margin-top: 0.5rem;
}

.legend-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.15rem;
}

.legend-start { background: #16a34a; }
.legend-stop { background: var(--color-primary); }
.legend-end { background: #dc2626; }

h1 {
  font-size: 1.4rem;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

.hint {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Forms */

.stacked-form label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.stop-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.stop-row select {
  flex: 1;
}

.stop-delete {
  display: flex !important;
  align-items: center;
  gap: 0.25rem;
  font-weight: normal !important;
  font-size: 0.85rem;
  color: var(--color-muted);
  white-space: nowrap;
  margin: 0 !important;
}

input[type="email"],
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 44px; /* touch-target guideline */
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

button,
.primary-button,
.secondary-button {
  display: inline-block;
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
}

.primary-button {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border: none;
  width: 100%;
  margin-top: 1rem;
  font-weight: 600;
}

.secondary-button {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  width: 100%;
  margin-top: 0.75rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--color-muted);
  text-decoration: underline;
  padding: 0;
  min-height: auto;
  font-size: 0.9rem;
}

.logout-form {
  margin: 0;
}

/* Messages */

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.messages .message {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.messages .message.success {
  background: #dcfce7;
  color: var(--color-success);
}

.messages .message.error {
  background: #fee2e2;
  color: var(--color-danger);
}

/* Tables (month dashboard, trip list) */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.open {
  background: #dcfce7;
  color: var(--color-success);
}

.badge.closed {
  background: #e5e7eb;
  color: var(--color-muted);
}

/* Landing page (logged-out "/") */

.hero {
  text-align: center;
  padding: 0.5rem 0 0.5rem;
}

.hero-art {
  max-width: 280px;
  margin: 0 auto 1.5rem;
}

.hero-art svg {
  width: 100%;
  height: auto;
  display: block;
}

.hero h1 {
  font-size: 1.6rem;
}

.hero .hint {
  font-size: 1rem;
  max-width: 34ch;
  margin: 0 auto 1.5rem;
}

.hero .primary-button {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* Stat tiles (month detail header, supervisor dashboard) */

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  flex: 1 1 8rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted);
}
