/* DrawX — Layout */

/* Top Nav */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 200;
  gap: 12px;
}
.topnav-left { display: flex; align-items: center; gap: 4px; flex: 1; }
.topnav-center { flex: 0 0 auto; }
.topnav-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  text-decoration: none;
}
.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

/* Nav Menus */
.topnav-menus { display: flex; align-items: center; }
.menu-item {
  position: relative;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  white-space: nowrap;
}
.menu-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.menu-item.active { color: var(--text-primary); background: var(--bg-active); }

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 200px;
  z-index: 300;
  box-shadow: var(--shadow-md);
  padding: 4px;
  animation: dropIn 0.15s ease;
}
@keyframes dropIn {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.menu-item:hover .dropdown,
.menu-item.open .dropdown { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.shortcut { color: var(--text-muted); font-size: 11px; }

/* Project Title */
.project-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: text;
  outline: none;
  min-width: 120px;
  text-align: center;
  transition: all 0.15s;
}
.project-title:hover { border-color: var(--border); }
.project-title:focus { border-color: var(--accent); background: var(--bg-tertiary); box-shadow: 0 0 0 2px var(--accent-muted); }

/* Theme Toggle in Nav */
.theme-toggle {
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-secondary);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* Main App Layout */
.app-layout {
  position: fixed;
  top: var(--topnav-h);
  bottom: var(--statusbar-h);
  left: 0; right: 0;
  display: flex;
  overflow: hidden;
}

/* Canvas Area */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--canvas-bg);
  background-image:
    radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0);
  background-size: 24px 24px;
}

.canvas-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
}

.canvas-viewport:active {
  cursor: grabbing;
}

.canvas-wrapper {
  position: absolute;
  transform-origin: 0 0;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
}

.canvas-wrapper canvas { display: block; }

/* Responsive Live Preview */
.responsive-preview {
  position: fixed;
  right: auto;
  bottom: auto;
  width: min(520px, calc(100% - 32px));
  height: 360px;
  max-height: min(360px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 640;
  min-width: 320px;
  min-height: 120px;
  resize: both;
  overflow: auto;
}

.floating-panel {
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 64px);
}

.panel-hidden {
  display: none !important;
}

.panel-window-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.panel-size-field {
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.panel-size-field input {
  width: 54px;
  height: 24px;
  padding: 2px 5px;
  text-align: right;
}

.panel-icon-btn,
.panel-restore-btn {
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 0 8px;
}

.panel-icon-btn:hover,
.panel-restore-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.panel-restore-btn {
  position: fixed;
  right: 16px;
  bottom: 42px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
}

.responsive-preview.collapsed .preview-grid {
  display: none;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: move;
  user-select: none;
  gap: 8px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr .55fr;
  gap: 8px;
  align-items: end;
  min-height: 0;
  flex: 1;
}

.preview-device {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.preview-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.preview-frame {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transform-origin: top left;
}

.preview-frame.desktop { height: clamp(120px, 42vh, 240px); }
.preview-frame.tablet { height: clamp(140px, 48vh, 280px); }
.preview-frame.phone { height: clamp(160px, 56vh, 320px); }

/* Floating Selection Toolbar */
.context-toolbar {
  position: fixed;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.context-toolbar.hidden {
  display: none;
}

.ctx-tool-btn,
.ctx-select,
.ctx-size {
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.ctx-select {
  min-width: 104px;
  padding: 0 6px;
}

.ctx-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ctx-tool-btn.danger {
  color: var(--error);
}

.ctx-color {
  width: 30px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.ctx-color input {
  width: 36px;
  height: 34px;
  border: 0;
  padding: 0;
  transform: translate(-3px, -3px);
}

.ctx-size input {
  width: 48px;
  height: 22px;
  padding: 2px 4px;
  text-align: right;
}

.context-toolbar:not(.is-text) .text-only {
  display: none;
}

.context-toolbar:not(.is-shape) .shape-only {
  display: none;
}

.context-toolbar:not(.is-image) .image-only {
  display: none;
}

.context-toolbar:not(.is-video) .video-only {
  display: none;
}

.export-settings-panel {
  position: fixed;
  width: 360px;
  min-width: 300px;
  min-height: 320px;
  padding: 12px;
  resize: both;
  overflow: auto;
  z-index: 670;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.export-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  cursor: move;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.export-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.export-grid .export-check {
  flex-direction: row;
  align-items: center;
  text-transform: none;
  font-size: 12px;
}

.export-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.export-presets button {
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
}

.export-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Status Bar */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--statusbar-h);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  gap: 16px;
}
.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
.status-center {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-divider { color: var(--border); }
.status-item { white-space: nowrap; }

.zoom-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 22px; height: 22px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}
.zoom-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.zoom-display {
  font-size: 11px;
  color: var(--text-primary);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
