/* Bombay Mars LAN Map - Sprint 1 */

:root {
  --bg-dark: #1a1d23;
  --bg-panel: #252830;
  --bg-hover: #2d323d;
  --accent: #4ecdc4;
  --accent-dim: #3ba89f;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --border: #3c4043;
  --offline: #5f6368;
  --success: #34a853;
  --warning: #f9ab00;
  --danger: #ea4335;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#refresh-btn {
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: var(--bg-dark);
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

#refresh-btn:hover {
  background: var(--accent-dim);
}

.admin-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

.admin-toggle input {
  cursor: pointer;
}

.main {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
}

.sidebar {
  width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-header h3 {
  margin: 0;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.toggle-btn.collapsed {
  transform: rotate(-90deg);
}

.collapsible-content.hidden {
  display: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-dark);
}

.device-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.device-item:last-child {
  border-bottom: none;
}

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

.device-item.selected {
  background: var(--bg-hover);
  border-left: 3px solid var(--accent);
}

.device-item .device-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-item .device-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.device-status.online { background: var(--success); }
.device-status.offline { background: var(--offline); }

.secondary-btn {
  padding: 0.4rem 0.8rem;
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
}

.secondary-btn:hover {
  background: var(--border);
}

.controls-group h3 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.controls-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  color: var(--text);
}

.layer-selector {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.layer-overlay {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.5rem;
}
.layer-overlay-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 1.5rem;
}

.filter-range {
  margin-top: 0.5rem;
}

.filter-range label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.filter-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.map {
  flex: 1;
  min-width: 0;
}

.inspector {
  width: 320px;
  min-width: 280px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.inspector.hidden {
  display: none;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.inspector-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

#inspector-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

#inspector-close:hover {
  color: var(--text);
}

.inspector-content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.inspector-content dl {
  margin: 0;
}

.inspector-content dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.inspector-content dt:first-child {
  margin-top: 0;
}

.inspector-content dd {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.inspector-content .device-thumb {
  width: 80px;
  height: 80px;
  background: var(--bg-dark);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.inspector-content .device-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.inspector-content .state-online {
  color: var(--success);
}

.inspector-content .state-offline {
  color: var(--offline);
}

/* Client list in inspector */
.clients-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.clients-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.clients-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
  font-style: italic;
}

.inspector-content .position-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0.5rem 0;
}

.inspector-content #reset-position-btn {
  margin-bottom: 0.5rem;
}

.client-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.client-item {
  background: var(--bg-dark);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
}

.client-name {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.2rem;
}

.tag {
  font-size: 0.7rem;
  background: rgba(78, 205, 196, 0.12);
  color: var(--accent);
  border: 1px solid rgba(78, 205, 196, 0.25);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  white-space: nowrap;
}

.tag-signal {
  background: rgba(255, 165, 0, 0.12);
  color: #f0a500;
  border-color: rgba(255, 165, 0, 0.3);
}

.tag-wired {
  background: rgba(150, 150, 255, 0.12);
  color: #9999ff;
  border-color: rgba(150, 150, 255, 0.3);
}

.client-traffic {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.timeline-panel {
  position: relative;
  width: 100%;
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(137, 177, 224, 0.28);
  border-radius: 12px;
  padding: 0.75rem 0.75rem 0.65rem;
  background: linear-gradient(180deg, rgba(29, 43, 66, 0.95), rgba(23, 35, 56, 0.94));
  color: #e7efff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(170, 205, 255, 0.15);
  backdrop-filter: blur(10px) saturate(115%);
}

.timeline-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.timeline-controls-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.timeline-ts {
  font-size: 0.92rem;
  font-weight: 700;
  color: #eaf3ff;
  letter-spacing: -0.01em;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.timeline-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #2f7fd8, #225fa8);
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(21, 51, 92, 0.45);
}

.timeline-btn:hover {
  background: linear-gradient(180deg, #3a8eea, #2a6fbe);
}

.timeline-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.timeline-speed {
  min-width: 56px;
  background: rgba(152, 183, 224, 0.16);
  color: #e9f2ff;
  border: 1px solid rgba(132, 170, 218, 0.35);
  border-radius: 10px;
  padding: 0.22rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.timeline-range {
  min-width: 64px;
  background: rgba(152, 183, 224, 0.16);
  color: #e9f2ff;
  border: 1px solid rgba(132, 170, 218, 0.35);
  border-radius: 10px;
  padding: 0.22rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.timeline-slider-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.timeline-slider {
  width: 100%;
  accent-color: #58d0ff;
}

.timeline-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: rgba(120, 155, 204, 0.24);
  border: 1px solid rgba(136, 173, 223, 0.35);
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #58d0ff;
  border: 2px solid #dff6ff;
  margin-top: -6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.timeline-slider::-moz-range-track {
  height: 8px;
  border-radius: 8px;
  background: rgba(120, 155, 204, 0.24);
  border: 1px solid rgba(136, 173, 223, 0.35);
}

.timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #58d0ff;
  border: 2px solid #dff6ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.timeline-hours {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.25rem;
  font-size: 0.68rem;
  color: #c7d7f2;
  opacity: 0.95;
}

.timeline-hours span {
  text-align: center;
}

@media (max-width: 900px) {
  .header {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .controls {
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .main {
    flex-direction: column;
    min-height: 0;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45vh;
  }

  .timeline-panel {
    border-radius: 10px;
    padding: 0.72rem;
  }

  .map {
    width: 100%;
    min-height: 55vh;
  }

  .inspector {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45vh;
  }

  .timeline-ts {
    font-size: 0.95rem;
  }
  .timeline-hours {
    font-size: 0.74rem;
  }
}

/* OpenLayers overrides */
.ol-control button {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
}

.ol-control button:hover {
  background: var(--bg-hover) !important;
}

.ol-attribution {
  background: rgba(37, 40, 48, 0.9) !important;
  color: var(--text-muted) !important;
}

.ol-attribution a {
  color: var(--accent) !important;
}
