/* Pico.css (loaded in base.html) handles body/typography, nav, form, button, table and
   article styling on plain semantic HTML with no extra classes -- this file only keeps what
   Pico has no opinion on, plus a compact-density override so a tab's content has a shot at
   fitting one screen without scrolling. */

:root {
  /* Pico's own recommended technique for a denser UI: its spacing/typography is rem-based,
     so shrinking the root size scales paddings/margins/gaps everywhere at once. */
  --pico-font-size: 80%;
  --pico-spacing: 0.55rem;
}

main.container {
  padding-block: 0.75rem;
}

h1, h2, h3 {
  margin-block: 0.25rem 0.5rem;
}

.inline-form {
  display: inline;
}

.flash {
  background: var(--pico-mark-background-color, #fff3cd);
  border: 1px solid var(--pico-mark-color, #ffe08a);
  padding: 0.4rem 0.75rem;
  border-radius: var(--pico-border-radius);
  list-style: none;
  margin: 0 0 0.75rem;
}

.error {
  color: var(--pico-del-color, #a00);
}

.hint {
  color: var(--pico-muted-color);
  font-size: 0.85em;
  margin-block: 0.25rem;
}

.user-badge {
  color: var(--pico-muted-color);
  font-size: 0.9em;
}

.checkbox {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-block: 0.4rem;
}

/* Compact start forms -- these are secondary to the map/log once something is running, and
   the user explicitly asked for smaller inputs so the map/log get the room. */
.compact-form label {
  margin-bottom: 0.3rem;
  font-size: 0.9em;
}

.compact-form input, .compact-form select {
  padding: 0.3rem 0.5rem;
  font-size: 0.95em;
  margin-bottom: 0;
}

/* Running/stopped indicator, shown instead of the start form once a process exists for that
   tab -- a single Start/Stop slot per tab, mirroring control_panel.py's ttk.Notebook (one
   script, one button, never a duplicated map). */
.panel-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: var(--pico-card-sectioning-background-color, var(--pico-background-color));
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  margin-bottom: 0.5rem;
}

.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--pico-muted-color);
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.running {
  background: #2ecc71;
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.25);
}

.extra-processes {
  margin-top: 0.5rem;
}

/* Deliberately theme-independent -- a dark terminal look regardless of light/dark page mode. */
.log {
  background: #111;
  color: #d6ffd6;
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  white-space: pre-wrap;
  border-radius: var(--pico-border-radius);
  margin-bottom: 0.4rem;
}

.route-editor-map {
  height: 380px;
  margin-bottom: 0.4rem;
  border-radius: var(--pico-border-radius);
}

.route-editor-grid {
  align-items: start;
}

.waypoint-table-wrap {
  max-height: 160px;
  overflow-y: auto;
}

.waypoint-table {
  margin-bottom: 0;
}

.waypoint-table td, .waypoint-table th {
  padding: 0.2rem 0.5rem;
}

.waypoint-table td {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}

/* --- Tabs (mirrors control_panel.py's ttk.Notebook) --- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.tab-button {
  /* Explicit colors, not Pico's button vars: Pico's default <button> pairs a filled
     background with a light/inverse text color meant to contrast against THAT background --
     stripping the background here left the text almost invisible against the page. */
  background: none !important;
  border: none;
  box-shadow: none;
  padding: 0.4rem 1rem;
  margin: 0 0 -1px 0;
  cursor: pointer;
  color: #57606a !important;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-size: 0.95em;
}

.tab-button:hover {
  color: #1a1a1a !important;
}

.tab-button.active {
  color: #1a1a1a !important;
  border-bottom-color: var(--pico-primary);
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .tab-button {
    color: #9aa4af !important;
  }
  .tab-button:hover {
    color: #f0f0f0 !important;
  }
  .tab-button.active {
    color: #f5f5f5 !important;
  }
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ============ Simulación: cockpit layout (status bar / side panel + map / traffic) ============ */

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.4rem 0.8rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-sectioning-background-color, var(--pico-background-color));
  font-size: 0.9em;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.statusbar-outputs {
  margin-left: auto;
  color: var(--pico-muted-color);
}

.statusbar-outputs strong {
  color: var(--pico-color);
}

.output-clients {
  margin-left: 0.2rem;
  font-size: 0.9em;
}

.output-clients.has-clients {
  color: #27ae60;
  font-weight: 600;
}

/* "Conecta NOVA Connect a host:port" line above the cockpit. */
.connect-hint {
  position: relative; /* anchors the QR popover */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  padding: 0.35rem 0.8rem;
  margin-bottom: 0.6rem;
  border-left: 4px solid var(--pico-primary);
  background: var(--pico-card-sectioning-background-color, var(--pico-background-color));
  border-radius: var(--pico-border-radius);
}

.connect-hint strong {
  font-family: var(--pico-font-family-monospace);
  font-size: 1.1em;
}

.connect-hint button {
  width: auto;
  padding: 0.1rem 0.6rem;
  margin: 0;
  font-size: 0.8em;
}

/* Configuration (2/5) | draggable divider | map (3/5). boat_panel.js rewrites
   grid-template-columns when the divider is dragged; everything stacks on narrow screens. */
.cockpit {
  --cockpit-height: calc(100vh - 12rem);
  display: grid;
  grid-template-columns: minmax(380px, 2fr) 8px 3fr;
  gap: 0.4rem;
  align-items: stretch;
}

.config-pane {
  height: max(560px, var(--cockpit-height));
  overflow-y: auto;
  padding-right: 0.35rem;
  min-width: 0;
}

.cockpit-divider {
  cursor: col-resize;
  border-radius: 4px;
  background: var(--pico-muted-border-color);
  opacity: 0.5;
  touch-action: none;
}

.cockpit-divider:hover {
  opacity: 1;
}

.cockpit-map {
  min-width: 0;
}

.cockpit-map .live-map-big {
  height: max(560px, var(--cockpit-height));
  margin: 0;
  border-radius: var(--pico-border-radius);
}

@media (max-width: 900px) {
  .cockpit {
    grid-template-columns: 1fr !important;
  }
  .cockpit-divider {
    display: none;
  }
  .config-pane {
    height: auto;
  }
  .cockpit-map .live-map-big {
    height: 380px;
  }
}

/* Barco / Tierra tabs stay visible while the pane scrolls. */
.config-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--pico-background-color);
}

.boat-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.boat-head button {
  margin: 0 0 0 auto;
  padding: 0.3rem 1rem;
  width: auto;
}

/* Label + control + small buttons on one line. */
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.4rem 0.6rem;
}

.field-row > label {
  flex: 1;
  min-width: 12rem;
  margin-bottom: 0.3rem;
}

.field-row > button {
  width: auto;
  padding: 0.25rem 0.7rem;
  margin-bottom: 0.3rem;
  font-size: 0.85em;
}

/* Numbered cards of the Barco tab: 1 Recorrido, 2 Barco (type -> situation, routing, devices),
   3 Piloto automático. Sub-sections inside a card get a lighter heading with a rule. */
.config-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.5rem 0.8rem 0.3rem;
  margin-bottom: 0.8rem;
  background: var(--pico-background-color);
}

.card-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 1.15em;
  margin: 0 0 0.5rem;
}

.card-title .hint {
  font-weight: 400;
  font-size: 0.75em;
}

summary.card-title {
  margin: 0;
  padding-block: 0.2rem;
}

details[open] > summary.card-title {
  margin-bottom: 0.5rem;
}

.card-num {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  font-size: 0.8em;
  flex-shrink: 0;
}

.card-sub {
  font-size: 0.95em;
  margin: 0.8rem 0 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--pico-muted-border-color);
}

.card-sub .hint {
  font-weight: 400;
}

.card-locked {
  margin-bottom: 0.4rem;
}

/* A line of small options (loop, start point, tick) that stays visible. */
.option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin-bottom: 0.35rem;
}

.option-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
}

.option-row input[type="text"] {
  width: 7.5rem;
  margin: 0;
  padding: 0.15rem 0.4rem;
  height: auto;
}

.option-row input.input-short {
  width: 3.5rem;
}

/* The routing fieldset is just a container inside the card. */
.config-card .routing-picker {
  border: none;
  padding: 0;
  margin: 0 0 0.4rem;
}

/* "¿Qué significan estos términos?" as a small link, not a section-looking row. */
.condition-picker .glossary > summary {
  display: inline-block;
  font-size: 0.85em;
  color: var(--pico-primary);
  cursor: pointer;
}

.condition-picker .glossary > summary::after {
  display: none;
}

.badge-modified {
  align-self: center;
  font-size: 0.75em;
  padding: 0 0.45rem;
  border-radius: 0.6rem;
  border: 1px solid #e67e22;
  color: #e67e22;
}

.badge-modified[hidden] {
  display: none;
}

/* Device table: ON | name | 0183 | N2K | fault. The two route columns only show while
   customizing the routing per device. */
.device-table {
  margin-bottom: 0.4rem;
  font-size: 0.95em;
}

.device-table th,
.device-table td {
  padding: 0.15rem 0.4rem;
  vertical-align: middle;
}

.device-table th {
  font-size: 0.8em;
  color: var(--pico-muted-color);
}

.device-table .device-cat td {
  padding-top: 0.5rem;
  font-size: 0.78em;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.device-table .on-cell {
  white-space: nowrap;
  width: 3.2rem;
}

.device-table .on-cell input {
  margin: 0 0.3rem 0 0;
}

.device-table .activity-dot {
  display: inline-block;
}

.device-table .name-cell {
  line-height: 1.25;
}

.device-table .route-col {
  display: none;
  text-align: center;
  width: 3.5rem;
}

.device-table.show-routes .route-col {
  display: table-cell;
}

.device-table .route-col input {
  margin: 0;
}

.route-native {
  font-size: 0.72em;
  color: #27ae60;
}

.route-none {
  color: var(--pico-muted-color);
}

.device-timer {
  font-size: 0.85em;
  color: #2980b9;
}

.device-timer:empty {
  display: none;
}

.duration-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.9em;
}

.segmented-small span {
  padding: 0.1rem 0.6rem !important;
  font-size: 0.85em;
}

/* "Personalizado" only appears once the routing really is custom. */
.custom-mode {
  display: none !important;
}

.custom-mode:has(input:checked) {
  display: block !important;
}

.routing-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
}

.routing-summary button {
  width: auto;
  padding: 0.15rem 0.6rem;
  margin: 0;
  font-size: 0.8em;
}

/* Bottom row: events (what the tester changed) next to the traffic log. */
.bottom-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 3fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.bottom-row .traffic {
  margin-top: 0;
  min-width: 0;
}

.event-list {
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  font-size: 0.85em;
}

.event-list li {
  list-style: none;
  padding: 0.1rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.event-list time {
  font-family: var(--pico-font-family-monospace);
  color: var(--pico-muted-color);
  margin-right: 0.3rem;
}

@media (max-width: 900px) {
  .bottom-row {
    grid-template-columns: 1fr;
  }
}

.side-section {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.3rem 0.7rem;
  margin-bottom: 0.6rem;
}

.side-section > summary {
  font-weight: 600;
  font-size: 1.05em;
}

.side-section h4 {
  font-size: 0.95em;
  margin: 0.6rem 0 0.3rem;
}

.side-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 0.3rem;
}

.side-status form {
  margin-left: auto;
}

.side-status button {
  padding: 0.2rem 0.7rem;
  margin: 0;
}

.discovery-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.discovery-row button {
  white-space: nowrap;
}

.discovery-row input {
  font-size: 0.8em;
  height: auto;
  padding: 0.2rem 0.4rem;
  margin: 0;
}

.discovery-row button {
  padding: 0.2rem 0.6rem;
  margin: 0;
  font-size: 0.8em;
}

.local-caster-form > summary {
  font-size: 0.9em;
}

/* Device groups and rows (switch, activity dot, name, protocol, status). */
.device-group {
  margin-block: 0.3rem;
}

.device-group > summary,
.device-group > legend {
  font-size: 0.85em;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Name on top, protocol + route underneath, so the row keeps one line per item however long. */
.device-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.device-name {
  font-weight: 500;
}

.device-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--pico-muted-color);
}

.device-bus {
  font-size: 0.72em;
  padding: 0 0.4rem;
  border-radius: 0.6rem;
  border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
  white-space: nowrap;
  cursor: help;
}

.activity-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--pico-muted-border-color);
  flex-shrink: 0;
  transition: background 0.2s;
}

.activity-dot.active {
  background: #2ecc71;
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.3);
}

/* Boat marker: a dot until a heading is known, then an arrow rotated to it. */
.boat-icon {
  background: none;
  border: none;
}

.boat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1c2833;
  border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}

.boat-arrow {
  width: 28px;
  height: 28px;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}

.boat-arrow svg {
  display: block;
}

.beacon-icon {
  background: none;
  border: none;
}

.beacon {
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 50%;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(231, 76, 60, 0.85);
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.35);
  animation: beacon-pulse 1.2s ease-in-out infinite;
}

@keyframes beacon-pulse {
  50% {
    box-shadow: 0 0 0 10px rgba(231, 76, 60, 0.1);
  }
}

.link-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #c0392b;
}

/* "Conexiones NTRIP" box under the map's layers control -- same look as that control. */
.map-info-box {
  background: #fff;
  color: #333;
  padding: 6px 10px;
  border-radius: 5px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  font-size: 0.8rem;
  line-height: 1.5;
}

.map-info-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.map-info-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.map-instruments .map-info-row {
  justify-content: space-between;
  gap: 1rem;
}

.map-info-key {
  color: #666;
}

/* Pico's select padding outranks a plain class, hence the longer selector. */
.device-table select.device-fault {
  width: auto;
  margin: 0;
  padding: 0 1.6rem 0 0.4rem;
  height: 1.7rem;
  line-height: 1.6rem;
  font-size: 0.75em;
  background-position: center right 0.3rem;
}

.device-fault.active {
  border-color: #e67e22;
  color: #e67e22;
}

.device-fault-desc {
  font-size: 0.85em;
  color: #e67e22;
}

.map-info-swatch {
  width: 14px;
  border-top: 2px dashed #e74c3c;
}

/* Traffic panel: every process's live output, filterable by source. */
.traffic {
  margin-top: 0.75rem;
}

.traffic-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.traffic-bar > button {
  padding: 0.15rem 0.6rem;
  margin: 0;
  font-size: 0.85em;
}

.traffic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1;
}

.traffic-chip {
  padding: 0.1rem 0.6rem;
  margin: 0;
  font-size: 0.8em;
  border-radius: 1rem;
  background: none;
  color: var(--pico-muted-color);
  border: 1px solid var(--pico-muted-border-color);
}

.traffic-chip.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary-background);
}

.traffic-log {
  height: 220px;
}

/* ============ Editores: sub-tabs ============ */

.subtabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.subtab-button {
  padding: 0.2rem 0.9rem;
  margin: 0;
  font-size: 0.9em;
  border-radius: 1rem;
  background: none;
  color: var(--pico-muted-color);
  border: 1px solid var(--pico-muted-border-color);
}

.subtab-button.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary-background);
}

.subtab-panel {
  display: none;
}

.subtab-panel.active {
  display: block;
}

/* ============ Barco: routing picker (segmented buttons + selected mode's explanation) ============ */

.routing-picker {
  margin-block: 0.4rem;
}

.routing-picker legend {
  font-size: 0.85em;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  overflow: hidden;
}

.segmented label {
  flex: 1 1 auto;
  margin: 0;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 0.3rem 0.5rem;
  text-align: center;
  font-size: 0.78em;
  white-space: nowrap;
  border-right: 1px solid var(--pico-muted-border-color);
}

.segmented label:last-child span {
  border-right: none;
}

.segmented input:checked + span {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  font-weight: 600;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--pico-primary);
  outline-offset: -2px;
}

.routing-desc {
  margin: 0.3rem 0 0.2rem;
}

.routing-custom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0.25rem 0;
  font-size: 0.8em;
}

.routing-custom-label {
  min-width: 9.5rem;
  color: var(--pico-muted-color);
}

.chip-check {
  margin: 0;
  cursor: pointer;
}

.chip-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-check span {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 1rem;
  border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
}

.chip-check input:checked + span {
  background: var(--pico-primary-background);
  border-color: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.device-route {
  font-size: 0.72em;
}

/* ============ Barco: autopilot remote ============ */

.autopilot-box {
  border-top: 1px solid var(--pico-muted-border-color);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}

.autopilot-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.3rem 0;
}

.autopilot-buttons button {
  padding: 0.15rem 0.55rem;
  margin: 0;
  font-size: 0.8em;
}

.autopilot-buttons button.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.autopilot-sep {
  width: 0.6rem;
}

/* ============ Barco: "Condiciones" picker ============ */

.condition-picker {
  margin-block: 0.4rem 0.6rem;
}

.condition-picker select {
  margin-bottom: 0.3rem;
}

.condition-desc {
  font-size: 0.85em;
  padding: 0.35rem 0.6rem;
  border-left: 3px solid var(--pico-primary);
  background: var(--pico-card-sectioning-background-color, transparent);
  margin-bottom: 0.3rem;
}

.condition-desc .hint {
  margin-block: 0.2rem 0;
}

.glossary > summary {
  font-size: 0.85em;
  color: var(--pico-primary);
}

.glossary dl {
  font-size: 0.82em;
  margin: 0.3rem 0 0;
}

.glossary dt {
  font-weight: 600;
  margin-top: 0.3rem;
}

.glossary dd {
  margin: 0 0 0 0.8rem;
  color: var(--pico-muted-color);
}

/* ============ Public boats (admin list + form, public page) ============ */

.admin-tabs a.tab-button {
  text-decoration: none;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.6rem;
}

.page-head > div {
  flex: 1;
  min-width: 16rem;
}

.page-head > [role="button"] {
  white-space: nowrap;
}

.mono {
  font-family: var(--pico-font-family-monospace);
}

.public-list {
  display: grid;
  gap: 0.7rem;
}

/* One boat: state | what it is | where to connect | actions; stacks on narrow screens. */
.public-boat {
  display: grid;
  grid-template-columns: 11rem minmax(0, 2fr) minmax(0, 1.6fr) auto;
  gap: 0.5rem 1rem;
  align-items: start;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid var(--pico-muted-border-color);
}

.public-boat.is-running {
  border-left-color: #2ecc71;
}

.public-boat h3 {
  margin: 0 0 0.2rem;
  font-size: 1.1em;
}

.public-boat p {
  margin: 0 0 0.2rem;
}

.public-boat-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
}

.public-boat-ports strong {
  font-size: 1.05em;
}

.public-boat-ports button {
  width: auto;
  padding: 0.05rem 0.5rem;
  margin: 0 0 0 0.3rem;
  font-size: 0.8em;
}

.public-boat-ports details {
  margin: 0.2rem 0 0;
}

.port-list {
  margin: 0.2rem 0 0;
  padding-left: 1rem;
  font-size: 0.85em;
}

.port-list li {
  list-style: disc;
}

.public-boat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.public-boat-actions form {
  margin: 0;
}

.public-boat-actions button,
.public-boat-actions [role="button"] {
  width: auto;
  margin: 0;
  padding: 0.25rem 0.8rem;
  font-size: 0.9em;
}

.badge {
  font-size: 0.72em;
  padding: 0 0.45rem;
  border-radius: 0.6rem;
  border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .public-boat {
    grid-template-columns: 1fr;
  }
  .public-boat-actions {
    justify-content: flex-start;
  }
}

.empty-state {
  text-align: center;
}

.form-error {
  padding: 0.45rem 0.8rem;
  border-left: 4px solid #c0392b;
  background: rgba(192, 57, 43, 0.08);
  border-radius: var(--pico-border-radius);
}

/* Save / cancel, always reachable at the bottom of the scrolling config pane. */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  padding: 0.5rem 0;
  background: var(--pico-background-color);
  border-top: 1px solid var(--pico-muted-border-color);
}

.form-actions button {
  width: auto;
  margin: 0;
}

.option-row input.input-port {
  width: 6.5rem;
}

.config-card textarea {
  margin-bottom: 0.35rem;
}

/* Gateway rows of a public boat: label, host:port (copyable), what it carries. */
.gateway-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.5rem;
  margin-bottom: 0.15rem;
}

.gateway-label {
  min-width: 5.5rem;
  font-size: 0.85em;
  color: var(--pico-muted-color);
}

/* "Otros puertos" as a small link instead of Pico's full-width accordion row. */
.public-boat-ports details > summary {
  display: inline-block;
  cursor: pointer;
}

.public-boat-ports details > summary::after {
  display: none;
}

.flash li {
  list-style: none;
}

/* The top bar wraps on phones instead of pushing the page sideways. */
@media (max-width: 700px) {
  nav.container-fluid {
    flex-wrap: wrap;
  }
  nav.container-fluid ul {
    flex-wrap: wrap;
  }
}

/* ============ Public boat page + the boats' map (public_boat.js, fleet_map.js) ============ */

/* "Tu tablet: conectada / no conectada" -- grey until connected, green when it is. */
.your-tablet {
  margin: 0.2rem 0 1rem;
  padding: 0.6rem 0.9rem;
  border-left: 5px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-sectioning-background-color, var(--pico-background-color));
}

.your-tablet strong {
  font-size: 1.25em;
  margin-right: 0.6rem;
}

.your-tablet p {
  margin: 0.3rem 0 0;
}

.your-tablet.is-connected {
  border-left-color: #2ecc71;
  background: rgba(46, 204, 113, 0.1);
}

.your-tablet.is-stopped {
  border-left-color: #c0392b;
}

.section-title {
  font-size: 1.15em;
  margin: 0.8rem 0 0.3rem;
}

/* The two gateways side by side, each with its QR code. */
.connect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 0.7rem;
}

.connect-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid var(--pico-muted-border-color);
}

.connect-card.carries-all {
  border-left-color: var(--pico-primary);
}

.connect-card strong {
  font-size: 1.15em;
}

.connect-card button {
  width: auto;
  padding: 0.05rem 0.5rem;
  margin: 0;
  font-size: 0.8em;
}

.badge-all {
  color: var(--pico-primary);
  border-color: var(--pico-primary);
}

/* White quiet zone around the QR so phones read it in dark mode too. */
.qr {
  flex: none;
  padding: 6px;
  background: #fff;
  border-radius: 4px;
  line-height: 0;
}

.qr img,
.qr canvas {
  width: 148px;
  height: 148px;
}

.qr-caption {
  margin-top: 4px;
  max-width: 148px;
  font-size: 0.68em;
  line-height: 1.2;
  color: #333;
  word-break: break-all;
}

/* The panel's QRs open on demand ("QR" button) instead of taking room all the time. */
.qr[hidden] {
  display: none;
}

.qr-popover {
  position: absolute;
  z-index: 1100; /* above Leaflet controls (1000) */
  right: 0.5rem;
  top: 100%;
  margin-top: 0.3rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

#constellation-discovery-qr {
  display: inline-block;
  margin: 0.4rem 0;
}

#constellation-discovery-qr[hidden] {
  display: none;
}

button.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.other-ports {
  margin: 0.4rem 0 0;
}

.other-ports > summary {
  display: inline-block;
  cursor: pointer;
}

.other-ports > summary::after {
  display: none;
}

.map-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.follow-toggle {
  font-size: 0.9em;
}

.public-map {
  height: max(420px, 60vh);
  border-radius: var(--pico-border-radius);
  margin-bottom: 0.6rem;
}

.public-sentences > summary {
  font-weight: 600;
}

/* The boats' map on /publicos and /admin/barcos. */
.fleet-map-wrap {
  position: relative;
  margin-bottom: 0.8rem;
}

.fleet-map {
  height: 340px;
  border-radius: var(--pico-border-radius);
}

.fleet-map-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  margin: 0;
  padding: 0.3rem 0.7rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-background-color);
}

.fleet-dot {
  width: 14px;
  height: 14px;
  margin: 6px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.leaflet-tooltip.fleet-label {
  font-weight: 600;
}

/* "El tuyo": the card of the boat the visitor's tablet is connected to. */
.badge-yours {
  display: none;
  color: #1e8449;
  border-color: #2ecc71;
}

.public-boat.is-yours {
  border-left-color: #e67e22;
  box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.45);
}

.public-boat.is-yours .badge-yours {
  display: inline;
}
