body { font-family: system-ui, sans-serif; margin: 0; color: #222; overflow-x: hidden; }
body.admin-mode { background: #fff5f5; }
h2, h3 { margin: 0 0 8px; }
label { display: block; margin: 8px 0; }
input { padding: 6px 8px; }
button { padding: 6px 10px; margin-left: 8px; }
.hidden { display: none !important; }
.msg { margin-top: 6px; min-height: 18px; color: #c00; }

#login { max-width: 320px; margin: 60px auto; padding: 16px; border: 1px solid #ddd; border-radius: 8px; }
/* Keep Add Robot form items on one line */
#add-robot { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
#add-robot label { margin: 0; }

.topbar { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid #eee; }
.client-count { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: #444; font-weight: 500; }
.tabs { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #eee; }
.tab-btn { padding: 6px 10px; }
.main { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.panel { border: 1px solid #eee; border-radius: 8px; padding: 12px; width: 420px; max-width: 100%; }

#map { width: 100%; max-width: 600px; height: auto; background: #f8f8f8; border: 1px solid #ddd; cursor: grab; touch-action: none; }
.mapbar { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.mapbar .paint-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.mapbar .layers { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.telemetry { display: grid; grid-template-columns: repeat(2, auto); gap: 6px 16px; margin-top: 8px; }
/* Simple diagnostics counters */
.diag { margin-top: 8px; color: #666; font-size: 0.9em; display: flex; flex-wrap: wrap; gap: 10px; }
.diag .item { display: inline-flex; gap: 4px; align-items: baseline; }

#joystick { position: relative; width: 220px; height: 220px; background: #fafafa; border: 1px solid #ddd; border-radius: 50%; margin: 12px auto; touch-action: none; }
#stick { position: absolute; width: 60px; height: 60px; border-radius: 50%; background: #44a; left: 80px; top: 80px; }
/* Transparent joystick style when camera is visible */
#joystick.transparent { background: transparent; border: 2px solid rgba(255,255,255,0.6); }
#joystick.transparent #stick { background: rgba(68,68,170,0.55); }
.controls { margin-top: 8px; display: grid; gap: 8px; }
.controls .group { display: flex; gap: 8px; flex-wrap: wrap; }
/* Vertically stacked action buttons with inline hints (mapping panel) */
.controls .group.stacked { flex-direction: column; align-items: flex-start; gap: 6px; }
.controls .action { display: inline-flex; align-items: center; gap: 8px; }
.controls .action .hint { color: #666; font-size: 0.9em; }

.admin-banner { display: none; padding: 6px 10px; background: #ffe3e3; color: #b10000; border-bottom: 1px solid #ffcccc; font-weight: 600; }
.admin-mode .admin-banner { display: block; }

/* Vendor logo styling */
.vendor-logo { height: 32px; width: auto; object-fit: contain; vertical-align: middle; margin-left: 8px; border-radius: 3px; }
/* Place vendor logo at left in user-info */
#vendor-logo-list { margin-left: 0; margin-right: 8px; }

/* Simple vertical stack container */
.vstack { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }

/* Robot list status dots */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-online { background: #28a745; }
.status-offline { background: #dc3545; }
.
.conn-indicator { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0; }

/* Grouping headers in robot list */
#robot-list { list-style: none; padding-left: 0; }
.group-header { font-weight: 600; margin-top: 12px; }
.subheader { font-weight: 500; margin-top: 6px; padding-left: 8px; color: #555; }
.robot-item { padding-left: 16px; }

/* Danger zone (destructive actions) */
.danger { margin-top: 12px; padding: 10px; border: 1px solid #f5c2c2; background: #fff3f3; color: #8a1f1f; border-radius: 6px; }
.danger-btn { background: #d9534f; color: #fff; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.danger-btn:hover { background: #c9302c; }

/* Responsive layout for small screens */
@media (max-width: 768px) {
  .main { flex-direction: column; padding: 12px; }
  .panel { width: 100%; }
  #map { max-width: 100%; }
  /* Add a right gutter beside the map so users can start a scroll gesture outside the canvas area on touch devices */
  #shared-map { padding-right: 48px; }
  /* Ensure the canvas does not fill into the right gutter */
  #map { width: calc(100% - 48px); }
  #joystick { width: 70vw; height: 70vw; max-width: 280px; max-height: 280px; }
  #stick { left: calc(50% - 30px); top: calc(50% - 30px); }
  .topbar { flex-wrap: wrap; gap: 8px; }
}

/* Camera fixed display size (client scales to 320x240) */
#camera-view { width: 320px; height: 240px; background: #000; object-fit: contain; }
#camera-wrap { display: inline-block; position: relative; }
#camera-view { display: block; pointer-events: none; }
#camera-wrap { display: inline-block; position: relative; }
#camera-view { display: block; pointer-events: none; }
#joystick-wrap { position: relative; display: inline-block; }
#camera-view-overlay { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; width: 320px; height: 240px; background: #000; object-fit: contain; }
#joystick-wrap #joystick { position: relative; z-index: 1; }
