/* webapp/styles.css */
html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: #111;
  color: #f3f3f3;
  font-family: "Segoe UI", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

#app-header {
  flex: 0 0 auto;
  background: #1c1c1c;
  border-bottom: 1px solid #3a3a3a;
  padding: 10px 14px 12px;
}

.brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-row h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

#controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 8px;
}

.setup-row label,
.feature-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #c8c8c8;
}

.setup-row input,
.setup-row select,
.feature-picker select,
#level-pickers select,
#level-pickers input,
#print-export-dialog select,
#print-export-dialog input {
  min-height: 40px;
  background: #111;
  color: #f3f3f3;
  border: 1px solid #5c5c5c;
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-gap {
  flex: 1 1 12px;
}

#level-pickers {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#level-pickers[hidden] {
  display: none;
}

.picker-pair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#feature-number,
#chamber-number {
  width: 4.5rem;
}

.picker-message {
  flex-basis: 100%;
  margin: 0;
  color: #f0d060;
  font-size: 12px;
}

.picker-message[hidden] {
  display: none;
}

#level-pickers select {
  cursor: pointer;
}

#feature-select {
  width: 16rem;
}

#chamber-select {
  width: 9.5rem;
}

#levelInfo,
#featureCount {
  font-size: 14px;
  color: #f3f3f3;
}

.app-version {
  font-size: 12px;
  color: #9a9a9a;
}

button {
  background: #2c2c2c;
  color: #f3f3f3;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 8px 12px;
  min-height: 40px;
  margin: 0;
  cursor: pointer;
  font: inherit;
}

button:hover {
  background: #f3f3f3;
  color: #111;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid #f0d060;
  outline-offset: 2px;
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
}

.map-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.level-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.feature-card {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 20px;
  max-height: 9.5rem;
  overflow: auto;
  background: #1c1c1c;
  border-bottom: 1px solid #3a3a3a;
  padding: 8px 14px;
  color: #f3f3f3;
  font-size: 14px;
}

#featureInfo {
  flex: 1 1 16rem;
  min-width: 0;
}

#featureInfo h2 {
  margin: 0 0 6px;
  font-size: 15px;
}

.feature-empty {
  margin: 0;
  color: #bdbdbd;
}

.feature-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 4px 16px;
  margin: 0;
}

.feature-facts div {
  margin: 0;
}

.feature-facts dt {
  color: #9a9a9a;
  font-size: 11px;
}

.feature-facts dd {
  margin: 0;
}

#svg {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

#thumbnails {
  min-height: 0;
  background: #1c1c1c;
  border-left: 1px solid #3a3a3a;
  padding: 12px;
  box-sizing: border-box;
  overflow: auto;
}

#thumbnails h2 {
  color: #f3f3f3;
  margin: 0 0 10px;
  font-size: 15px;
}

.thumbnail {
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid #444;
  padding: 5px;
  background: #333;
}

.thumbnail.current {
  border-color: #f0d060;
}

.thumbnail:hover {
  background: #444;
}

.thumbnail svg {
  border: 1px solid white;
  display: block;
  margin-bottom: 5px;
}

.thumbnail div {
  text-align: center;
  color: white;
  font-size: 12px;
}

dialog {
  background: #222;
  color: white;
  border: 1px solid white;
  padding: 20px;
  border-radius: 5px;
}

dialog button {
  margin: 10px 5px;
}

#print-export-dialog {
  width: min(60rem, 96vw);
  max-height: 92vh;
  overflow: auto;
}

.print-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem);
  gap: 16px;
  align-items: start;
}

#print-preview {
  margin: 0;
}

#print-preview figcaption {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 8px;
}

#print-preview-svg {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  background: #000;
  border: 1px solid #666;
  display: block;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

#progress-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #111;
  color: #f3f3f3;
  border: 1px solid #f3f3f3;
  padding: 20px;
  z-index: 1000;
  max-height: 80vh;
  max-width: min(36rem, 92vw);
  overflow-y: auto;
}

#print-export-dialog p {
  margin: 8px 0 12px;
}

#print-export-dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}

#print-export-dialog label[hidden] {
  display: none;
}

#print-export-dialog select,
#print-export-dialog input {
  font: inherit;
  padding: 4px;
}

/* Door highlighting for edit mode */
.selectable-door:hover {
  fill: rgba(255, 255, 0, 0.3) !important;
  stroke: #ffff00 !important;
  stroke-width: 2 !important;
}

.selectable-door.selected {
  fill: rgba(255, 0, 0, 0.3) !important;
  stroke: #ff0000 !important;
  stroke-width: 2 !important;
}

/* Edit mode toolbar styling */
#edit-toolbar {
  font-family: Arial, sans-serif;
  font-size: 12px;
}

#edit-toolbar button {
  padding: 4px 8px;
  margin: 2px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s;
}

#edit-toolbar button:hover {
  background-color: #e0e0e0 !important;
}

/* Invalid operation feedback */
.invalid-operation {
  cursor: not-allowed !important;
}

/* Drag preview styling */
.drag-preview {
  opacity: 0.7;
  stroke-dasharray: 5,5;
}

/* Validation error indicator */
.validation-error {
  fill: rgba(255, 0, 0, 0.2) !important;
  stroke: #ff0000 !important;
  stroke-width: 2 !important;
}

/* Selection highlight handled in JS */

#file-progress {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.file-progress-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 280px;
  padding: 20px 24px;
  background: white;
  color: #111;
  border: 2px solid #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 18px;
}

#file-progress[hidden] {
  display: none;
}

#file-progress p {
  margin: 0;
}

.file-progress-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #ccc;
  border-top-color: #111;
  border-radius: 50%;
  animation: file-progress-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

@keyframes file-progress-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 800px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  #svg {
    height: 68vh;
    flex: none;
  }

  #thumbnails {
    border-left: 0;
    border-top: 1px solid #3a3a3a;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
  }

  .level-cluster,
  #level-pickers {
    flex-wrap: wrap;
  }

  #thumbnails h2 {
    flex: 1 0 100%;
  }

  .thumbnail {
    width: 148px;
    margin: 0;
  }

  .print-layout {
    grid-template-columns: 1fr;
  }

  .action-gap {
    display: none;
  }
}

/* Smoke test: console.log('Styles loaded'); */