/* Axis Mundi - Editor Styles */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 0.4em 1em;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  gap: 0.5em;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.toolbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  text-align: center;
}

.separator {
  color: var(--text-muted);
}

#world-name {
  font-family: var(--font-heading);
  font-size: 1.1em;
  font-weight: 600;
  padding: 0.2em 0.5em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  outline: none;
  min-width: 150px;
  text-align: center;
}

#world-name:hover {
  border-color: var(--border);
}

#world-name:focus {
  border-color: var(--accent);
}

label {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-bottom: 0.2em;
}

/* Workspace */
#workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1em;
  display: flex;
  flex-direction: column;
  gap: 1em;
  transition: margin-left 0.2s ease, opacity 0.2s ease;
}

#workspace.sidebar-hidden #sidebar {
  margin-left: -260px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-section h3 {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5em;
}

.sidebar-section textarea {
  font-size: 0.85em;
  min-height: 50px;
}


/* POI controls */
.poi-controls {
  display: flex;
  gap: 0.4em;
  margin-bottom: 0.5em;
}

.poi-controls input {
  flex: 1;
  font-size: 0.85em;
  padding: 0.3em 0.5em;
}

.poi-controls select {
  font-size: 0.85em;
  padding: 0.3em;
  width: auto;
}

/* POI list */
#poi-list {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.poi-list-item {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.4em 0.5em;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85em;
  transition: background var(--transition);
}

.poi-list-item:hover {
  background: var(--bg-tertiary);
}

.poi-list-item.active {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.poi-list-icon {
  font-size: 1em;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

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

.poi-list-edit {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.1em 0.3em;
  font-size: 0.9em;
}

.poi-list-item:hover .poi-list-edit {
  opacity: 1;
}

/* Map viewport */
#map-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  cursor: grab;
}

#map-viewport:active {
  cursor: grabbing;
}

#map-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#map-content {
  position: absolute;
  transform-origin: 0 0;
}

#map-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

#poi-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#poi-layer > * {
  pointer-events: auto;
}

/* Map placeholder */
#map-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#map-placeholder.hidden {
  display: none;
}

.placeholder-content {
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 4em;
  margin-bottom: 0.3em;
}

/* Map info bar */
#map-info {
  position: absolute;
  bottom: 0.5em;
  left: 0.5em;
  display: flex;
  gap: 1em;
  font-size: 0.75em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.2em 0.6em;
  border-radius: var(--radius);
  pointer-events: none;
}

/* POI Editor Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow);
}

.modal-large {
  max-width: 900px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.2em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.1em 0.3em;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1em 1.5em;
  border-top: 1px solid var(--border);
}

.modal-footer-right {
  display: flex;
  gap: 0.5em;
}

.btn-primary {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-danger {
  background: #c0392b !important;
  color: white !important;
  border-color: #c0392b !important;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* POI Editor Body */
.poi-editor-body {
  padding: 1.5em;
}

.poi-editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8em;
  margin-bottom: 1em;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.field-row label {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.poi-editor-markdown {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.poi-editor-markdown label {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.markdown-editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em;
  height: 300px;
}

.markdown-editor-split textarea {
  height: 100%;
  font-size: 0.85em;
}

#poi-markdown-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75em;
  overflow-y: auto;
}

/* POI links checkbox list */
#poi-links-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  max-height: 80px;
  overflow-y: auto;
}

.link-checkbox {
  display: flex;
  align-items: center;
  gap: 0.2em;
  font-size: 0.8em;
  background: var(--bg-tertiary);
  padding: 0.2em 0.5em;
  border-radius: var(--radius);
  cursor: pointer;
}

.link-checkbox input {
  width: auto;
}

/* Side panel (for viewer preview) */
.panel-category {
  margin-bottom: 1em;
}

.panel-links {
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

.panel-links h4 {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-bottom: 0.4em;
}

.panel-link-item {
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.3em 0.5em;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85em;
  transition: background var(--transition);
}

.panel-link-item:hover {
  background: var(--bg-secondary);
}

/* POI Marker in editor */
.poi-marker.editor-marker {
  cursor: move;
}

.poi-marker.editor-marker:active {
  cursor: grabbing;
}

.poi-marker .poi-marker-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 2.2em;
  font-weight: 600;
  font-family: var(--font-body);
  line-height: 1.1;
  padding: 0.2em 0.6em;
  background: #fff;
  color: #000;
  pointer-events: none;
  display: none;
  z-index: 30;
}

.poi-marker:hover .poi-marker-label,
#poi-layer.show-labels .poi-marker .poi-marker-label {
  display: block;
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 3000;
  min-width: 160px;
  padding: 0.3em 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 1em;
  font-size: 0.85em;
  cursor: pointer;
  transition: background var(--transition);
}

.context-menu-item:hover {
  background: var(--bg-tertiary);
}

.context-menu-item.danger {
  color: #c0392b;
}

.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.3em 0;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 1.5em;
  right: 1.5em;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75em 1.25em;
  font-size: 0.85em;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 5000;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.success {
  border-left: 3px solid #27ae60;
}

.toast.error {
  border-left: 3px solid #c0392b;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* Drag feedback */
#map-viewport.drag-over::after {
  content: 'Drop image here';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 2em 3em;
  font-size: 1.2em;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
  }

  #workspace.sidebar-hidden #sidebar {
    margin-left: -200px;
  }

  .poi-editor-body {
    padding: 1em;
  }

  .poi-editor-fields {
    grid-template-columns: 1fr;
  }

  .markdown-editor-split {
    grid-template-columns: 1fr;
    height: auto;
  }

  .markdown-editor-split textarea {
    height: 200px;
  }
}

/* ── View / Read-only mode ── */
body.viewmode .editor-only,
body.readonly .editor-only {
  display: none !important;
}

body.viewmode #world-name,
body.readonly #world-name {
  font-weight: 600;
}
