/* === Global Reset & Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #1e1e2e;
  --bg-mid: #252538;
  --bg-light: #2d2d44;
  --bg-hover: #383850;
  --bg-active: #4a4a6a;
  --text-primary: #e0e0e8;
  --text-secondary: #a0a0b8;
  --text-dim: #707088;
  --accent: #5b8def;
  --accent-hover: #7aa5ff;
  --accent-dim: #3a5f9e;
  --danger: #ef5b5b;
  --success: #5bef7a;
  --warning: #efcf5b;
  --border: #3a3a52;
  --border-light: #4a4a62;
  --toolbar-height: 72px;
  --menubar-height: 36px;
  --panel-width: 240px;
  --status-height: 28px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-dark);
  user-select: none;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* === Menu Bar === */
#menu-bar {
  height: var(--menubar-height);
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 100;
}

.menu-left, .menu-right { display: flex; align-items: center; gap: 4px; }
.menu-center { flex: 1; text-align: center; }

.app-logo {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-right: 16px;
  letter-spacing: 0.5px;
}

.menu-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu-btn.active { background: var(--accent-dim); color: var(--text-primary); border-color: var(--accent); }

.menu-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.menu-group { display: flex; align-items: center; gap: 2px; }

#doc-title {
  color: var(--text-secondary);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  outline: none;
  min-width: 100px;
  display: inline-block;
}
#doc-title:focus { background: var(--bg-light); color: var(--text-primary); }

#zoom-display {
  color: var(--text-secondary);
  font-size: 12px;
  min-width: 40px;
  text-align: center;
}

/* === App Container === */
#app-container {
  display: flex;
  height: calc(100vh - var(--menubar-height) - var(--toolbar-height));
  position: relative;
}

/* === Canvas Container === */
#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #1a1a2a;
  cursor: crosshair;
}

#main-canvas, #overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
}

#overlay-canvas {
  pointer-events: none;
  z-index: 2;
}

/* === Coordinate Display === */
#coord-display {
  position: absolute;
  bottom: var(--status-height);
  left: 0;
  padding: 4px 12px;
  background: rgba(30, 30, 46, 0.9);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0 4px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 10;
  display: flex;
  gap: 12px;
  font-family: 'Courier New', monospace;
}

/* === Status Bar === */
#status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--status-height);
  background: var(--bg-mid);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 10;
  gap: 16px;
}

#status-hint { color: var(--text-dim); }

/* === Text Input Overlay === */
#text-input-overlay {
  position: absolute;
  z-index: 50;
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--text-primary);
  font-size: 14px;
  padding: 4px;
  outline: none;
  resize: none;
  min-width: 100px;
  min-height: 24px;
}

/* === Modals === */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

/* === Dropdown Menus === */
.dropdown-menu {
  position: absolute;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 200;
  min-width: 180px;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
}
.dropdown-menu button:hover { background: var(--bg-hover); }
