/* Slab Layout Overlay Styles */

/* Main Panel Container */
.slab-layout-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.slab-layout-panel.hidden {
  display: none;
}

/* Header */
.slab-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.slab-panel-header h2 {
  margin: 0;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.slab-panel-header h2::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2300d4aa' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z'/%3E%3Cpath d='M7 12h4v5H7zm6-5h4v10h-4z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Buttons */
.slab-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.slab-btn-primary {
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  color: #000;
}

.slab-btn-primary:hover {
  background: linear-gradient(135deg, #00e6b8 0%, #00cfa5 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.slab-btn-secondary {
  background: #2d3748;
  color: #fff;
  border: 1px solid #4a5568;
}

.slab-btn-secondary:hover {
  background: #3d4a5c;
  border-color: #5a6878;
}

.slab-btn-danger {
  background: #e53e3e;
  color: #fff;
}

.slab-btn-danger:hover {
  background: #f56565;
}

.slab-btn-icon {
  padding: 8px;
  min-width: 36px;
  justify-content: center;
}

.slab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Main Content Layout */
.slab-panel-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Sidebar */
.slab-sidebar {
  width: 320px;
  background: #1a1a2e;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Tabs */
.slab-tabs {
  display: flex;
  border-bottom: 1px solid #333;
  background: #16213e;
}

.slab-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #8892a6;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.slab-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.slab-tab.active {
  color: #00d4aa;
  background: rgba(0, 212, 170, 0.1);
}

.slab-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #00d4aa;
}

/* Tab Content */
.slab-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.slab-tab-pane {
  display: none;
}

.slab-tab-pane.active {
  display: block;
}

/* Section Headers */
.slab-section {
  margin-bottom: 20px;
}

.slab-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8892a6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Slab Size Selector */
.slab-size-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.slab-size-option {
  padding: 10px;
  background: #2d3748;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.slab-size-option:hover {
  border-color: #4a5568;
  background: #3d4a5c;
}

.slab-size-option.selected {
  border-color: #00d4aa;
  background: rgba(0, 212, 170, 0.1);
}

.slab-size-option .size-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.slab-size-option .size-dims {
  font-size: 0.75rem;
  color: #8892a6;
}

/* Custom Size Input */
.slab-custom-size {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.slab-custom-size input {
  width: 70px;
  padding: 8px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 4px;
  color: #fff;
  font-size: 0.875rem;
  text-align: center;
}

.slab-custom-size input:focus {
  outline: none;
  border-color: #00d4aa;
}

.slab-custom-size span {
  color: #8892a6;
  font-size: 0.875rem;
}

/* Piece List */
.piece-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.piece-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #2d3748;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.piece-item:hover {
  background: #3d4a5c;
}

.piece-item.selected {
  border-color: #00d4aa;
  background: rgba(0, 212, 170, 0.15);
}

.piece-item.placed {
  opacity: 0.6;
}

.piece-item.placed::after {
  content: 'Placed';
  margin-left: auto;
  font-size: 0.7rem;
  color: #00d4aa;
  background: rgba(0, 212, 170, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.piece-color {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  margin-right: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.piece-info {
  flex: 1;
  min-width: 0;
}

.piece-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.piece-dims {
  font-size: 0.75rem;
  color: #8892a6;
}

.piece-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.piece-item:hover .piece-actions {
  opacity: 1;
}

.piece-action-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: #4a5568;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.piece-action-btn:hover {
  background: #5a6878;
}

.piece-action-btn.delete:hover {
  background: #e53e3e;
}

/* Inventory Search */
.inventory-search {
  position: relative;
  margin-bottom: 16px;
}

.inventory-search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 8px;
  color: #fff;
  font-size: 0.875rem;
}

.inventory-search input:focus {
  outline: none;
  border-color: #00d4aa;
}

.inventory-search::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%238892a6' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Inventory Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.inventory-slab {
  background: #2d3748;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.inventory-slab:hover {
  border-color: #4a5568;
  transform: translateY(-2px);
}

.inventory-slab.selected {
  border-color: #00d4aa;
}

.inventory-slab-image {
  width: 100%;
  height: 80px;
  object-fit: cover;
  background: #1a1a2e;
}

.inventory-slab-info {
  padding: 10px;
}

.inventory-slab-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-slab-details {
  font-size: 0.7rem;
  color: #8892a6;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #8892a6;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Canvas Container */
.slab-canvas-container {
  display: none;
  flex: 1;
  position: relative;
  background: #0d1117;
  overflow: hidden;
}

.slab-canvas-container.active {
  display: flex;
  flex-direction: column;
}

.slab-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
}

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

.slab-canvas.tool-select {
  cursor: default;
}

.slab-canvas.tool-rotate {
  cursor: crosshair;
}

/* Canvas Toolbar */
.canvas-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  background: rgba(26, 26, 46, 0.95);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  z-index: 10;
}

.canvas-tool {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #8892a6;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.canvas-tool:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.canvas-tool.active {
  background: #00d4aa;
  color: #000;
}

.canvas-tool svg {
  width: 20px;
  height: 20px;
}

.toolbar-divider {
  width: 1px;
  background: #333;
  margin: 4px 0;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(26, 26, 46, 0.95);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  z-index: 10;
}

.zoom-level {
  font-size: 0.75rem;
  color: #8892a6;
  text-align: center;
  padding: 4px 0;
}

/* Stats Panel */
.slab-stats {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(26, 26, 46, 0.95);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #333;
  min-width: 200px;
  z-index: 10;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #333;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 0.8rem;
  color: #8892a6;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.stat-value.yield-good {
  color: #48bb78;
}

.stat-value.yield-warning {
  color: #ecc94b;
}

.stat-value.yield-poor {
  color: #f56565;
}

/* Yield Bar */
.yield-bar {
  height: 8px;
  background: #2d3748;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.yield-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #48bb78 0%, #00d4aa 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Vein Guide Overlay */
.vein-guide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.vein-guide-lines {
  stroke: rgba(0, 212, 170, 0.3);
  stroke-width: 1;
  stroke-dasharray: 8, 4;
}

/* Seam Indicator */
.seam-indicator {
  position: absolute;
  background: rgba(255, 193, 7, 0.8);
  height: 3px;
  pointer-events: none;
  z-index: 15;
}

.seam-indicator::before {
  content: 'SEAM';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 600;
  color: #ffc107;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Action Bar */
.slab-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #16213e;
  border-top: 1px solid #333;
  flex-shrink: 0;
}

.action-bar-left,
.action-bar-right {
  display: flex;
  gap: 10px;
}

/* Modal Overlay */
.slab-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.slab-modal {
  background: #1a1a2e;
  border-radius: 12px;
  border: 1px solid #333;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
}

.slab-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
}

.slab-modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
}

.slab-modal-close {
  background: transparent;
  border: none;
  color: #8892a6;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}

.slab-modal-close:hover {
  color: #fff;
}

.slab-modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 60vh;
}

.slab-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #333;
}

/* Form Elements */
.slab-form-group {
  margin-bottom: 16px;
}

.slab-form-group:last-child {
  margin-bottom: 0;
}

.slab-form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 8px;
}

.slab-form-input,
.slab-form-select {
  width: 100%;
  padding: 10px 12px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #fff;
  font-size: 0.875rem;
}

.slab-form-input:focus,
.slab-form-select:focus {
  outline: none;
  border-color: #00d4aa;
}

.slab-form-row {
  display: flex;
  gap: 12px;
}

.slab-form-row .slab-form-group {
  flex: 1;
}

/* Loading State */
.slab-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.slab-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #333;
  border-top-color: #00d4aa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Tooltip */
.slab-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 100;
  max-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.slab-tooltip::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

/* Keyboard Shortcut Hints */
.shortcut-hint {
  display: inline-block;
  padding: 2px 6px;
  background: #2d3748;
  border-radius: 4px;
  font-size: 0.7rem;
  color: #8892a6;
  margin-left: 8px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .slab-sidebar {
    width: 280px;
  }

  .inventory-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .slab-panel-content {
    flex-direction: column;
  }

  .slab-sidebar {
    width: 100%;
    height: 40%;
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .slab-canvas-container {
    height: 60%;
  }

  .slab-stats {
    top: auto;
    bottom: 60px;
    right: 8px;
    min-width: 150px;
    padding: 10px;
  }

  .canvas-toolbar {
    left: 8px;
    top: 8px;
  }

  .zoom-controls {
    bottom: 60px;
  }
}

/* Print Styles for Cut Sheet */
@media print {
  .slab-layout-panel {
    position: static;
    background: #fff;
  }

  .slab-panel-header,
  .slab-sidebar,
  .slab-action-bar,
  .canvas-toolbar,
  .zoom-controls {
    display: none !important;
  }

  .slab-canvas-container {
    width: 100%;
    height: auto;
  }

  .slab-stats {
    position: static;
    background: #fff;
    border: 1px solid #ccc;
    color: #000;
  }

  .stat-label,
  .stat-value {
    color: #000;
  }
}
