/* ==========================================================================
   GridMaster - Workspace & Canvas Styles
   ========================================================================== */

.workspace-container {
  flex: 1;
  height: 100%;
  min-height: 0;
  min-width: 0;
  position: relative;
  background-color: var(--bg-workspace);
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(93, 93, 68, 0.08) 1px, transparent 0);
  background-size: 20px 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The Interactive Canvas Element */
#drawing-canvas {
  display: block;
  outline: 8px solid #FFFFFF;
  outline-offset: 0;
  box-shadow: var(--shadow-canvas), 0 0 0 1px var(--border-medium);
  border-radius: 2px;
  cursor: grab;
  touch-action: none;
}

/* Hide drawing canvas before an image or blank grid is loaded without breaking canvas dimensions */
body:not(.has-image) #drawing-canvas,
.workspace-container:not(.has-image) #drawing-canvas {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  top: 0 !important;
  left: 0 !important;
  z-index: -1 !important;
}

body.has-image #drawing-canvas,
.workspace-container.has-image #drawing-canvas {
  position: relative !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  display: block !important;
  max-width: 100% !important;
  z-index: 2 !important;
}

#drawing-canvas.is-panning {
  cursor: grabbing !important;
}

#drawing-canvas.is-cropping {
  cursor: crosshair !important;
}

/* Floating Zoom & Viewport HUD */
.workspace-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-floating);
  z-index: 20;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.workspace-hud.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

.hud-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

.hud-divider {
  width: 1px;
  height: 16px;
  background: var(--border-medium);
  margin: 0 4px;
}

.zoom-level-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 48px;
  text-align: center;
  padding: 0 4px;
  cursor: pointer;
}

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

/* Floating Quick Mode Switcher (Pan vs Select) */
.workspace-modes {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 3px;
  display: flex;
  gap: 3px;
  box-shadow: var(--shadow-sm);
  z-index: 20;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

.mode-btn.active {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
}

/* Canvas Rulers Overlay */
.ruler-top {
  position: absolute;
  top: 0;
  left: 30px;
  right: 0;
  height: 24px;
  background: rgba(26, 24, 22, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  display: none;
  z-index: 10;
  overflow: hidden;
}

.ruler-left {
  position: absolute;
  top: 24px;
  left: 0;
  bottom: 0;
  width: 30px;
  background: rgba(26, 24, 22, 0.85);
  border-right: 1px solid var(--border-subtle);
  display: none;
  z-index: 10;
  overflow: hidden;
}

.ruler-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 30px;
  height: 24px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: none;
  z-index: 11;
}

/* ==========================================================================
   Empty / Landing State Overlay
   ========================================================================== */
.empty-state-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
  background: var(--bg-workspace);
  overflow-y: auto;
}

.empty-state-overlay.hidden,
body.has-image .empty-state-overlay,
.workspace-container.has-image .empty-state-overlay {
  display: none !important;
}

.empty-state-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 40px 36px;
  margin: auto;
  text-align: center;
  box-shadow: var(--shadow-floating);
  animation: fadeInScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.empty-state-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  background: var(--bg-panel-hover);
  color: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
}

.empty-state-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.empty-state-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* Dropzone Zone */
.dropzone-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  background: var(--bg-app);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dropzone-box:hover, .dropzone-box.drag-over {
  border-color: var(--accent-primary);
  background: var(--bg-panel-hover);
  transform: translateY(-2px);
}

.dropzone-icon {
  color: var(--accent-primary);
}

.dropzone-text-main {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.dropzone-cta-btn {
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  pointer-events: auto;
  transition: all var(--transition-fast);
}

.dropzone-text-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.hidden-file-input {
  display: none;
}

/* Sample Images & Blank Grid Options */
.empty-state-alternatives {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.alt-action-link {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.alt-action-link:hover {
  background: var(--bg-panel-hover);
  color: var(--accent-primary);
}

.sample-pills {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sample-pill-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.sample-pill-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--bg-panel-hover);
}

/* Fullscreen Preview Mode Viewport */
body.is-preview-mode .app-header,
body.is-preview-mode .sidebar-controls,
body.is-preview-mode .workspace-modes {
  display: none !important;
}

body.is-preview-mode .workspace-container {
  width: 100vw;
  height: 100vh;
}

.preview-exit-hud {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 100;
  box-shadow: var(--shadow-floating);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

body.is-preview-mode .preview-exit-hud {
  display: flex;
}
