/* APSR Maid Arrival Dashboard — standalone styling (self-contained). */

:root {
  --accent: #6aa0b1;
  --accent-dark: #5a8896;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #d7dae0;
  --bg: #f4f5f8;
  --card: #ffffff;
  --font: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- toolbar ---------- */
.toolbar {
  max-width: 960px;
  margin: 0 auto 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-mark {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); border-radius: 10px; font-size: 22px;
}
.brand-eyebrow { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.board-title { margin: 0; font-size: 22px; color: var(--text); }

.you-label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.you-select {
  font-family: var(--font); font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; min-width: 150px;
}

.board { max-width: 960px; margin: 0 auto; }

/* ---------- sync banner ---------- */
.sync-banner {
  max-width: 960px; margin: 0 auto 16px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px;
}
.sync-banner-shared { background: #eaf6ea; border-color: #7cb97c; color: #1f5b1f; }
.sync-banner-local { background: #eef0f4; color: #555; }
.sync-banner-warn { background: #fff5e6; border-color: #e6a23c; color: #8a5200; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab-btn {
  font-family: var(--font); font-size: 14px; padding: 9px 16px;
  border: 1px solid var(--border); border-radius: 8px 8px 0 0; background: #eef0f4;
  color: var(--muted); cursor: pointer; border-bottom: none;
}
.tab-btn.tab-active { background: var(--card); color: var(--text); font-weight: 600; }

/* ---------- entry form ---------- */
.entry-form {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.form-heading { font-weight: 600; margin-bottom: 12px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); position: relative; }
.form-field-wide { grid-column: 1 / -1; }
.form-field input,
.form-field select,
.form-field textarea {
  font-family: var(--font); font-size: 14px; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.form-field textarea { resize: vertical; }
.form-actions { margin-top: 14px; display: flex; gap: 8px; }

/* confidence-flagged OCR fields */
.conf-high { border-color: #4caf50 !important; background: #f2faf2; }
.conf-medium { border-color: #e6a23c !important; background: #fff8ec; }
.conf-low, .conf-none { border-color: #cc4444 !important; background: #fdf2f2; }

.ocr-status { font-size: 13px; color: var(--muted); margin: 4px 0; }
.ocr-review { margin-top: 8px; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; }
.ocr-thumb-wrap { margin-bottom: 8px; }
.ocr-thumb-img { max-width: 280px; max-height: 340px; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }
.ocr-hint { font-size: 12px; color: var(--muted); margin: 0; }
.ocr-raw-toggle {
  font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer;
  padding: 6px 0; text-decoration: underline;
}
.ocr-raw-text {
  white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f7f8fa;
  border: 1px solid var(--border); border-radius: 6px; padding: 10px; max-height: 240px; overflow-y: auto;
}

/* ---------- agent combobox ---------- */
.combo-wrap { position: relative; }
.combo-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  margin-top: 4px; max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.combo-item {
  display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px;
  cursor: pointer; font-size: 13px;
}
.combo-item:hover { background: #f1f5f4; }
.combo-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.subtle { color: var(--muted); font-size: 12px; }

/* ---------- entry list ---------- */
.entry-list { display: flex; flex-direction: column; gap: 26px; }
.date-group { display: flex; flex-direction: column; gap: 10px; }
/* Bold, high-contrast section divider — the weekday+date and the accent-filled
   count pill are deliberately oversized relative to everything below them, so
   scanning a long board for "what's arriving when" doesn't require reading every
   card, and so it's obvious at a glance where one day's arrivals end and the next
   day's begin. */
.date-group-header {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 6px 2px 8px; border-bottom: 2px solid var(--accent);
}
.date-group-date {
  font-family: var(--font); font-size: 21px; font-weight: 700; color: var(--text);
}
.date-group-count {
  font-family: var(--font); font-size: 13px; font-weight: 600; color: #fff;
  background: var(--accent); padding: 3px 11px; border-radius: 12px; white-space: nowrap;
}
.entry-card {
  background: var(--card); border: 1px solid var(--border);
  border-left: 5px solid var(--accent); border-radius: 10px; padding: 14px 16px;
}
.entry-header { display: flex; align-items: center; gap: 8px; }
.entry-header-spacer { flex: 1 1 auto; }
.entry-flight { font-family: var(--font); font-weight: 700; font-size: 15px; color: var(--text); }
.entry-passenger { font-family: var(--font); font-size: 19px; font-weight: 700; color: var(--text); margin: 10px 0 8px; }
.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.entry-detail { display: flex; flex-direction: column; }
.detail-label { font-family: var(--font); font-size: 11px; color: var(--muted); }
.detail-value { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--text); white-space: pre-line; word-break: break-word; }
.entry-ticket { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.entry-ticket-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }
.entry-ticket-link { font-family: var(--font); font-size: 13px; color: var(--accent); }

.icon-btn {
  border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--muted); padding: 10px; border-radius: 6px;
}
.icon-btn:hover { background: #eef0f4; }
.icon-btn-danger { color: #b00020; font-size: 20px; }

.empty-state { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 0; }

/* ---------- agents tab / manage panel ---------- */
.manage-pin-gate p { color: var(--muted); font-size: 14px; }
.pin-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pin-input {
  font-family: var(--font); font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; flex: 1 1 160px;
}
.pin-error { color: #b00020; font-size: 13px; }
.pin-state { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }

.manage-panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.manage-section { margin-bottom: 18px; }
.manage-section-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; color: var(--text); }
.manage-empty { color: var(--muted); font-size: 13px; padding: 6px 0; }

.agent-list, .user-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.agent-row, .user-row {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.agent-row-name, .agent-row-country {
  font-family: var(--font); font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.agent-row-name { flex: 1 1 55%; }
.agent-row-country { flex: 1 1 35%; }
.user-row-name { flex: 1 1 auto; font-size: 14px; }

.add-agent-row, .add-user-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-agent-name, .add-user-name {
  font-family: var(--font); font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; flex: 1 1 55%;
}
.add-agent-country {
  font-family: var(--font); font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; flex: 1 1 30%;
}

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 24, 34, 0.45); }
.modal-card {
  position: relative; background: var(--card); border-radius: 12px; width: min(520px, 92vw);
  max-height: 88vh; overflow-y: auto; padding: 18px 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-title { margin: 0; font-size: 18px; }

.thumbnail-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.thumbnail-modal[hidden] { display: none; }
.thumbnail-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 18, 0.75); }
.thumbnail-modal-content { position: relative; max-width: 92vw; max-height: 92vh; }
/* min-width forces even the small persisted thumbnail (used as a fallback when no
   full-resolution ticketFileUrl exists — e.g. Blob storage isn't connected yet) to
   scale up to a legible size instead of rendering at its tiny native resolution;
   height:auto preserves aspect ratio as it scales. Has no effect on a genuine
   full-resolution image, which is already larger than this floor. */
.thumbnail-modal-content img:not([hidden]) {
  max-width: 92vw; max-height: 92vh; min-width: min(480px, 92vw); height: auto;
  border-radius: 8px; display: block;
}
.thumbnail-modal-content img[hidden] { display: none; }
/* Used when the full-resolution ticket file (not the small persisted thumbnail) is
   available — a PDF renders natively and legibly here, far better than stretching a
   320px thumbnail image up to modal size. */
.thumbnail-modal-content iframe#thumbnail-modal-frame:not([hidden]) {
  width: 85vw; height: 88vh; max-width: 900px; border: none; border-radius: 8px; background: #fff; display: block;
}
.thumbnail-modal-content iframe#thumbnail-modal-frame[hidden] { display: none; }
.thumbnail-modal-close {
  position: absolute; top: -14px; right: -14px; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: #fff; font-size: 18px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@media (max-width: 620px) {
  .form-grid { grid-template-columns: 1fr; }
  .entry-grid { grid-template-columns: 1fr; }
}
