/* =========================================================================
   Share Vehicle Tracking — styles
   Loaded by Masterboard.html. Kept separate to avoid bloating Masterboard.
   Chunks A + B + C: modal shell, creation form, share-created view,
                     manage-shares table, context menu.
   ========================================================================= */

/* ── Backdrop + modal shell ──────────────────────────────────────────────── */
#shareBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 1100;
}
#shareBackdrop.open { display: block; }

#shareModal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1101;
  width: 600px;
  max-width: 95vw;
  max-height: 88vh;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .7);
  overflow: hidden;
  flex-direction: column;
  font-size: 13px;
  color: #cbd5e1;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#shareModal.open { display: flex; }

/* Manage view needs more horizontal room — bump width when that view shows */
#shareModal:has(.ms-table) { width: 760px; }

/* ── Header (draggable) ──────────────────────────────────────────────────── */
.share-modal-head {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid #334155;
  display: flex; align-items: center; gap: 12px;
  cursor: move;
  user-select: none;
  background: linear-gradient(180deg, #2a3a55 0%, #1e293b 100%);
}
.share-modal-head h2 {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
}
.share-modal-head h2.success { color: #22c55e; }
.share-modal-head .veh-tag {
  font-family: 'Courier New', monospace;
  background: #0f172a;
  color: #3b82f6;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #334155;
}
.share-modal-head .x {
  margin-left: auto;
  background: none;
  border: none;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  transition: color .15s;
}
.share-modal-head .x:hover { color: #e2e8f0; }

/* ── Body ────────────────────────────────────────────────────────────────── */
.share-modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ── Footer buttons ──────────────────────────────────────────────────────── */
.share-modal-foot {
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid #334155;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #0f172a;
}
.share-btn-primary {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.share-btn-primary:hover { background: #2563eb; }
.share-btn-primary:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
}

.share-btn-secondary {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.share-btn-secondary:hover {
  color: #e2e8f0;
  border-color: #3b82f6;
}

.share-btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, .4);
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.share-btn-danger:hover { background: rgba(239, 68, 68, .1); }

/* ── Form layout ─────────────────────────────────────────────────────────── */
.sf-group { margin-bottom: 18px; }
.sf-group:last-child { margin-bottom: 0; }

.sf-label {
  display: block;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  font-weight: 600;
}

.sf-radio-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sf-radio-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.sf-radio-opt:hover { border-color: #475569; }
.sf-radio-opt.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, .08);
}
.sf-radio-opt input[type="radio"] { accent-color: #3b82f6; }
.sf-radio-opt .sf-opt-label {
  flex: 1;
  font-size: 13px;
  color: #e2e8f0;
}

.sf-select, .sf-input {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.sf-select:focus, .sf-input:focus { border-color: #3b82f6; }

.sf-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.sf-pick-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.sf-pick-btn:hover { color: #e2e8f0; border-color: #3b82f6; }

.sf-subline {
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}

.sf-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.sf-check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e2e8f0;
  cursor: pointer;
}
.sf-check-grid input[type="checkbox"] { accent-color: #3b82f6; }
.sf-check-grid label.disabled {
  color: #64748b;
  cursor: not-allowed;
}

.sf-pwd-row {
  display: flex;
  gap: 8px;
}
.sf-pwd-row input {
  flex: 1;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  outline: none;
}
.sf-pwd-row input:focus { border-color: #3b82f6; }

.sf-dice {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}
.sf-dice:hover { color: #f59e0b; border-color: #f59e0b; }

.sf-warning {
  display: none;
  gap: 10px;
  align-items: flex-start;
  background: rgba(245, 158, 11, .08);
  border: 1px solid rgba(245, 158, 11, .3);
  color: #fbbf24;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-top: 10px;
  line-height: 1.45;
}
.sf-warning.show { display: flex; }
.sf-warning b { color: #f59e0b; }
.sf-warning .w-ico { flex-shrink: 0; font-size: 14px; }

/* "N active shares for this vehicle" banner at top of create form */
.ms-existing-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(59, 130, 246, .08);
  border: 1px solid rgba(59, 130, 246, .3);
  color: #93c5fd;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 12px;
}
.ms-existing-link {
  background: transparent;
  border: 1px solid rgba(59, 130, 246, .5);
  color: #93c5fd;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ms-existing-link:hover { background: rgba(59, 130, 246, .15); color: #fff; }

/* ── Share-created view ──────────────────────────────────────────────────── */
.sc-section-title {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0 0 8px;
}
.sc-section-title + .sc-section-title { margin-top: 18px; }

.sc-link-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #e2e8f0;
  word-break: break-all;
  margin-bottom: 10px;
}

.sc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.sc-mini-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 7px 11px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all .15s;
}
.sc-mini-btn:hover {
  color: #e2e8f0;
  border-color: #3b82f6;
}
.sc-mini-btn.primary {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}
.sc-mini-btn.primary:hover { background: #2563eb; }
.sc-mini-btn.danger { color: #ef4444; border-color: rgba(239, 68, 68, .4); }
.sc-mini-btn.danger:hover { background: rgba(239, 68, 68, .1); }
.sc-mini-btn.flash {
  background: #22c55e !important;
  color: #fff !important;
  border-color: #22c55e !important;
}

.sc-qr-panel {
  display: none;
  margin: 10px 0;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  width: fit-content;
}
.sc-qr-panel.show { display: block; }
.sc-qr-panel svg, .sc-qr-panel img { display: block; }
.sc-qr-caption {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
  font-family: 'Courier New', monospace;
  word-break: break-all;
  max-width: 180px;
}

.sc-expiry-info {
  background: #0f172a;
  border-left: 3px solid #22c55e;
  padding: 10px 14px;
  border-radius: 4px;
  margin: 14px 0;
  font-size: 12px;
  color: #94a3b8;
}
.sc-expiry-info b { color: #22c55e; }

.sc-audit-empty {
  color: #64748b;
  font-size: 12px;
  padding: 10px;
  background: #0f172a;
  border-radius: 6px;
  text-align: center;
}

/* ── Manage shares view ──────────────────────────────────────────────────── */
.ms-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 12px;
  color: #94a3b8;
}
.ms-active-num {
  color: #22c55e;
  font-weight: 700;
  font-size: 14px;
}
.ms-muted { color: #64748b; }
.ms-summary-actions {
  display: flex;
  gap: 8px;
}

.ms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ms-table th {
  text-align: left;
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 10px;
  border-bottom: 1px solid #334155;
  font-weight: 600;
}
.ms-table td {
  padding: 10px;
  border-bottom: 1px solid #334155;
  color: #94a3b8;
  vertical-align: top;
}
.ms-table tr.ms-faded { opacity: .55; }

.ms-label {
  color: #e2e8f0;
  font-weight: 600;
}
.ms-sub {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
}
.ms-empty {
  text-align: center;
  color: #64748b;
  padding: 24px 10px;
  font-style: italic;
}

.ms-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.ms-status.active  { background: rgba(34, 197, 94, .15);  color: #22c55e; }
.ms-status.arrived { background: rgba(168, 85, 247, .15); color: #a855f7; }
.ms-status.expired { background: rgba(100, 116, 139, .15); color: #64748b; }

.ms-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ms-tiny {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
}
.ms-tiny:hover { color: #e2e8f0; border-color: #3b82f6; }
.ms-tiny.danger:hover { color: #ef4444; border-color: #ef4444; }
.ms-tiny.flash {
  background: #22c55e !important;
  color: #fff !important;
  border-color: #22c55e !important;
}

/* ── Right-click context menu ────────────────────────────────────────────── */
#shareCtxMenu {
  display: none;
  position: fixed;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px;
  min-width: 200px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#shareCtxMenu.open { display: block; }
.ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #e2e8f0;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.ctx-item:hover { background: #334155; color: #fff; }

/* ── DEFERRED: Trip-based shares ───────────────────────────────────────────
   Trip-based expiry (arrive-at-geofence / pick-on-map) is deferred until the
   geofence module is built and the production schema drift (polygon vs geom)
   is resolved. The Go backend still accepts expiry_type="trip" — only the UI
   is hidden. Re-enable by deleting the selector below. See
   ShareTracking_v1_Summary.md § Deferred for the full upgrade proposal. */
#shareModal .sf-radio-opt[data-opt="trip"] { display: none; }
/* Also trim the subline — with trip hidden, "whichever first" is confusing */
.sf-subline-trip-note { display: none; }
