/* MetroMap Studio — Editor Page Overrides
   The legacy metromapdesigner.css handles most styling.
   This file provides overrides for the fullstack integration. */

/* ============================================================
   DESIGN SYSTEM TOKENS
   ============================================================ */
:root {
  --bs-body-font-family: 'Barlow', sans-serif;
  --surface-color: rgba(255, 255, 255, 0.9);
  --border-subtle: #e5e7eb;
  --primary-accent: #0d6efd;
  --z-index-canvas: 0;
  --z-index-panel: 900;
  --z-index-ui: 1000;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--bs-body-font-family);
}

/* ============================================================
   ISLAND NAVIGATION
   ============================================================ */
.app-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  z-index: var(--z-index-ui);
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.nav-island {
  background: var(--surface-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.4rem 0.75rem;
  pointer-events: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hamburger menu popover */
.hamburger-menu-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.35rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  min-width: 180px;
  z-index: var(--z-index-ui);
}

.hamburger-menu-popover.open {
  display: flex;
}

.hamburger-menu-popover .dropdown-item {
  border-radius: 8px;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

.hamburger-menu-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  font-weight: 600;
  padding: 0.25rem 0.75rem 0.15rem;
}

.hamburger-lang-grid {
  display: flex;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem 0.25rem;
}

.hamburger-lang-btn {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: #495057;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hamburger-lang-btn:hover {
  background-color: #f1f3f5;
  color: #000;
}

.hamburger-lang-btn.active {
  background-color: var(--primary-accent);
  border-color: var(--primary-accent);
  color: #fff;
}

.nav-island-spacious {
  padding: 0.4rem 1rem;
  gap: 0.35rem;
}

.nav-island-title {
  font-weight: 700;
  color: #212529;
  font-size: 1.3rem;
  white-space: nowrap;
}

.nav-island-btn {
  border: none;
  background: transparent;
  color: #495057;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  font-size: 1.3rem;
}

.nav-island-btn:hover {
  background-color: #f1f3f5;
  color: #000;
}

.nav-island-btn.dropdown-toggle::after {
  display: none;
}

.nav-lang-btn {
  font-size: 0.75rem;
  font-weight: 600;
  width: auto;
  min-width: 32px;
  padding: 0 4px;
}

/* User avatar dropdown */
.user-avatar-btn {
  padding: 2px 8px 2px 4px;
  background-color: transparent;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.user-avatar-btn:hover,
.user-avatar-btn[aria-expanded="true"] {
  background-color: #f1f3f5;
  border-color: var(--border-subtle);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  background-color: #a855f7;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-circle-lg {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
}

.user-dropdown-card {
  width: 300px;
  border-radius: 16px;
  border: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  margin-top: 0.5rem !important;
}

.user-promo-card {
  background-color: #eef2ff;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.5rem;
}

/* Responsive: stack islands on small screens */
@media (max-width: 640px) {
  .app-navbar {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .nav-island {
    padding: 0.3rem 0.5rem;
    gap: 0.25rem;
    border-radius: 10px;
  }
  .nav-island-title {
    font-size: 0.8rem;
  }
  .nav-island-btn {
    width: 28px;
    height: 28px;
  }
}

/* ============================================================
   CANVAS WRAPPER
   ============================================================ */
#canvas-scroll-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background-color: #f8f9fa;
  background-image:
    linear-gradient(#e9ecef 1px, transparent 1px),
    linear-gradient(90deg, #e9ecef 1px, transparent 1px);
  background-size: 40px 40px;
}

#application {
  min-width: fit-content;
  min-height: fit-content;
}

/* Right-click pan cursor — overrides all child cursors */
#canvas-scroll-wrapper.is-panning,
#canvas-scroll-wrapper.is-panning * {
  cursor: grabbing !important;
}

/* Canvas margin: space for floating island nav above + align with navbar */
#canvas {
  margin-top: 80px !important;
  margin-left: 1.5rem !important;
}

/* Hide legacy floating nav (replaced by island nav) */
#fullNavigation {
  display: none !important;
}

/* Hide legacy toolbar (replaced by tool dock) */
.toolbar {
  display: none !important;
}

/* ============================================================
   CONTEXT PANEL (station properties — right side)
   ============================================================ */
.context-panel,
#stationEditor {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  width: 280px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  z-index: var(--z-index-panel);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  margin: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Override legacy stationEditor show/hide */
.stationEditorHidden,
#stationEditor.stationEditorHidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
}

.stationEditorShow,
#stationEditor.stationEditorShow {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.context-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}

.context-panel-header:active {
  cursor: grabbing;
}

.panel-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  font-weight: 600;
}

.context-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.context-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #6c757d;
  font-weight: 600;
}

.context-row {
  display: flex;
  gap: 0.5rem;
}

.context-panel .form-control,
.context-panel .form-select {
  border-color: var(--border-subtle);
  font-size: 0.85rem;
}

.context-panel .form-control:focus,
.context-panel .form-select:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.15);
}

/* Responsive: panel full-width on mobile */
@media (max-width: 640px) {
  .context-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 50vh;
  }
}

/* ============================================================
   FLOATING TOOL DOCK
   ============================================================ */
.tool-dock-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-index-ui);
}

.tool-dock {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  padding: 0.4rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.tool-dock-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Color badge on metroline tool button */
.tool-color-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
}

/* Station palette popover (above dock) */
.station-palette-popover {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  display: none;
  align-items: center;
  gap: 0.25rem;
  z-index: var(--z-index-ui);
}

.station-palette-popover.open {
  display: flex;
}

/* Canvas size popover (above dock) */
.canvas-size-popover {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  min-width: 140px;
  z-index: var(--z-index-ui);
}

.canvas-size-popover.open {
  display: flex;
}

.canvas-size-popover .dropdown-item {
  border-radius: 8px;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.canvas-size-popover .dropdown-item small {
  font-size: 0.7rem;
}

.canvas-size-check {
  visibility: hidden;
  font-size: 0.75rem;
}

.canvas-size-option.active .canvas-size-check {
  visibility: visible;
  color: var(--primary-accent);
}

.canvas-size-option.active {
  color: var(--primary-accent);
  font-weight: 600;
}

/* Highlight active station tool button in dock */
#activeStationBtn.tool-active {
  background-color: #e7f1ff;
  color: var(--primary-accent);
}

/* Color palette popover (above dock) */
.color-palette-popover {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  z-index: var(--z-index-ui);
}

.color-palette-popover.open {
  display: flex;
}

/* Color grid inside popover */
.color-palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 200px;
}

.color-palette-grid .metro-button {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: 50%;
  min-width: 32px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.color-palette-grid .metro-button:hover {
  transform: scale(1.15);
}

.color-palette-grid .metro-button.colorSelected {
  border-color: #212529 !important;
  transform: scale(1.15);
}

/* Footer row (picker + add) */
.color-palette-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

/* Color picker in dock */
.tool-color-picker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  padding: 0;
  background: transparent;
}

/* Tool buttons (round, 40px) */
.tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #495057;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  cursor: pointer;
  font-size: 1.4rem;
  padding: 0;
  position: relative;
}

.tool-btn:hover {
  background-color: #f1f3f5;
  color: #000;
}

.tool-btn.toolSelected,
.tool-btn.active {
  background-color: #e7f1ff;
  color: var(--primary-accent);
}

/* Override legacy .toolSelected for new round buttons */
.tool-dock .toolSelected {
  border: none !important;
  background-color: #e7f1ff !important;
  color: var(--primary-accent) !important;
}

/* Override legacy .colorSelected for dock */
.tool-dock .colorSelected {
  border-color: #212529 !important;
}

/* Hide dropdown caret on move tool */
.tool-btn.dropdown-toggle::after {
  display: none;
}

/* Responsive tool dock */
@media (max-width: 640px) {
  .tool-dock-container {
    bottom: 1rem;
  }
  .tool-dock {
    padding: 0.3rem 0.5rem;
    gap: 0.15rem;
  }
  .tool-btn {
    width: 34px;
    height: 34px;
    font-size: 0.875rem;
  }
  .tool-dock-colors .metro-button {
    width: 24px;
    height: 24px;
    min-width: 24px;
  }
  .tool-color-picker {
    width: 24px;
    height: 24px;
  }
}

/* Hide legacy bottom toolbar (replaced by zoom-controls) */
.bottom-toolbar {
  display: none !important;
}

/* ============================================================
   ZOOM CONTROLS (bottom left)
   ============================================================ */
.zoom-controls {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: var(--z-index-ui);
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #495057;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1.3rem;
  padding: 0;
}

.zoom-btn:hover {
  background-color: #f1f3f5;
  color: #000;
}

.zoom-display {
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  user-select: none;
  cursor: pointer;
  padding: 0 4px;
  color: #212529;
}

.zoom-display:hover {
  color: var(--primary-accent);
}

@media (max-width: 640px) {
  .zoom-controls {
    bottom: 1rem;
    left: 1rem;
  }
}

/* Dashboard thumbnail grid */
#dashboard-maps-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.dashboard-map-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-map-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.dashboard-thumbnail {
  height: 120px;
  object-fit: cover;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.dashboard-thumbnail-placeholder {
  height: 120px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
