/* ═══════════════════════════════════════════════════════════
   Itineraries module — dark, phone-first look (own palette, excluded from
   kitchen.css's body.dark rule). Isolated to #module-itineraries and
   .itn-modal-* (the edit modals are appended to <body>).
   ═══════════════════════════════════════════════════════════ */
:root {
  --itn-bg:     #0E1117;
  --itn-card:   #171C24;
  --itn-line:   #262E3A;
  --itn-text:   #E8ECF0;
  --itn-dim:    #8693A1;
  --itn-joint:  #F2B33D;
  --itn-dan:    #5AA9FF;
  --itn-sarah:  #FF7EB6;
  --itn-red:    #FF5C5C;
  --itn-hour:   56px; /* must match HOUR_PX in ui-itineraries.js */
}

#module-itineraries {
  margin: calc(-1 * var(--s4));
  width: calc(100% + var(--s4) * 2);
  height: calc(100% + var(--s4) * 2);
  background: var(--itn-bg);
  color: var(--itn-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
#module-itineraries[hidden], #module-itineraries [hidden] { display: none !important; }

.itn-header {
  margin: var(--s3);
  flex-shrink: 0;
  --mod-header-accent: var(--itn-joint);
  background: var(--itn-card);
}

.itn-btn {
  font: 600 16px var(--font-ui);
  border-radius: 12px;
  padding: 13px 16px;
  min-height: 48px;
  border: 1px solid var(--itn-line);
  background: var(--itn-card);
  color: var(--itn-text);
  cursor: pointer;
}
.itn-back-btn {
  font: 600 14px var(--font-ui); height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--itn-line); background: var(--itn-card); color: var(--itn-text); cursor: pointer;
}
.itn-btn-primary { background: var(--itn-joint); color: #1a1405; border-color: var(--itn-joint); }
.itn-btn-danger { color: var(--itn-red); }
.itn-icon-btn {
  font: 600 15px var(--font-ui);
  min-width: 44px; height: 44px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--itn-line);
  background: var(--itn-card); color: var(--itn-text); cursor: pointer;
}
.itn-icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Trips list ─────────────────────────────────────────── */
.itn-trips-view { padding: 0 var(--s3) var(--s3); display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.itn-trips { display: flex; flex-direction: column; gap: 12px; }
.itn-trip-card {
  text-align: left; width: 100%;
  background: var(--itn-card); border: 1px solid var(--itn-line);
  border-left: 5px solid var(--itn-joint);
  border-radius: 14px; padding: 18px 18px; color: var(--itn-text); cursor: pointer;
}
.itn-trip-card-name { font: 700 20px var(--font-ui); }
.itn-trip-card-sub { font: 400 15px var(--font-ui); color: var(--itn-dim); margin-top: 6px; }
.itn-empty { color: var(--itn-dim); font: 400 16px var(--font-ui); padding: 28px 4px; text-align: center; }

/* ── Trip view ──────────────────────────────────────────── */
.itn-trip-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 var(--s3) var(--s2); }
.itn-toolbar { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; flex-shrink: 0; }
.itn-trip-meta { flex: 1; min-width: 0; }
.itn-trip-dates { font: 700 17px var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itn-trip-count { font: 500 13px var(--font-ui); color: var(--itn-joint); margin-top: 2px; }
.itn-filter-btn { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 14px; }
.itn-filter-btn i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.itn-controls { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; flex-shrink: 0; }
.itn-seg { flex: 1; display: flex; border: 1px solid var(--itn-line); border-radius: 10px; overflow: hidden; background: var(--itn-card); min-width: 0; }
.itn-seg button {
  flex: 1; height: 42px; border: 0; background: transparent; color: var(--itn-dim);
  font: 600 14px var(--font-ui); cursor: pointer; min-width: 0;
}
.itn-seg button.is-on { background: var(--itn-joint); color: #1a1405; }
.itn-nav { display: flex; gap: 6px; }
.itn-nav .itn-icon-btn { height: 44px; }

/* Day strip (agenda + day modes) */
.itn-strip {
  position: relative; display: flex; gap: 6px; overflow-x: auto; flex-shrink: 0; padding-bottom: 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.itn-strip::-webkit-scrollbar { display: none; }
.itn-pill {
  flex: 0 0 auto; width: 52px; padding: 7px 0 8px; border-radius: 12px;
  border: 1px solid var(--itn-line); background: var(--itn-card); color: var(--itn-dim);
  font: 500 12px var(--font-ui); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.itn-pill b { font: 700 18px var(--font-ui); color: var(--itn-text); }
.itn-pill i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.itn-pill.has-items i { background: var(--itn-dim); }
.itn-pill.is-today { color: var(--itn-joint); }
.itn-pill.is-on { background: var(--itn-joint); border-color: var(--itn-joint); color: #1a1405; }
.itn-pill.is-on b { color: #1a1405; }
.itn-pill.is-on i { background: #1a1405; }

.itn-hint { font: 400 12px var(--font-ui); color: var(--itn-dim); padding-top: 6px; flex-shrink: 0; }

/* ── Agenda ─────────────────────────────────────────────── */
.itn-agenda {
  position: relative; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 96px; /* room for the + button */
}
.itn-day-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  background: var(--itn-bg); padding: 10px 2px 8px; border-bottom: 1px solid var(--itn-line);
}
.itn-day-name { font: 700 17px var(--font-ui); }
.itn-day-tag { font: 500 12px var(--font-ui); color: var(--itn-dim); border: 1px solid var(--itn-line); border-radius: 999px; padding: 2px 8px; }
.itn-day.is-today .itn-day-name { color: var(--itn-joint); }
.itn-day.is-today .itn-day-tag { color: var(--itn-joint); border-color: var(--itn-joint); }
.itn-day-add {
  margin-left: auto; width: 40px; height: 36px; border-radius: 10px; border: 1px dashed var(--itn-line);
  background: transparent; color: var(--itn-dim); font: 600 20px var(--font-ui); cursor: pointer;
}
.itn-day-body { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 14px; }
.itn-day-empty { color: var(--itn-dim); font: 400 14px var(--font-ui); padding: 4px 2px; }
.itn-card {
  --c: var(--itn-joint);
  display: flex; gap: 12px; text-align: left; width: 100%; box-sizing: border-box;
  background: var(--itn-card); color: var(--itn-text); border: 1px solid var(--itn-line);
  border-left: 5px solid var(--c); border-radius: 12px; padding: 12px 14px; cursor: pointer;
  font-family: var(--font-ui);
}
.itn-card.is-dan { --c: var(--itn-dan); }
.itn-card.is-sarah { --c: var(--itn-sarah); }
.itn-card.is-cont { border-style: dashed; border-left-style: solid; background: color-mix(in srgb, var(--c) 8%, var(--itn-card)); }
.itn-card-time { flex: 0 0 52px; font: 700 15px var(--font-ui); line-height: 1.3; font-variant-numeric: tabular-nums; }
.itn-card-time small { display: block; font: 400 13px var(--font-ui); color: var(--itn-dim); }
.itn-card-body { flex: 1; min-width: 0; }
.itn-card-title { font: 600 16px/1.3 var(--font-ui); overflow-wrap: anywhere; }
.itn-card-sub { font: 400 14px/1.35 var(--font-ui); color: var(--itn-dim); margin-top: 3px; overflow-wrap: anywhere; }
.itn-card-tag { display: inline-block; margin-top: 6px; font: 600 12px var(--font-ui); color: var(--c); }

/* ── Floating add button ────────────────────────────────── */
.itn-fab {
  position: absolute; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--itn-joint); color: #1a1405; font: 400 34px/1 var(--font-ui);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}

/* ── Calendar grid (Day timeline + Week) ────────────────── */
.itn-cal {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; position: relative;
  border: 1px solid var(--itn-line); border-radius: 10px; background: var(--itn-card);
}
.itn-grid {
  display: grid;
  grid-template-columns: 46px repeat(var(--itn-days), minmax(0, 1fr));
  width: 100%;
}
.itn-corner, .itn-dayhead, .itn-allday-label, .itn-allday, .itn-gutter { background: var(--itn-card); }
.itn-corner { position: sticky; top: 0; left: 0; z-index: 6; height: 48px; border-bottom: 1px solid var(--itn-line); }
.itn-dayhead {
  position: sticky; top: 0; z-index: 4; height: 48px; box-sizing: border-box;
  border-bottom: 1px solid var(--itn-line); border-left: 1px solid var(--itn-line);
  padding: 7px 5px; font: 600 13px var(--font-ui); line-height: 1.25; overflow: hidden; white-space: nowrap;
}
.itn-dayhead small { display: block; font-weight: 400; font-size: 12px; color: var(--itn-dim); }
.itn-dayhead.is-today { color: var(--itn-joint); }
.itn-allday-label {
  position: sticky; top: 48px; left: 0; z-index: 6; border-bottom: 1px solid var(--itn-line);
  font: 400 10px var(--font-ui); color: var(--itn-dim); padding: 8px 3px; text-align: right;
}
.itn-allday {
  position: sticky; top: 48px; z-index: 3; min-height: 38px; box-sizing: border-box;
  border-bottom: 1px solid var(--itn-line); border-left: 1px solid var(--itn-line);
  padding: 3px; display: flex; flex-direction: column; gap: 3px; cursor: pointer;
}
.itn-gutter { position: sticky; left: 0; z-index: 2; height: calc(var(--itn-hour) * 24); }
.itn-hour-label {
  position: absolute; right: 4px; transform: translateY(-50%);
  font: 400 11px var(--font-ui); color: var(--itn-dim);
}
.itn-col {
  position: relative; height: calc(var(--itn-hour) * 24);
  border-left: 1px solid var(--itn-line); cursor: cell;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--itn-hour) - 1px), var(--itn-line) calc(var(--itn-hour) - 1px), var(--itn-line) var(--itn-hour));
}
.itn-col.is-today { background-color: rgba(242, 179, 61, 0.05); }
.itn-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--itn-red); z-index: 1; pointer-events: none; }

/* Items — colour = who (joint / Dan / Sarah), icon = type */
.itn-ev {
  --c: var(--itn-joint);
  position: absolute; box-sizing: border-box; overflow: hidden;
  border-radius: 6px; border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 22%, var(--itn-card));
  padding: 3px 6px; font: 600 12px/1.3 var(--font-ui); color: var(--itn-text);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; z-index: 2;
}
.itn-grid.is-day .itn-ev { font-size: 15px; padding: 5px 9px; }
.itn-ev.is-dan { --c: var(--itn-dan); }
.itn-ev.is-sarah { --c: var(--itn-sarah); }
.itn-ev small { display: block; font-weight: 400; color: var(--itn-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itn-grid.is-day .itn-ev small { font-size: 13px; }
.itn-ev-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itn-ev.is-dragging { opacity: 0.85; box-shadow: 0 6px 18px rgba(0,0,0,0.5); z-index: 8; cursor: grabbing; }
.itn-ev.is-ghost { opacity: 0.6; border-style: dashed; pointer-events: none; z-index: 7; }
.itn-ev-resize {
  position: absolute; left: 0; right: 0; bottom: 0; height: min(28px, 45%);
  cursor: ns-resize; touch-action: none; /* lets a finger drag it without the page scrolling */
}
.itn-ev-resize::after { /* visible grab bar */
  content: ''; position: absolute; left: 50%; bottom: 3px; width: 30px; height: 4px; margin-left: -15px;
  border-radius: 2px; background: currentColor; opacity: 0.55;
}
.itn-ev.is-allday { position: static; min-height: 24px; padding: 3px 6px; }
.itn-ev.is-cont { border-left-width: 0; border-radius: 0 6px 6px 0; }

/* ── Modals (appended to <body>) ────────────────────────── */
.itn-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
}
.itn-modal-sheet {
  width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; box-sizing: border-box;
  background: #171C24; color: #E8ECF0; border: 1px solid #262E3A;
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px)); font-family: var(--font-ui);
}
@media (min-width: 600px) { .itn-modal-overlay { align-items: center; } .itn-modal-sheet { border-radius: 16px; } }
.itn-modal-sheet h2 { margin: 0 0 8px; font: 700 21px var(--font-ui); color: #E8ECF0; }
.itn-modal-sheet label { display: block; font: 600 12px var(--font-ui); color: #8693A1; text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 5px; }
.itn-modal-sheet input, .itn-modal-sheet select, .itn-modal-sheet textarea {
  width: 100%; box-sizing: border-box; min-width: 0; min-height: 46px;
  background: #0E1117; color: #E8ECF0; border: 1px solid #262E3A; border-radius: 10px;
  padding: 10px 12px; font: 400 16px var(--font-ui); /* 16px stops iOS zooming on focus */
}
.itn-modal-sheet textarea { min-height: 80px; resize: vertical; }
.itn-modal-row { display: flex; gap: 10px; }
.itn-modal-row > * { flex: 1; min-width: 0; }
.itn-modal-check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font: 400 16px var(--font-ui); text-transform: none; letter-spacing: 0; color: #E8ECF0; }
.itn-modal-sheet label.itn-modal-check { font: 400 16px var(--font-ui); text-transform: none; letter-spacing: 0; color: #E8ECF0; margin: 14px 0 0; }
.itn-modal-check input { width: 22px; height: 22px; min-height: 0; }
.itn-modal-seg { display: flex; gap: 8px; }
.itn-modal-seg button {
  flex: 1; min-height: 46px; padding: 8px 4px; border-radius: 10px; border: 1px solid #262E3A;
  background: #0E1117; color: #8693A1; font: 600 14px var(--font-ui); cursor: pointer;
}
.itn-modal-seg button.is-on { color: #E8ECF0; border-color: #8693A1; background: #1f2631; }
.itn-modal-note { color: #F2B33D; font: 400 13px var(--font-ui); margin-top: 8px; }
.itn-modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.itn-modal-actions .itn-btn { flex: 1; }
.itn-modal-overlay [hidden] { display: none !important; }
.itn-modal-error { color: #FF5C5C; font: 400 14px var(--font-ui); margin-top: 10px; }

/* Draft block placed by clicking a slot: adjust it, then tap it to open the details form */
.itn-ev.is-draft { --c: #E8ECF0; background: rgba(232,236,240,0.16); border: 1px dashed #E8ECF0; border-left-width: 3px; z-index: 5; cursor: grab; }
