/* My SW Flights — dashboard styles.
   Identity: a departures board in pine and mint on pale sage paper.
   Upcoming trips live on the dark board; past trips sit beneath in a quiet
   light list. Expanding a row pulls out a light "ticket stub" panel. */

:root {
  --paper: #eef2ef;
  --card: #ffffff;
  --ink: #14251f;
  --ink-soft: #4f635b;
  --ink-faint: #8a9a92;
  --line: #d9e2dc;
  --board: #173b34;
  --board-line: #245349;
  --board-text: #ffffff;
  --board-muted: rgba(255, 255, 255, 0.72);
  --accent: #7fe0b8;
  --accent-deep: #1f7a5c;
  --accent-deeper: #176349;
  --rose: #ffb4ad;
  --rose-deep: #b3261e;
  --straw: #f5d58a;
  --straw-deep: #9a6b00;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-optical-sizing: auto;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); }

button, input { font: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- Header --- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 800px;
  margin: 0 auto;
  padding: 1.1rem 1rem 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
}
.brand img { width: 2rem; height: 2rem; }
.brand h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }

#login-btn {
  background: var(--board);
  color: #fff;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
#login-btn:hover { background: var(--board-line); }

/* --- Layout --- */

main {
  max-width: 800px;
  margin: 1rem auto 2rem;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.9rem;
}

/* --- Section heads (Upcoming / Past) --- */

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.list-head h2 { margin: 0; }
.list-summary {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.list-summary strong { font-weight: 700; color: var(--ink); }

/* Upcoming = the board */
#upcoming-card {
  background: var(--board);
  border-color: var(--board);
  color: var(--board-text);
  box-shadow: 0 30px 60px -36px rgba(20, 37, 31, 0.6);
}
#upcoming-card .list-head { border-bottom: 1px solid var(--board-line); padding-bottom: 0.8rem; }
#upcoming-card h2 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
#upcoming-card .list-summary { color: var(--board-muted); }
#upcoming-card .list-summary strong { color: var(--accent); }

/* Past = quiet list */
#past-card h2 { color: var(--ink-soft); }

/* --- Flight rows (same shape as the landing-page board) --- */

.flight-card {
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.flight-card:last-child { border-bottom: 0; padding-bottom: 0.25rem; }
#upcoming-card .flight-card { border-color: var(--board-line); }

.card-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "route status"
    "meta  chevron";
  column-gap: 1rem;
  row-gap: 0.2rem;
  align-items: start;
}
.route-main { grid-area: route; min-width: 0; }
.card-summary > .status { grid-area: status; }
.meta { grid-area: meta; }
.chevron { grid-area: chevron; justify-self: end; align-self: end; }

.route-segment { display: inline-flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.city-pair { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.city-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.airport-code { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; color: var(--accent-deep); }
.route-arrow { color: var(--accent-deep); font-weight: 400; }
#upcoming-card .airport-code, #upcoming-card .route-arrow { color: var(--accent); }

.rt-routes { display: flex; flex-direction: column; gap: 0.3rem; }
.rt-leg { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.rt-leg-date { font-size: 0.9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
#upcoming-card .rt-leg-date { color: var(--board-muted); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#upcoming-card .meta { color: var(--board-muted); }
.meta-pax { flex-basis: 100%; }         /* passengers always start their own line */

.fare { font-weight: 700; color: var(--accent-deep); }
#upcoming-card .fare { color: var(--accent); }
.fare.returned { color: var(--rose-deep); }
#upcoming-card .fare.returned { color: var(--rose); }

.chevron {
  display: inline-block;
  transition: transform 0.2s;
  color: var(--ink-faint);
  font-size: 0.75rem;
}
#upcoming-card .chevron { color: var(--board-muted); }
.flight-card.open .chevron { transform: rotate(180deg); }

/* Status pills */
.status {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
}
.status-confirmed { background: rgba(31, 122, 92, 0.12); color: var(--accent-deep); }
.status-cancelled { background: rgba(179, 38, 30, 0.1); color: var(--rose-deep); }
.status-modified  { background: rgba(154, 107, 0, 0.12); color: var(--straw-deep); }
#upcoming-card .status-confirmed { background: rgba(127, 224, 184, 0.16); color: var(--accent); }
#upcoming-card .status-cancelled { background: rgba(255, 255, 255, 0.1); color: var(--rose); }
#upcoming-card .status-modified  { background: rgba(255, 255, 255, 0.1); color: var(--straw); }

/* Cancelled rows */
.flight-card.cancelled .city-name { text-decoration: line-through; text-decoration-color: rgba(179, 38, 30, 0.6); color: var(--ink-soft); }
#upcoming-card .flight-card.cancelled .city-name { color: rgba(255, 255, 255, 0.6); text-decoration-color: rgba(255, 180, 173, 0.7); }

/* --- Expanded "ticket stub" --- */

.expanded-details {
  display: none;
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
}
#upcoming-card .expanded-details { background: var(--card); }
.flight-card.open .expanded-details { display: block; }

.leg-detail { color: var(--ink-soft); padding: 0.1rem 0; font-variant-numeric: tabular-nums; }
.leg-group + .leg-group { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.leg-group-header { font-size: 0.8rem; font-weight: 700; color: var(--ink); margin-bottom: 0.15rem; }

.conf-block { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }
.conf-num { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; margin-bottom: 0.25rem; }
.pax-fares { margin-bottom: 0.4rem; }
.pax-fare-row { padding: 0.05rem 0; color: var(--ink); }
.pax-fare-row .fare { color: var(--accent-deep); }

.email-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}
.email-history-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.email-link {
  color: var(--accent-deep);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-link:hover { text-decoration: underline; }
.email-history-date { font-size: 0.75rem; color: var(--ink-faint); }

.pill {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  white-space: nowrap;
}
.pill-confirmed { background: rgba(31, 122, 92, 0.12); color: var(--accent-deep); }
.pill-modified  { background: rgba(154, 107, 0, 0.12); color: var(--straw-deep); }
.pill-cancelled { background: rgba(179, 38, 30, 0.1); color: var(--rose-deep); }
.pill-shared    { background: rgba(31, 122, 92, 0.12); color: var(--accent-deep); }

/* --- Empty / loading --- */

.empty-state { color: var(--ink-faint); text-align: center; padding: 1.5rem 0; }
#upcoming-card .empty-state { color: var(--board-muted); }
.loading { color: var(--ink-faint); font-style: italic; padding: 0.5rem 0; }

/* --- Banners --- */

#verification-banner { border-left: 4px solid var(--straw-deep); }
#verification-banner strong { display: block; margin-bottom: 0.3rem; }
#verification-banner p { color: var(--ink-soft); font-size: 0.9rem; }
#banner-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.9rem; flex-wrap: wrap; }
.btn-verify {
  background: var(--accent-deep);
  color: #fff;
  text-decoration: none;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}
.btn-verify:hover { background: var(--accent-deeper); }
#verification-dismiss { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 0.85rem; }
#verification-dismiss:hover { color: var(--ink-soft); text-decoration: underline; }

.shared-banner-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.shared-banner-head h2 { margin: 0; }

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

.landing-hero { text-align: center; padding: 3rem 1rem 2rem; }
.landing-logo { display: inline-block; width: 3.5rem; height: 3.5rem; margin-bottom: 1rem; }
.landing-hero h2 { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-bottom: 0.75rem; }
.landing-tagline { color: var(--ink-soft); font-size: 1.05rem; max-width: 30rem; margin: 0 auto 1.5rem; text-wrap: pretty; }
.btn-primary-hero {
  background: var(--board);
  color: #fff;
  border: none;
  padding: 0.8rem 1.75rem;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary-hero:hover { background: var(--board-line); }
.landing-hint { color: var(--ink-faint); font-size: 0.85rem; margin-top: 0.9rem; }
.landing-hint a { color: var(--accent-deep); }

/* --- Avatar + dropdown --- */

.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--board); color: var(--accent);
  border: none; font-weight: 700; font-size: 0.8rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.avatar-btn:hover { background: var(--board-line); }

#user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px -12px rgba(20, 37, 31, 0.35);
  min-width: 210px; z-index: 100; padding: 0.4rem 0;
}
.dropdown-email { padding: 0.5rem 1rem; font-size: 0.8rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.dropdown-divider { border: none; border-top: 1px solid var(--line); margin: 0.25rem 0; }
.dropdown-item { display: block; width: 100%; text-align: left; padding: 0.5rem 1rem; background: none; border: none; font-size: 0.9rem; color: var(--ink); cursor: pointer; text-decoration: none; }
.dropdown-item:hover { background: var(--paper); }
.dropdown-item-danger { color: var(--rose-deep); }

/* --- Account panel --- */

.account-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.account-header h2 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
#account-panel .card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.btn-back { background: none; border: none; color: var(--accent-deep); cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.btn-back:hover { text-decoration: underline; }
.account-hint { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 0.75rem; }

.inbound-email-display {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--paper); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin-bottom: 0.5rem;
}
.inbound-email-addr { flex: 1; font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }
.btn-copy {
  background: var(--accent-deep); color: #fff; border: none;
  padding: 0.35rem 0.8rem; border-radius: 7px;
  font-size: 0.85rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-copy:hover { background: var(--accent-deeper); }
.status-msg { margin-top: 0.4rem; font-size: 0.9rem; color: var(--accent-deep); min-height: 1.2em; }
.status-msg.error { color: var(--rose-deep); }

.share-links-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.share-link-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; background: var(--paper); border-radius: 8px; padding: 0.6rem 0.8rem; }
.share-link-meta { flex: 1; min-width: 160px; }
.share-link-label { font-weight: 700; }
.share-link-date { color: var(--ink-faint); font-size: 0.8rem; }
.share-link-url { flex: 2; min-width: 200px; font-size: 0.8rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-revoke { background: none; color: var(--rose-deep); border: 1px solid var(--rose-deep); padding: 0.3rem 0.75rem; border-radius: 7px; font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-revoke:hover { background: rgba(179, 38, 30, 0.08); }
.share-create-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.share-create-form input { flex: 1; min-width: 180px; padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: 7px; font-size: 0.9rem; background: var(--card); color: var(--ink); }

/* --- Footer --- */

footer { text-align: center; padding: 1.5rem 1rem 2.5rem; color: var(--ink-faint); font-size: 0.85rem; }

/* --- Email viewer dialog --- */

dialog {
  border: none; border-radius: var(--radius); padding: 0;
  width: 90vw; max-width: 720px; max-height: 85vh; margin: auto;
  box-shadow: 0 24px 60px -20px rgba(20, 37, 31, 0.5);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(20, 37, 31, 0.55); }
#email-dialog-close { align-self: flex-end; margin: 0.5rem 0.5rem 0; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--ink-soft); }
#email-iframe { flex: 1; border: none; width: 100%; min-height: 60vh; }

/* --- Small screens --- */

@media (max-width: 520px) {
  .card { padding: 1.1rem; }
  .city-name { font-size: 1.05rem; }
  /* Route gets the full width; the status pill drops to the meta line's right edge. */
  .card-summary {
    column-gap: 0.6rem;
    grid-template-areas:
      "route route"
      "meta  status";
  }
  .card-summary > .status { align-self: end; }
  .chevron { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chevron { transition: none; }
}
