/* LoadMatch Mobile Design System */
:root {
  --bg-dark: #0b0f19;
  --bg-surface: #131b2e;
  --card-bg: rgba(30, 41, 59, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-azure: #3b82f6;
  --accent-azure-hover: #2563eb;
  --accent-whatsapp: #25d366;
  --accent-whatsapp-hover: #128c7e;
  --accent-danger: #ef4444;
  --accent-amber: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

/* APP SHELL */
.phone-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-dark);
}

/* HEADER */
/* WRAPS RATHER THAN CLIPS.
 *
 * At 360px this row needed 396px — brand 132 + account 232 + 32 padding — and
 * .phone-shell is overflow:hidden, so the sign-out button was drawn 21px off the
 * screen with 23px of its 44px target left. It still took a tap at the visible
 * centre, which is why nobody caught it: degraded, not dead.
 *
 * flex-wrap only fires when the row genuinely cannot hold both, so a 390px phone
 * still renders one row. See DECISIONS.md #header-wraps-instead-of-clipping.
 */
.phone-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
  z-index: 10;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo-small {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-azure), var(--accent-emerald));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.85rem;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.account-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* NOT justify-content: space-between on the parent — that distributes each flex
   * LINE separately, so once this wraps it becomes its line's only item and lands
   * flush LEFT under the brand. margin-left:auto is the one that survives the wrap,
   * and it holds this hard right whether it shares row one or owns row two. */
  margin-left: auto;
}

.account-name-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

.btn-signout:active {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* MAIN SCROLLABLE CONTENT */
.phone-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 1rem calc(70px + var(--safe-bottom)) 1rem;
}

/* When send bar is visible on Stuur screen */
.phone-content.has-send-bar {
  padding-bottom: calc(140px + var(--safe-bottom));
}

.mobile-view {
  display: none;
  width: 100%;
}

.mobile-view.active {
  display: block;
}

/* DISPATCH CONTEXT CARD (Mine + Date) */
.dispatch-context-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.context-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.context-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-toggle {
  font-size: 0.75rem;
  color: var(--accent-azure);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.context-select, .context-input {
  width: 100%;
  height: 44px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 0.65rem;
  font-size: 0.9rem;
  outline: none;
}

.context-select:focus, .context-input:focus {
  border-color: var(--accent-azure);
}

.details-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
}

.extra-details-pane {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--card-border);
}

.extra-details-pane.open {
  display: flex;
}

/* RIGS LIST (STUUR) */
.rigs-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.rigs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.2rem;
}

.rigs-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge-count {
  background: var(--accent-azure);
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 12px;
  font-weight: 700;
}

.btn-select-all {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0 0.6rem;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.btn-select-all:active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.rig-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rig-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-height: 44px;
}

.rig-card.selected {
  border-color: var(--accent-azure);
  background: rgba(59, 130, 246, 0.1);
}

.rig-checkbox-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.rig-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-azure);
  cursor: pointer;
}

.rig-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.rig-primary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rig-combo-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.rig-verdict-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.rig-sub-line {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.rig-sub-line span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* BADGES */
.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  white-space: normal;
  word-break: break-word;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-secondary {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* STATS GRID (VLOOT / MYNE / DOKUMENTE) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
}

.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* SECTION BLOCKS */
.section-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.1rem;
}

/* ASSET / ENTITY CARD (Vloot / Myne / Dokumente) */
.asset-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.asset-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.asset-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.asset-primary-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.asset-secondary-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-card-action {
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-card-action:active {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-azure);
}

/* DOCUMENT COMPLIANCE ROWS */
.doc-rows-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.doc-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.doc-name {
  font-size: 0.75rem;
  color: var(--text-main);
  font-weight: 500;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-doc-update {
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  color: var(--accent-azure);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SITE CARDS (MYNE) */
.site-contact-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.site-contact-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-main);
  text-decoration: none;
  min-height: 44px;
  padding: 0 0.2rem;
}

.site-contact-link:active {
  color: var(--accent-azure);
}

.empty-rigs {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
}

/* FIXED BOTTOM SEND BAR (STUUR ONLY) */
.fixed-send-bar {
  position: absolute;
  bottom: calc(56px + var(--safe-bottom));
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--card-border);
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.4rem;
  z-index: 20;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
}

.send-btn {
  flex: 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: opacity 0.15s ease;
}

.send-btn:active {
  opacity: 0.8;
}

.send-btn i {
  font-size: 0.95rem;
}

.btn-whatsapp { background: var(--accent-whatsapp); }
.btn-pdf { background: var(--accent-danger); }
.btn-csv { background: var(--accent-emerald); }
.btn-email { background: var(--accent-azure); }

/* BOTTOM NAVIGATION BAR */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--card-border);
  display: flex;
  z-index: 30;
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  padding: 0.2rem 0;
}

.nav-item i {
  font-size: 1.1rem;
}

.nav-item.active {
  color: var(--accent-azure);
  font-weight: 700;
}

.nav-item:active {
  background: rgba(255, 255, 255, 0.04);
}

/* AUTH MODAL */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card-mobile {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-card-mobile h2 {
  font-size: 1.4rem;
  text-align: center;
}

.auth-card-mobile .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.auth-card-mobile label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-card-mobile input {
  height: 44px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: white;
  padding: 0 0.75rem;
  font-size: 1rem;
}

.auth-btn-primary {
  height: 48px;
  background: var(--accent-azure);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-card .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-card label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.btn-secondary {
  min-height: 44px;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-primary {
  min-height: 44px;
  padding: 0 1rem;
  background: var(--accent-azure);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ---- VERVAL (renewal triage) --------------------------------------------
   Rows are full-width buttons: the whole row is the tap target, not an icon
   inside it. 56px minimum height clears the 44px guideline with room for a
   gloved thumb, which is the hand this screen is actually used by.          */

.verval-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.5rem;
}

.verval-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.verval-counts {
  font-size: 0.78rem;
  opacity: 0.75;
  text-align: right;
  /* The three counts must wrap rather than push the row wider than 390px. */
  min-width: 0;
}

.verval-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "asset badge"
    "doc   badge";
  align-items: center;
  gap: 0.15rem 0.75rem;
  width: 100%;
  min-height: 56px;
  padding: 0.7rem 1rem;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.verval-row:active { background: rgba(255, 255, 255, 0.06); }

.verval-asset {
  grid-area: asset;
  font-weight: 600;
  /* A long reg or a long driver name truncates instead of widening the page. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.verval-doc {
  grid-area: doc;
  font-size: 0.8rem;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.verval-row .badge {
  grid-area: badge;
  justify-self: end;
  white-space: nowrap;
}

/* ---- SURFACE SWITCH -----------------------------------------------------
   Sits above the bottom nav, quiet but visible. Not in a settings screen:
   the case it exists for is a device guessed wrong at a boom gate.        */

/* The switch-to-desktop control, now in the header beside sign-out. Was
   .surface-switch at the end of the shell, drawn under the bottom navigation.
   See DECISIONS.md #switch-link-under-the-nav. */
.btn-surface {
  background: none;
  border: none;
  color: var(--text-muted);
  min-height: 40px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-surface:active {
  color: var(--accent-azure);
}


/* ── Yard actions and the way out of the sign-in screen ──────────────────────
   Added with #phone-can-do-the-yard-jobs. Both use tokens already defined
   above rather than fresh colours, so the phone keeps one palette. */

.yard-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.yard-actions button {
  flex: 1;
  /* 44px is the touch target a gloved hand can hit on a moving truck's step. */
  min-height: 44px;
  font-size: 0.85rem;
}

.auth-aux-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--card-border);
  text-align: center;
}

.auth-link-btn {
  background: none;
  border: none;
  color: var(--accent-azure);
  font: inherit;
  font-size: 0.85rem;
  /* Not a link in a paragraph: a target big enough to hit without zooming. */
  min-height: 40px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-link-btn:active {
  opacity: 0.6;
}
