/* ==========================================================================
   Singapore Leave Optimizer - PWA styles
   Design direction: "boarding pass" / travel-itinerary aesthetic.
   Palette: deep harbor teal + sunset coral + warm gold, on a pale sea-mist
   background. Suggested breaks render as ticket-stub cards - the one
   deliberate signature element, reinforcing "this break = a trip".
   ========================================================================== */

:root {
  --bg: #F2F6F5;
  --surface: #FFFFFF;
  --ink: #10262B;
  --muted: #5B7280;
  --line: #E1E8E7;

  --primary: #0B4F6C;
  --primary-dark: #073246;
  --primary-tint: #E4EEF1;

  --accent: #FF6B4A;
  --accent-dark: #E14B2A;
  --accent-tint: #FFE8E1;

  --gold: #FFC857;
  --gold-tint: #FFF6E0;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;

  --shadow-card: 0 4px 16px rgba(11, 79, 108, 0.08);
  --shadow-pop: 0 12px 32px rgba(11, 79, 108, 0.18);

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .display {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------------------------------------------------------------- header */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 30px;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
}

.header-art {
  position: absolute;
  top: 0;
  right: 0;
  width: 78%;
  height: 100%;
  pointer-events: none;
}

.flight-path {
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 2;
  stroke-dasharray: 5 8;
  stroke-linecap: round;
  animation: dash-drift 40s linear infinite;
}

@keyframes dash-drift {
  to { stroke-dashoffset: -400; }
}

.flight-origin {
  fill: var(--gold);
}

.flight-plane path {
  fill: #fff;
}

.flight-pin circle {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 1.5;
}

.app-header .eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
  display: block;
  position: relative;
}

.app-header h1 {
  font-size: 27px;
  line-height: 1.15;
  color: #fff;
  max-width: 280px;
  position: relative;
}

.app-header p {
  margin: 9px 0 0;
  font-size: 13.5px;
  color: rgba(255,255,255,0.78);
  max-width: 280px;
  line-height: 1.5;
  position: relative;
}

/* ------------------------------------------------------------------ card */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 17px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --------------------------------------------------------------- fields */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.segmented {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(11,79,108,0.25);
}

.stepper {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: fit-content;
}

.stepper button {
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
}

.stepper button:active { background: var(--primary-tint); }

.stepper input {
  width: 56px;
  text-align: center;
  border: none;
  background: transparent;
  font-family: "IBM Plex Mono", monospace;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* toggle row (checkbox styled as switch) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.toggle-row .toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.switch {
  position: relative;
  width: 46px;
  height: 27px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch .thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}

.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(19px); }

.sub-field {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: none;
}
.sub-field.visible { display: block; }

.pill-btn {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.pill-btn .count-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 3px 9px;
}

/* ------------------------------------------------------------ generate */
.generate-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 17px;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.01em;
  margin-top: 18px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255,107,74,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.generate-btn svg { width: 19px; height: 19px; transition: transform 0.2s ease; }
.generate-btn:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(255,107,74,0.42); }
.generate-btn:hover svg { transform: translate(2px,-2px); }
.generate-btn:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(255,107,74,0.3); }
.generate-btn:disabled { background: #C9B7B0; box-shadow: none; cursor: default; transform: none; }
.generate-btn:disabled svg { transform: none; }

.status-line {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 10px;
  min-height: 16px;
}
.status-line.error { color: var(--accent-dark); font-weight: 600; }

/* -------------------------------------------------------------- summary */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.stat {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.stat .icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.stat .icon svg { width: 14px; height: 14px; }
.stat.tone-primary .icon { background: var(--primary-tint); color: var(--primary); }
.stat.tone-accent .icon { background: var(--accent-tint); color: var(--accent-dark); }
.stat.tone-gold .icon { background: var(--gold-tint); color: #8a6300; }
.stat.tone-mint .icon { background: #E1F4EC; color: #1E8A5F; }

.stat .value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.stat .label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

.optimized-note {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1E8A5F;
  background: #E1F4EC;
  border-radius: 999px;
  padding: 7px 12px;
  margin-top: 12px;
  width: fit-content;
}

.target-banner {
  background: linear-gradient(135deg, var(--gold-tint), #fff);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.target-banner .emoji { font-size: 20px; line-height: 1; }

/* ------------------------------------------------------------------ tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  border: none;
  background: var(--surface);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.tab-btn.active { background: var(--primary); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ------------------------------------------------------ ticket / boarding pass
   Signature element: each suggested break renders as a torn boarding-pass
   stub - the "days off" figure sits in a perforated stub, like a flight
   duration, reinforcing that this break is a trip worth taking. */
.ticket {
  position: relative;
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  overflow: hidden;
}

.ticket.is-target { box-shadow: 0 4px 16px rgba(255,200,87,0.35); }
.ticket.is-mandatory { box-shadow: 0 4px 16px rgba(11,79,108,0.18); }

.ticket__main {
  flex: 1;
  padding: 16px 14px 16px 18px;
  min-width: 0;
}

.ticket__period {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.ticket__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag.holiday { background: var(--primary-tint); color: var(--primary); }
.tag.target { background: var(--gold-tint); color: #8a6300; border: 1px solid var(--gold); }
.tag.mandatory { background: var(--primary); color: #fff; }

.ticket__meta {
  font-size: 12px;
  color: var(--muted);
}

.ticket__stub {
  width: 92px;
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  position: relative;
  text-align: center;
}

.ticket.is-target .ticket__stub { background: var(--accent); }

.ticket__stub .days {
  font-family: "IBM Plex Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.ticket__stub .days-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  margin-top: 2px;
}
.ticket__stub .leave-cost {
  margin-top: 8px;
  font-size: 10.5px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 2px 8px;
}

.ticket__perforation {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 0;
  border-left: 2px dashed rgba(255,255,255,0.55);
}
.ticket__notch {
  position: absolute;
  left: -9px;
  width: 18px;
  height: 18px;
  background: var(--bg);
  border-radius: 50%;
  z-index: 2;
}
.ticket__notch.top { top: -9px; }
.ticket__notch.bottom { bottom: -9px; }

/* --------------------------------------------------------------- simple list rows (leave dates, holidays) */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.list-row:last-child { border-bottom: none; }
.list-row .date {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}
.list-row .day { color: var(--muted); font-size: 12.5px; }
.list-row .note { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 24px 12px;
}

/* -------------------------------------------------------------- export btn */
.export-btn {
  width: 100%;
  background: var(--primary-tint);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.export-btn:disabled { opacity: 0.5; cursor: default; }

/* ----------------------------------------------------------- modal sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,38,43,0.45);
  display: none;
  align-items: flex-end;
  z-index: 50;
}
.sheet-overlay.open { display: flex; }

.sheet {
  background: var(--surface);
  width: 100%;
  max-height: 86vh;
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 0 auto 14px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sheet-header h3 { font-size: 16px; }

.counter-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-tint);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
  display: inline-block;
}
.counter-badge.exceeded { color: var(--accent-dark); background: var(--accent-tint); }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-nav button {
  border: none;
  background: var(--bg);
  color: var(--primary);
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}
.cal-nav .month-label {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 15px;
}

.cal-legend {
  display: flex;
  gap: 12px;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}
.cal-dow {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.blank { background: transparent; cursor: default; }
.cal-day.off-day { background: transparent; color: #B9C6C4; cursor: not-allowed; }
.cal-day.selected { background: var(--accent); color: #fff; }
.cal-day:disabled { pointer-events: none; }

.sheet-actions {
  display: flex;
  gap: 10px;
}
.sheet-actions button {
  flex: 1;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost { background: var(--bg); color: var(--muted); }
.btn-primary { background: var(--accent); color: #fff; }

/* --------------------------------------------------------------- footer */
.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 20px;
  padding: 0 12px;
}

/* -------------------------------------------------------------- utility */
.hidden { display: none !important; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .animate-in, .flight-path { animation: none !important; }
}

@media (min-width: 640px) {
  .app-header { padding-top: 32px; }
}
