/* ShopBot Labs - Slicer App Styles */

:root {
  --primary: #171b60;
  --accent: #f00069;
  --accent-hover: #d10059;

  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --border-color: #d2d2d7;

  --sidebar-width: 300px;
  --preview-height: 200px;
}

.dark-mode {
  --bg-primary: #1d1d1f;
  --bg-secondary: #2d2d30;
  --bg-tertiary: #3d3d40;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --border-color: #424245;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}
.sidebar-logo { height: 20px; width: auto; }
.header-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unit-toggle {
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.3);
}

.unit-btn {
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.15s ease;
}

.unit-btn:hover {
  color: white;
  border-color: transparent;
}

.unit-btn.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

#themeToggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
}

.light-mode .dark-icon,
.dark-mode .light-icon {
  display: none;
}

/* Control Sections */
.control-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.control-section h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.2s ease;
  background: var(--bg-primary);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(240, 0, 105, 0.05);
}

.drop-zone p {
  margin: 0;
  color: var(--text-secondary);
}

.drop-zone-or {
  font-size: 0.75rem;
  margin: 0.5rem 0 !important;
}

.file-input-label {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
}

.file-input-label:hover {
  background: var(--accent-hover);
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-primary);
  border-radius: 6px;
  margin-top: 0.5rem;
}

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

#fileName {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#clearFile {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.25rem;
}

#clearFile:hover {
  color: var(--accent);
}

.model-info {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.model-info.hidden {
  display: none;
}

/* Dimensions Grid */
.dims-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dim-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dim-axis {
  width: 1.4rem;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
}

.dim-x { color: #e74c3c; }
.dim-y { color: #2ecc71; }
.dim-z { color: #3498db; }

.dim-row input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.5rem;
}

.dim-row .unit-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 1.2rem;
}

.link-btn {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--text-secondary);
  border-color: var(--border-color);
  background: var(--bg-primary);
}

.link-btn.linked {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(240, 0, 105, 0.08);
}

.link-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.link-icon {
  line-height: 1;
}

.dims-footer {
  margin-top: 0.5rem;
}

.dims-footer button {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
}

/* Axis Buttons */
.axis-buttons {
  display: flex;
  gap: 0.25rem;
}

.axis-btn {
  flex: 1;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.axis-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Button Rows */
.button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.button-row button {
  flex: 1;
}

/* Buttons */
button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

/* Input Grids */
.input-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  align-items: center;
}

input[type="number"],
select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.input-with-unit input {
  flex: 1;
  min-width: 0;
}

.input-with-unit span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Bit select with custom input */
.bit-select-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.bit-select-row select {
  flex: 1;
  min-width: 0;
}

.bit-select-row.custom-active select {
  flex: 0 0 auto;
  width: auto;
}

.custom-bit-wrap {
  flex: 1;
  min-width: 0;
}

.custom-bit-wrap input {
  width: 100%;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.engrave-depth-wrap {
  flex-shrink: 0;
}

.engrave-depth-wrap input {
  width: 3.5rem;
}

/* Advanced Settings */
.advanced-settings {
  margin-top: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
}

.advanced-settings summary {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.advanced-settings summary:hover {
  color: var(--text-primary);
}

.advanced-settings[open] summary {
  border-bottom: 1px solid var(--border-color);
}

.advanced-settings .input-grid {
  padding: 0.75rem;
  margin: 0;
}

/* Info Blocks */
.info-block {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 0.8rem;
}

.info-block.hidden {
  display: none;
}

.info-block div {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
}

.info-block span {
  font-weight: 500;
}

/* Canvas Container */
#canvasContainer {
  position: fixed;
  left: var(--sidebar-width);
  top: 0;
  right: 0;
  bottom: var(--preview-height);
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Status Bar */
#statusBar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.8rem;
}

/* Toolpath Info Overlay */
#toolpathInfo {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 200px;
}

#toolpathInfo.hidden {
  display: none;
}

#toolpathInfo h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Preview Panel (bottom strip) */
#previewPanel {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  height: var(--preview-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: row;
  z-index: 100;
}

.preview-header {
  padding: 0.75rem;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 120px;
}

.preview-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0;
  white-space: nowrap;
}

.sheet-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sheet-nav.hidden {
  display: none;
}

.sheet-nav button {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}

#sheetLabel {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.preview-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  overflow: hidden;
}

#nestCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#loadingOverlay.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loadingText {
  color: white;
  margin-top: 1rem;
  font-size: 1rem;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
