/* iViu Plot - main styles */

:root {
  --plot-bg: #1a1a2e;
}

html {
  font-size: 16px;
}

body {
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ── Replay button active state ─────────────────────────────── */
@keyframes plot-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

#global-replay-btn.replay-active {
  color:            #fff !important;
  background-color: #198754 !important;
  border-color:     #198754 !important;
}

#global-replay-btn.replay-active svg {
  display:          inline-block;
}

/* ── Canvas device tooltip ───────────────────────────────────── */
.canvas-tooltip {
  position:         absolute;
  pointer-events:   none;
  z-index:          200;
  background:       rgba(15,23,42,0.88);
  color:            #f1f5f9;
  font-size:        0.75rem;
  line-height:      1.45;
  padding:          5px 9px;
  border-radius:    6px;
  white-space:      pre;
  box-shadow:       0 2px 8px rgba(0,0,0,0.35);
  max-width:        260px;
  transform:        translate(14px, -50%);
}

/* Login */
.login-center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.form-signin {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* Sidebar */
.sidebar {
  width: 340px;
  min-width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--bs-border-color);
}

/* Give canvas area same secondary background as sidebar so the border is seamless */
#canvas-area {
  background-color: var(--bs-secondary-bg);
}

/* Sidebar tabs */
.sidebar-tabs {
  scrollbar-width: none;       /* Firefox */
}
.sidebar-tabs::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

.sidebar-tabs .nav-link {
  font-size: 0.68rem;
  padding: 5px 6px;
  white-space: nowrap;
}

/* Tab content fills remaining height */
.sidebar-tab-content {
  display: flex;
  flex-direction: column;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  height: 100%;
}
.sidebar-pane.show.active {
  display: flex !important;
}

.sidebar-pane-body {
  min-height: 0;
}

.sidebar-pane-toolbar {
  min-height: 0;
}

.sidebar-pane-list {
  min-height: 0;
}

.sidebar-pane-status {
  font-size: 0.72rem;
}

/* Inline detail panel */
.detail-panel {
  padding: 6px 8px;
  font-size: 0.74rem;
  max-height: 45%;
  overflow-y: auto;
  flex-shrink: 0;
}

.detail-toolbar {
  padding-bottom: 4px;
}

.detail-table td {
  padding: 1px 3px;
  vertical-align: top;
  font-size: 0.72rem !important;
}
.detail-table td.font-monospace {
  font-size: 0.65rem !important;
  word-break: break-all;
  overflow-wrap: break-word;
  white-space: normal !important;
}

.detail-table td.lbl {
  color: var(--bs-secondary-color);
  text-align: right;
  white-space: nowrap;
  width: 40%;
  padding-right: 6px;
}

/* Device pos-tech filter buttons */
.dev-pt-btn {
  font-size: 0.75rem;
  padding: 1px 6px;
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  opacity: 0.6;
}
.dev-pt-btn.active {
  opacity: 1;
  border-color: var(--bs-secondary-color);
  background: var(--bs-secondary-bg);
}

/* Canvas */
#plot-canvas {
  display: block;
  cursor: crosshair;
}

.plot-overlay-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--bs-secondary-color);
  font-size: 1.1rem;
  pointer-events: none;
}

/* Mode indicator overlay */
.mode-indicator {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  z-index: 10;
}

/* Tag list */
.tag-list {
  font-size: 0.78rem;
}

.tag-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.tag-list-item:hover {
  background: var(--bs-secondary-bg);
}

.tag-list-item.active {
  background: rgba(91, 184, 245, 0.20);
  border-left: 3px solid #5BB8F5;
  padding-left: 1px;
}

.ap-list-item {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  user-select: none;
}

.ap-list-item:hover {
  background: var(--bs-secondary-bg);
}

.ap-list-item.active {
  background: rgba(91, 184, 245, 0.20);
  border-left: 3px solid #5BB8F5;
  padding-left: 1px;
}

.device-list-item.active {
  background: rgba(91, 184, 245, 0.18);
  border-left: 3px solid #5BB8F5;
  padding-left: 1px;
}

.calpoint-item.active {
  background: rgba(91, 184, 245, 0.20);
  border-left: 3px solid #5BB8F5;
  padding-left: 1px;
}

.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-square {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* Inline list icon shapes (AP diamond, Cal triangle) */
.list-icon-diamond {
  display: inline-block;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border-radius: 1px;
  flex-shrink: 0;
}

.list-icon-triangle {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  flex-shrink: 0;
}

/* Cal point list */
.calpoint-list {
  font-size: 0.78rem;
}

.calpoint-item {
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.calpoint-item:hover {
  background: var(--bs-secondary-bg);
}

/* Shared icon button */
.btn-icon {
  background: none;
  border: none;
  padding: 1px 4px;
  cursor: pointer;
  color: var(--bs-secondary-color);
  line-height: 1;
  border-radius: 3px;
  font-size: 0.75rem;
}

.btn-icon:hover {
  color: var(--bs-body-color);
  background: var(--bs-secondary-bg);
}

.btn-xs {
  font-size: 0.7rem;
  padding: 1px 5px;
}

/* Zoom controls overlay */
.canvas-zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 10;
}

.canvas-zoom-controls .btn {
  padding: 4px 8px;
  font-size: 0.75rem;
  opacity: 0.7;
}

.canvas-zoom-controls .btn:hover {
  opacity: 1;
}

.canvas-zoom-controls .btn.active {
  opacity: 1;
  color: #f90;
  border-color: #f90;
  background: rgba(255,153,0,0.15);
}

/* Coordinate readout — now lives inside #legend-bar on the right */
.coord-readout {
  margin-left: 12px;
  color: rgba(255,255,255,0.70);
  font-size: 0.70rem;
  font-family: monospace;
  white-space: nowrap;
  pointer-events: none;
  min-width: 120px;
  text-align: right;
}

.bar-copyright {
  color: rgba(255,255,255,0.88);
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
}

.sidebar-footer {
  height: 44px;
  background: rgba(0,0,0,0.45);
  border-top: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: #fff;
  padding: 0 12px;
}

/* Ruler distance readout — displayed above X axis strip */
.ruler-readout {
  position: absolute;
  bottom: 52px;
  right: 10px;
  background: rgba(0,0,0,0.72);
  color: #f90;
  border: 1px solid #f90;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: monospace;
  font-weight: bold;
  padding: 3px 10px;
  z-index: 11;
  pointer-events: none;
  white-space: nowrap;
}

/* Device list */
.device-list {
  font-size: 0.875rem;
}

.device-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.device-list-item:hover {
  background: var(--bs-secondary-bg);
}

.device-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}



/* Full-width legend/footer bar — spans canvas + sidebar at the very bottom */
#legend-bar {
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  background: rgba(0,0,0,0.52);
  border-top: 1px solid rgba(255,255,255,0.12);
  z-index: 10;
  padding: 0 10px 0 44px;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,0.88);
  font-size: 0.7rem;
  white-space: nowrap;
}

.legend-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.legend-diamond {
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border-radius: 1px;
}

.legend-triangle {
  width: 0;
  height: 0;
  background: none !important;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 10px solid;
}

/* ══════════════════════════════════════════════
   Mobile layout  (≤ 767px)
══════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Navbar — keep single row, hide low-priority items */
  .navbar { flex-wrap: nowrap; padding-left: 8px !important; padding-right: 8px !important; }
  .navbar-brand { font-size: 0.8rem; margin-right: 4px !important; }
  #location-search  { display: none !important; }
  #refresh-status   { display: none !important; }
  #navbar-user      { display: none !important; }
  #tag-count-badge  { display: none !important; }
  #device-count-badge { font-size: 0.65rem; padding: 2px 5px; }
  #trace-active-badge { font-size: 0.65rem; padding: 2px 5px; }
  #location-select  { max-width: 130px; font-size: 0.8rem; }

  /* Canvas — full width (sidebar is lifted out of flow when fixed) */
  #canvas-area { width: 100% !important; }

  /* Sidebar — slides in from the right as an overlay */
  .sidebar {
    position: fixed;
    top: 0;
    right: -105%;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 1050;
    border-left: none;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    transition: right 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.sidebar-open { right: 0; }

  /* Backdrop shown when sidebar is open */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1049;
  }
  #sidebar-backdrop.active { display: block; }

  /* Sidebar close button — only visible on mobile */
  #sidebar-close-btn { display: flex !important; }

  /* Larger touch targets for zoom controls */
  .canvas-zoom-controls { top: 8px; right: 8px; gap: 6px; }
  .canvas-zoom-controls .btn { padding: 10px 14px; font-size: 0.9rem; }

  /* Legend bar — hide symbol legend; keep only right group */
  .legend-item { display: none !important; }
  #legend-bar { padding: 0 8px; gap: 0; }

  /* Mode indicator — full width on mobile */
  .mode-indicator {
    width: calc(100% - 24px);
    bottom: 10px;
    font-size: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    gap: 4px;
  }
  #mode-scale-input { flex-wrap: wrap; justify-content: center; }
}

/* ── Location Proposal panel ───────────────────────────────── */
.prop-camera-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--bs-secondary-bg);
}

.prop-camera-row .prop-cam-label {
  flex-grow: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prop-camera-row .prop-cam-pos {
  color: var(--bs-secondary-color);
  font-size: 0.7rem;
  white-space: nowrap;
}

/* Camera icon on canvas (proposal mode) */
.prop-camera-placing {
  cursor: crosshair !important;
}

/* PDF print / generation styles (applied to a hidden off-screen DIV) */
#prop-pdf-container {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1122px;   /* A4 landscape ~96dpi */
  background: #fff;
  color: #111;
  font-family: "Roboto", Arial, sans-serif;
}

.prop-pdf-cover {
  width: 1122px;
  min-height: 793px;
  box-sizing: border-box;
  padding: 60px 72px 40px;
  display: flex;
  flex-direction: column;
}

.prop-pdf-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #1a3a6b;
  padding-bottom: 14px;
  margin-bottom: 28px;
}

.prop-pdf-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a3a6b;
  letter-spacing: 0.03em;
}

.prop-pdf-confidential {
  font-size: 0.72rem;
  color: #c0392b;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid #c0392b;
  padding: 2px 8px;
  border-radius: 3px;
}

.prop-pdf-title-block {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.prop-pdf-location-name {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.prop-pdf-address {
  font-size: 0.95rem;
  color: #555;
}

.prop-pdf-objective-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1a3a6b;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 8px;
}

.prop-pdf-objective {
  font-size: 1.05rem;
  color: #222;
  font-style: italic;
}

.prop-pdf-customer-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 10px;
}

.prop-pdf-customer {
  font-size: 1rem;
  color: #333;
}

.prop-pdf-meta-row {
  display: flex;
  gap: 32px;
  margin-top: 20px;
  font-size: 0.8rem;
  color: #777;
  border-top: 1px solid #e0e0e0;
  padding-top: 12px;
}

.prop-pdf-meta-row span strong {
  color: #333;
}

/* Floor plan page */
.prop-pdf-floorplan-page {
  width: 1122px;
  min-height: 793px;
  box-sizing: border-box;
  padding: 30px 40px 20px;
  display: flex;
  flex-direction: column;
  page-break-before: always;
}

.prop-pdf-fp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.prop-pdf-fp-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a3a6b;
}

.prop-pdf-fp-canvas {
  flex-grow: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f8fc;
}

.prop-pdf-fp-canvas img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Device summary table on PDF */
.prop-pdf-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 14px;
}

.prop-pdf-summary-table th {
  background: #1a3a6b;
  color: #fff;
  padding: 5px 10px;
  text-align: left;
  font-weight: 600;
}

.prop-pdf-summary-table td {
  padding: 4px 10px;
  border-bottom: 1px solid #e8e8e8;
}

.prop-pdf-summary-table tr:nth-child(even) td {
  background: #f4f6fb;
}

/* Footer bar on PDF pages */
.prop-pdf-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ddd;
  padding-top: 8px;
  margin-top: 12px;
  font-size: 0.68rem;
  color: #999;
}

.prop-pdf-footer .prop-pdf-copyright {
  color: #aaa;
}
