/* Cruise Photo-Booking Recommender — dark UI, no external font (Google
   Fonts would be blocked by this project's CSP style-src, and the shared
   duit-sampingan app already hits that same limit), no external JS lib.
   Sizing is tuned for one-handed touch use (this runs on a phone on deck,
   not a desk) — text and tap targets sized generously on purpose, not
   just for legibility but because 16px inputs also stop iOS Safari's
   auto-zoom-on-focus, which is its own usability bug otherwise. */

:root {
  --bg: #0a0c10;
  --panel: #12151c;
  --panel-2: #171b24;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --text-dim: rgba(238, 241, 246, 0.6);
  --text-faint: rgba(238, 241, 246, 0.38);
  --green: #34c759;
  --green-dark: #06210f;
  --blue: #7eb9ff;
  --red: #ff453a;
  /* Kept distinct from --green on purpose: the Predict gauge's low/medium/
     high scale (predict.js gaugeColor()) needs three visually different
     colors to stay meaningful — this is the old --gold value, scoped now
     to that one semantic role instead of doubling as the app's brand
     color (which is --green everywhere else, the whole point of this
     palette — see index.html/README for why: differentiates this tool
     from duit-sampingan's gold theme at a glance). */
  --amber: #f2c66d;
  --sans: -apple-system, "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; }

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 14px;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
}

label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 8px;
  font-weight: 500;
}

.field { margin-bottom: 18px; }

.cabin-hint {
  font-size: 14px;
  margin-top: 7px;
  min-height: 18px;
}
.cabin-hint.found { color: var(--green); }
.cabin-hint.unknown { color: var(--text-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: opacity 0.15s;
  min-height: 48px;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--green); color: var(--green-dark); border-color: transparent; }
.btn-danger { background: rgba(255, 69, 58, 0.15); color: var(--red); border-color: rgba(255, 69, 58, 0.3); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 11px 16px; font-size: 14.5px; min-height: 40px; }

/* ---- Shell / layout ---- */

#screen-auth, #screen-pending {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card, .pending-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
}

.brand {
  text-align: center;
  margin-bottom: 26px;
}
.brand-icon {
  display: block;
  margin: 0 auto 14px;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(52, 199, 89, 0.18);
}
.brand-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 14.5px; color: var(--text-dim); margin-top: 5px; }

.auth-err {
  display: none;
  background: rgba(255, 69, 58, 0.12);
  color: var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14.5px;
  margin-bottom: 16px;
}

.auth-toggle {
  text-align: center;
  margin-top: 18px;
  font-size: 14.5px;
  color: var(--text-dim);
}
.auth-toggle button {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 600;
  font-size: 14.5px;
  padding: 8px;
}

.pending-icon { font-size: 42px; text-align: center; margin-bottom: 12px; }
.pending-card h2 { text-align: center; font-size: 20px; margin: 0 0 10px; }
.pending-card p { text-align: center; color: var(--text-dim); font-size: 15px; line-height: 1.55; margin: 0 0 22px; }

#app { display: none; min-height: 100dvh; flex-direction: column; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.topbar-title { font-size: 17.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.15);
  flex-shrink: 0;
}
.conn-dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.15);
}

.sync-banner {
  font-size: 14px;
  text-align: center;
  padding: 11px 14px;
  background: rgba(52, 199, 89, 0.1);
  color: var(--green);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sync-banner.offline-only {
  background: rgba(255, 69, 58, 0.1);
  color: var(--red);
  cursor: default;
}
.topbar-ship { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-badge {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 100px;
  background: rgba(52, 199, 89, 0.15);
  color: var(--green);
  font-weight: 700;
}

nav.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  gap: 4px;
}
nav.tabs button {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  min-height: 48px;
}
nav.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--green);
}

main {
  flex: 1;
  padding: 18px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
}
.card-sub { font-size: 14px; color: var(--text-faint); margin: -10px 0 16px; line-height: 1.4; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-faint);
  font-size: 15px;
}

/* ---- Probability result ---- */

.result-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gauge-label { font-size: 14px; color: var(--text-dim); text-align: center; }
.gauge-pct { font-size: 14px; font-weight: 700; }

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  margin-bottom: 10px;
}
.breakdown-label { flex: 0 0 150px; color: var(--text-dim); text-align: right; }
.breakdown-bar-track {
  flex: 1;
  height: 9px;
  background: var(--panel-2);
  border-radius: 100px;
  position: relative;
  overflow: hidden;
}
.breakdown-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 100px;
}
.breakdown-val { flex: 0 0 46px; font-family: var(--mono); font-size: 13.5px; color: var(--text-dim); }

.explanation {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 16px;
  margin-top: 4px;
}
.explanation b { color: var(--text); }

/* ---- List rows (history / admin) ---- */

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-main { min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 13px; color: var(--text-faint); margin-top: 3px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 9px;
  border-radius: 100px;
}
.pill-green { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.pill-red { background: rgba(255, 69, 58, 0.15); color: var(--red); }
.pill-gray { background: rgba(255, 255, 255, 0.08); color: var(--text-faint); }
.pill-accent { background: rgba(52, 199, 89, 0.15); color: var(--green); }

/* ---- Admin sub-tabs ---- */

.subtabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.subtabs button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 100px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 600;
  min-height: 44px;
}
.subtabs button.active { background: var(--green); color: var(--green-dark); border-color: transparent; }

.weight-editor {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.weight-editor:last-child { border-bottom: none; }
.weight-editor .we-label { flex: 1; font-size: 14.5px; }
.weight-editor input[type="number"] { width: 84px; text-align: center; padding: 10px; }

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14.5px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.err { color: var(--red); }

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .breakdown-label { flex-basis: 110px; }
}
