/* ═══════════════════════════════════════════════════════════════
   CNC CAM TAB — Styles
   ═══════════════════════════════════════════════════════════════ */

.cnc-layout {
  display: flex;
  height: calc(100vh - 160px);
  min-height: 500px;
  gap: 0;
}

.cnc-operations-panel {
  width: 360px;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  background: var(--bg-secondary, #14142b);
}

.cnc-preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Accordion */
.cnc-accordion { border-bottom: 1px solid rgba(255,255,255,0.06); }
.cnc-accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; user-select: none;
  background: rgba(255,255,255,0.02);
  transition: background 0.15s;
}
.cnc-accordion-header:hover { background: rgba(255,255,255,0.04); }
.cnc-accordion-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.5); }
.cnc-accordion-badge { font-size: 10px; background: rgba(59,130,246,0.15); color: #60A5FA; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.cnc-accordion-chevron { font-size: 10px; color: rgba(255,255,255,0.3); transition: transform 0.2s; }
.cnc-accordion.open .cnc-accordion-chevron { transform: rotate(90deg); }
.cnc-accordion-body { display: none; }
.cnc-accordion.open .cnc-accordion-body { display: block; }

.cnc-stock-info {
  padding: 10px 14px;
}

.cnc-operations-list {
  padding: 2px 0;
}

.cnc-operation {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.1s;
}

.cnc-operation:hover {
  background: rgba(255,255,255,0.03);
}

.cnc-operation.selected {
  background: rgba(59,130,246,0.08);
  border-left: 3px solid #3B82F6;
}

.cnc-operation.disabled {
  opacity: 0.4;
}

.cnc-preview-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #0a0a1a;
}

.cnc-preview-area svg {
  width: 100%;
  height: 100%;
}

.cnc-gcode-preview {
  background: #0a0a1a;
  color: #22C55E;
  padding: 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.4;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre;
  margin: 0;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Operation Editor */
.cnc-op-editor { padding: 10px 14px; }
.cnc-field-group { margin-bottom: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cnc-field-label { font-size: 11px; color: rgba(255,255,255,0.5); min-width: 90px; font-weight: 600; }
.cnc-field-hint { font-size: 10px; color: rgba(255,255,255,0.3); }
.cnc-field-row { display: flex; gap: 10px; align-items: center; }
.cnc-indent { padding-left: 96px; }

/* Actions bar at bottom */
.cnc-actions-bar { padding: 10px 14px; }

.cnc-input, .cnc-select { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 6px 10px; color: #fff; font-size: 13px; font-family: 'JetBrains Mono', monospace; }
.cnc-input:focus, .cnc-select:focus { border-color: #3B82F6; outline: none; }
.cnc-input-sm { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; padding: 4px 8px; color: #fff; font-size: 12px; font-family: 'JetBrains Mono', monospace; width: 70px; }
.cnc-select option { background: #1a1a2e; color: #fff; }

.cnc-btn { padding: 8px 16px; background: #3B82F6; border: none; border-radius: 6px; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.cnc-btn:hover { background: #2563EB; }
.cnc-btn-sm { padding: 4px 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; color: rgba(255,255,255,0.6); font-size: 11px; cursor: pointer; transition: all 0.15s; }
.cnc-btn-sm:hover { background: rgba(255,255,255,0.1); color: #fff; }
.cnc-btn-danger { background: transparent; border: 1px solid rgba(239,68,68,0.3); color: #EF4444; }
.cnc-btn-danger:hover { background: rgba(239,68,68,0.1); }

/* Chip Load Indicator */
.cnc-chip-load { padding: 6px 10px; border-radius: 6px; }
.cnc-chip-load.good { background: rgba(34,197,94,0.1); }
.cnc-chip-load.warning { background: rgba(245,158,11,0.1); }
.cnc-chip-load.error { background: rgba(239,68,68,0.1); }
.cnc-chip-value { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; }
.cnc-chip-advice { font-size: 12px; color: rgba(255,255,255,0.5); }

/* Tool Library */
.tool-lib-list { max-height: 400px; overflow-y: auto; }
.tool-lib-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.06); transition: background 0.15s; }
.tool-lib-item:hover { background: rgba(255,255,255,0.03); }
.tool-lib-icon { width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.tool-lib-info { flex: 1; min-width: 0; }
.tool-lib-name { font-size: 14px; font-weight: 600; }
.tool-lib-specs { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.tool-lib-defaults { font-size: 11px; color: rgba(255,255,255,0.3); font-family: 'JetBrains Mono', monospace; }
.tool-lib-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Cut Method Selector */
.sheet-cut-method { display: inline-flex; align-items: center; gap: 6px; }
.cut-method-select { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; padding: 2px 6px; color: rgba(255,255,255,0.7); font-size: 11px; cursor: pointer; }
.cut-method-select:focus { border-color: #3B82F6; outline: none; }
.cut-method-select option { background: #1a1a2e; color: #fff; }

/* CNC Form in modals */
.cnc-form .cnc-field-group { margin-bottom: 12px; }
.cnc-form label { font-size: 12px; color: rgba(255,255,255,0.5); min-width: 140px; display: inline-block; }
.cnc-form .cnc-input, .cnc-form .cnc-select { width: 100%; }
.cnc-form textarea.cnc-input { resize: vertical; min-height: 40px; }

/* Drill pattern preview */
.drill-pattern-preview { background: rgba(0,0,0,0.3); border-radius: 6px; padding: 12px; margin-top: 8px; }

/* Operation selected edit view */
.cnc-op-editor h3 { font-size: 15px; color: #fff; }
.cnc-op-editor .cnc-field-group + .cnc-field-group { border-top: none; }

/* Operation Template Menu ("What Are You Making?") */
.op-template-grid { display: flex; flex-direction: column; gap: 4px; }
.op-template-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.35); padding: 12px 0 4px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.op-template { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.op-template:hover { background: rgba(59,130,246,0.1); }
.op-template-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: rgba(255,255,255,0.05); border-radius: 8px; flex-shrink: 0; color: rgba(255,255,255,0.6); font-weight: 700; }
.op-template-info { flex: 1; min-width: 0; }
.op-template-name { font-size: 13px; font-weight: 600; }
.op-template-desc { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 1px; }

/* CNC Empty State / Start Screen */
.cnc-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 40px; text-align: center; color: rgba(255,255,255,0.6); }
.cnc-empty h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: rgba(255,255,255,0.8); }
.cnc-empty p { font-size: 14px; color: rgba(255,255,255,0.4); margin-bottom: 20px; }
.cnc-start-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-width: 560px; width: 100%; }
.cnc-start-btn { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 20px 16px; text-align: center; cursor: pointer; transition: all 0.2s; color: #fff; }
.cnc-start-btn:hover { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.3); transform: translateY(-1px); }
.cnc-start-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.7; }
.cnc-start-label { font-size: 14px; font-weight: 700; }
.cnc-start-desc { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 4px; line-height: 1.4; }

/* Edge Trim Settings */
.cnc-trim-settings { padding: 10px 14px; }
.cnc-trim-diagram { text-align: center; margin: 8px 0; }
.cnc-trim-inputs { margin-top: 6px; }
.cnc-trim-inputs label { font-size: 11px; color: rgba(255,255,255,0.4); min-width: auto; }

/* Material Warnings */
.cnc-warning { display: flex; gap: 8px; padding: 8px 10px; border-radius: 6px; font-size: 11px; line-height: 1.4; margin-bottom: 6px; }
.cnc-warning.warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); color: rgba(245,158,11,0.9); }
.cnc-warning.info { background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.15); color: rgba(96,165,250,0.9); }
.cnc-warning-icon { flex-shrink: 0; font-size: 14px; }

/* Operation Header Bar */
.op-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; background: rgba(255,255,255,0.03); border-radius: 6px; margin-bottom: 4px; }
.op-header-left { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.op-number { font-weight: 700; font-size: 12px; color: rgba(255,255,255,0.4); min-width: 18px; }
.op-name-input { background: transparent; border: none; color: #fff; font-size: 12px; font-weight: 600; flex: 1; min-width: 0; padding: 2px 4px; border-radius: 4px; }
.op-name-input:hover { background: rgba(255,255,255,0.05); }
.op-name-input:focus { background: rgba(255,255,255,0.08); outline: 1px solid rgba(59,130,246,0.3); }
.op-header-actions { display: flex; gap: 1px; flex-shrink: 0; }
.op-action-btn { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; color: rgba(255,255,255,0.3); cursor: pointer; border-radius: 4px; font-size: 12px; }
.op-action-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.op-action-btn:disabled { opacity: 0.2; cursor: default; }
.op-action-danger:hover { background: rgba(239,68,68,0.15); color: #EF4444; }

/* Pattern Editor */
.op-pattern-editor { padding: 6px 0; }
.op-pattern-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; font-weight: 600; }
.op-pattern-params { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.op-pattern-individual { padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.06); margin-top: 6px; }
.op-pattern-help { padding: 6px 10px; background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.1); border-radius: 6px; font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 6px; line-height: 1.4; }
.op-pattern-presets { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

/* Interactive Preview */
.cnc-interactive-hole { transition: fill 0.1s; cursor: pointer; }
.cnc-interactive-hole:hover { fill-opacity: 1; }
.cnc-interactive-groove { cursor: ns-resize; }
.cnc-interactive-groove:hover { opacity: 1 !important; }
.cnc-interactive-part { cursor: pointer; transition: fill-opacity 0.1s; }
.cnc-interactive-part:hover { fill-opacity: 0.25 !important; }

/* Status Bar */
.cnc-status-bar { padding: 5px 14px; background: rgba(0,0,0,0.3); border-top: 1px solid rgba(255,255,255,0.06); font-size: 11px; color: rgba(255,255,255,0.35); display: flex; justify-content: space-between; gap: 12px; flex-shrink: 0; }

/* Responsive */
@media (max-width: 1024px) {
  .cnc-layout { flex-direction: column; }
  .cnc-operations-panel { width: 100%; max-height: 45vh; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06); }
}

@media (max-width: 768px) {
  .cnc-operations-panel { max-height: 40vh; }
  .cnc-field-label { min-width: 70px; font-size: 10px; }
  .cnc-op-editor { padding: 8px 10px; }
}
