:root {
  --navy: #2D3955;
  --navy-dark: #232D42;
  --teal: #13C5BD;
  --teal-dark: #0FA69F;
  --green: #3F7D3F;
  --red: #B03A2E;
  --amber: #8A6D3B;
  --grey: #666666;
  --border: #DDDDDD;
  --bg: #F5F7FA;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #FFFFFF;
  color: #222222;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---- RTL support: mirrors layout for Arabic, Urdu, etc. without a webfont ---- */
html[dir="rtl"] .doc-title-inner { flex-direction: row-reverse; }
html[dir="rtl"] .doc-title-text { text-align: right; }
html[dir="rtl"] .ticket-field { flex-direction: row-reverse; }
html[dir="rtl"] .checkbox-label { flex-direction: row-reverse; }
html[dir="rtl"] .evidence-item { flex-direction: row-reverse; }
html[dir="rtl"] .brand-block { text-align: right; }

/* ============================================================
   Header — navy block with the white logo sitting to the left
   of the Complaint Register heading.
   ============================================================ */
.doc-title-block {
  background: var(--navy);
  padding: 20px;
}

.doc-title-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;   /* group sits centred, not pinned left */
  gap: 26px;
}

.brand-logo {
  height: 67px;
  width: auto;
  aspect-ratio: 709 / 285;   /* the logo's true ratio -- locked, cannot stretch */
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.doc-title-text { min-width: 0; }

.doc-title-eyebrow {
  margin: 0 0 3px 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #A9BBD4;
}

.doc-title-main {
  margin: 0 0 4px 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--teal);
  line-height: 1.15;
}

.doc-title-sub {
  margin: 0;
  font-size: 12px;
  color: #C3D3E8;
}

/* On narrow screens the logo and text stack rather than squeezing the
   heading into an unreadable column beside a shrinking logo. */
@media (max-width: 560px) {
  .doc-title-inner {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  .doc-title-text { text-align: center; }
  .brand-logo { height: 54px; }
  .doc-title-main { font-size: 20px; }
}

.lang-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.lang-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  justify-content: flex-end;
}
html[dir="rtl"] .lang-bar-inner { justify-content: flex-start; }

/* ============================================================
   Generic in-form searchable picker (vessel, and reusable for any
   other long list). Visually matches a normal <select> so it sits
   naturally next to Category/Priority, unlike the compact header
   language picker.
   ============================================================ */
.field-picker {
  position: relative;
}

.field-picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #FFFFFF;
  color: #222222;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
html[dir="rtl"] .field-picker-button { text-align: right; }

.field-picker-button:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.field-picker-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(45, 57, 85, 0.18);
  z-index: 40;
  overflow: hidden;
}
.lang-picker {
  position: relative;
  flex-shrink: 0;
}

.lang-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 140px;
}

.lang-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-caret { font-size: 10px; color: var(--grey); }

.lang-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 260px;
  max-width: 80vw;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(45, 57, 85, 0.18);
  z-index: 50;
  overflow: hidden;
}

html[dir="rtl"] .lang-panel { right: auto; left: 0; }

.lang-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  border-radius: 0;
}
.lang-search:focus { outline: none; background: var(--bg); }

.lang-list {
  max-height: 320px;
  overflow-y: auto;
}

.lang-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 14px;
  color: #222222;
  cursor: pointer;
}
html[dir="rtl"] .lang-option { text-align: right; }

.lang-option:hover, .lang-option.highlighted { background: var(--bg); }
.lang-option.selected { color: var(--navy); font-weight: 700; background: #EAF2F1; }

.lang-divider {
  padding: 6px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.lang-no-results {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--grey);
  text-align: center;
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-nav {
  display: flex;
  max-width: 960px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  flex: 1;
  padding: 13px 12px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--grey);
  cursor: pointer;
}

.tab-button.active {
  color: var(--navy);
  border-bottom-color: var(--teal);
}

/* ============================================================
   Layout — mobile-first, widens into a real desktop layout
   ============================================================ */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 60px 16px;
}

.tab-panel[hidden] { display: none; }

label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin: 16px 0 6px 0;
}

/* Every text-entry input type must be listed here. An earlier version only
   covered type="text", so switching the contact field to type="tel" for the
   numeric keypad silently dropped all its styling and left it rendering at
   the browser's default size, visibly mismatched against every other field. */
select,
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="date"],
textarea {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
}

select:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

textarea { resize: vertical; }

/* Section blocks styled after the document's tables: a navy header bar
   with white caps text, content beneath inside a bordered box. */
fieldset {
  margin-top: 24px;
  border: none;
  border-radius: 0;
  padding: 0;
  min-width: 0;
}

fieldset legend {
  /* Rendered as a full-width bar rather than an inline legend, so it reads
     like the document's table headers. */
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  background: var(--navy);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  box-sizing: border-box;
}

.fieldset-body {
  padding: 4px 14px 16px 14px;
  border: 1px solid var(--navy);
  border-top: none;   /* the navy legend bar above IS the top edge */
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  margin: 0;
}

.checkbox-label input { width: auto; accent-color: var(--teal); }

/* ---- Evidence ---- */
.file-label, .secondary-button {
  display: inline-block;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--navy);
}

.voice-controls {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.recording-status {
  font-size: 13px;
  color: var(--red);
  font-weight: 600;
}

.evidence-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.evidence-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.evidence-item .remove-evidence {
  background: none;
  border: none;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.evidence-status {
  font-size: 11px;
  color: var(--grey);
}

/* ============================================================
   Buttons — navy for primary actions (matches the wordmark),
   teal reserved for focus states and the resolved status badge
   ============================================================ */
#submitButton, #newComplaintButton, #queuedOkButton, #statusCheckButton,
#retryNowButton, #sentResultsOkButton {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #FFFFFF;
  background: var(--navy);
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

#submitButton:hover, #newComplaintButton:hover, #queuedOkButton:hover,
#statusCheckButton:hover, #retryNowButton:hover, #sentResultsOkButton:hover {
  background: var(--navy-dark);
}

#submitButton:disabled, #statusCheckButton:disabled {
  background: #9AA5B8;
  cursor: not-allowed;
}

.banner {
  padding: 14px;
  border-radius: 6px;
  margin: 12px auto;
  max-width: 480px;
  font-size: 14px;
}

.banner-error {
  background: #FDEDEC;
  border: 2px solid var(--red);
  color: var(--red);
  font-weight: 600;
}

@keyframes bannerFlash {
  0%   { box-shadow: 0 0 0 4px rgba(176, 58, 46, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(176, 58, 46, 0); }
}
.banner-flash { animation: bannerFlash 1s ease-out; }

.banner-success {
  background: #EAF3EA;
  border: 1px solid var(--green);
  color: #2A5A2A;
}

.banner-success h2 { margin: 0 0 6px 0; font-size: 18px; }
.banner-success p { margin: 0; }

.banner-offline {
  background: #FCF3D6;
  border: 1px solid var(--amber);
  color: #6B5327;
}

.banner-queued {
  background: #E3FBFA;
  border: 1px solid var(--teal);
  color: var(--navy);
}

.banner-queued-full {
  background: #E3FBFA;
  border: 1px solid var(--teal);
  color: var(--navy);
  padding: 16px;
  border-radius: 6px;
}

.banner-queued-full h2 { margin: 0 0 8px 0; font-size: 18px; }

.ticket-box {
  background: #FFFFFF;
  border: 1px solid var(--navy);
  border-radius: 0;
  padding: 0;
}

.ticket-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
}

.ticket-field + .ticket-field { border-top: 1px solid var(--navy); }

.ticket-label { font-size: 13px; color: var(--grey); }

.ticket-value {
  font-size: 17px;
  font-weight: 700;
  font-family: "Courier New", monospace;
  letter-spacing: 0.5px;
  color: var(--navy);
}

.hint {
  font-size: 13px;
  color: var(--grey);
  text-align: center;
  margin-top: 12px;
}

/* ---- Status lookup ---- */
.status-result {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  background: var(--bg);
}

.status-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  color: #FFFFFF;
  background: var(--navy);
}

.status-badge.resolved { background: var(--teal-dark); }

.status-detail {
  margin-top: 12px;
  font-size: 14px;
  color: #444444;
}

.status-detail p { margin: 4px 0; }

/* ============================================================
   Desktop layout (laptop / wider screens)
   Below this width the mobile single-column layout above applies
   unchanged -- nothing here removes mobile support, it only adds
   a wider, multi-column arrangement once there's room for it.
   ============================================================ */
@media (min-width: 768px) {
  main {
    max-width: 720px;
    padding: 32px 24px 80px 24px;
  }

  #formView, #successView, #queuedView, #statusTab {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(45, 57, 85, 0.06);
  }

  /* Vessel / Category / Priority side by side once there's room */
  #complaintForm .row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
  }
  #complaintForm .row-3 label { margin-top: 0; }

  .ticket-box { max-width: 420px; margin: 0 auto; }

  .banner, .status-result { max-width: 100%; }
}

@media (min-width: 1100px) {
  main { max-width: 860px; }
}

/* ============================================================
   Build marker — lets anyone confirm at a glance whether the
   deployed copy is current or a stale cached one. Deliberately
   small and unobtrusive, but present on every page load.
   ============================================================ */
.build-marker {
  text-align: center;
  font-size: 10px;
  color: #AAAAAA;
  padding: 12px 0 20px 0;
  letter-spacing: 0.5px;
}

/* Secondary (less prominent) action button, e.g. "OK" sitting
   beneath a primary "Send now". */
.secondary-action {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.secondary-action:hover { background: var(--bg); }

.sent-ticket-box + .sent-ticket-box { margin-top: 12px; }

/* ============================================================
   Complaint type toggle + MLC-specific fields
   ============================================================ */
.type-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.type-toggle-option {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.type-toggle-option:has(input:checked) {
  border-color: var(--teal);
  background: #E3FBFA;
}

.type-toggle-option input { width: auto; margin: 0; }



.mlc-mapping-note {
  margin: 0 0 4px 0;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}




input[type="date"] {
  min-height: 42px;
  color: #222222;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.65;
  padding: 2px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}


/* ============================================================
   MLC document-style grid -- mirrors the actual OFCO paper form's
   layout (label chip beside input, inside a real bordered table),
   using the app's own navy/teal rather than the document's raw
   colors, so it still reads as one consistent product.
   ============================================================ */
.doc-grid { border: 1px solid var(--navy); border-radius: 4px; overflow: hidden; }

.doc-row {
  display: flex;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.doc-row:first-of-type { border-top: none; }

.doc-pair {
  display: flex;
  align-items: stretch;
  flex: 1 1 260px;
  min-width: 0;
  border-left: 1px solid var(--border);
}
.doc-pair:first-child { border-left: none; }
.doc-pair-wide { flex: 1 1 100%; }

.doc-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: var(--navy);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12.5px;
  padding: 10px 12px;
  min-width: 110px;
  letter-spacing: 0.2px;
}

.doc-value {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  font-size: 14px;
  min-height: 40px;
  min-width: 0;
}
.doc-value:focus { outline: 2px solid var(--teal); outline-offset: -2px; }

.doc-value-radios {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.doc-value-radios .checkbox-label { font-weight: normal; margin: 0; }

/* Full-width section bar -- matches the paper form's own section
   headers (VESSEL DETAILS, SEAFARER DETAILS) exactly in role, using
   the app's navy instead of the document's lighter slate-blue. */
.doc-section-bar {
  margin: 0;
  padding: 9px 12px;
  background: var(--navy);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-top: 1px solid var(--border);
}

/* Stack label above input on narrow screens -- the doc's side-by-side
   layout gets cramped below ~420px, same reasoning as everywhere else
   in this form that adapts for mobile. */
@media (max-width: 420px) {
  .doc-pair { flex-direction: column; border-left: none; border-top: 1px solid var(--border); }
  .doc-row > .doc-pair:first-child { border-top: none; }
  .doc-chip { min-width: 0; }
}
