/* ===== PROFESSIONAL CUT LIST OPTIMIZER STYLES ===== */

/* CSS Variables for consistent theming */
:root {
  --accent-color: #8C5A3C;
  --primary-color: #8C5A3C;
  --accent-hover: #7A4F33;
  --primary-hover: #7A4F33;
  --bg-color: #f5f5f5;
  --panel-bg: #ffffff;
  --border-color: #e0e0e0;
  --text-primary: #333333;
  --text-secondary: #666666;
  --success-color: #4CAF50;
  --danger-color: #f44336;
  --warning-color: #ff9800;
  --info-color: #2196F3;
}

/* Ensure all buttons are visible */
button {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Ensure proper button contrast */
.optimize-btn,
.export-btn,
.add-piece-btn {
  color: white !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.remove-piece {
  color: white !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Main Layout */
.optimizer-main {
  background: var(--bg-color);
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

/* Professional Tool Header */
.tool-header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tool-title h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.tool-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

.tool-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: #f8f9fa;
  border-color: var(--accent-color);
}

.action-btn.primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.action-btn.primary:hover {
  background: var(--primary-hover);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 1rem;
}

/* Tool Toolbar */
.tool-toolbar {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbar-group {
  display: flex;
  gap: 0.25rem;
}

.toolbar-btn {
  padding: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #f8f9fa;
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* Main Interface Container */
.interface-container {
  display: grid;
  grid-template-columns: 350px 1fr 350px;
  grid-template-areas: "input visualization stats";
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 140px);
  overflow: visible;
}

/* Input Panel */
.input-panel {
  background: var(--panel-bg);
  border-radius: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  grid-area: input;
  padding: 0;
}

/* Collapsible Sections */
.input-section,
.stats-section {
  border-bottom: 1px solid var(--border-color);
}

.section-header {
  padding: 0.75rem;
  background: #f8f9fa;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.section-header:hover {
  background: #e9ecef;
}

.section-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-toggle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.section-content {
  padding: 0.75rem;
  display: none;
}

.section-content.active {
  display: block;
}

/* Table Styles */
.table-container {
  margin-bottom: 1rem;
}

.input-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.input-table th {
  background: #f8f9fa;
  padding: 0.5rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.input-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #f0f0f0;
}

.input-table input {
  width: 100%;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 0.875rem;
}

.input-table input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(140, 90, 60, 0.1);
}

.actions {
  display: flex;
  gap: 0.25rem;
}

.action-icon {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.action-icon.confirm {
  background: var(--success-color);
  color: white;
}

.action-icon.confirm:hover {
  background: #45a049;
}

.action-icon.remove {
  background: var(--danger-color);
  color: white;
}

.action-icon.remove:hover {
  background: #da190b;
}

.action-icon.drag {
  background: var(--text-secondary);
  color: white;
  cursor: grab;
}

.action-icon.drag:hover {
  background: var(--text-primary);
}

.add-row-btn {
  width: 100%;
  padding: 0.5rem;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background-color 0.2s ease;
}

.add-row-btn:hover {
  background: var(--accent-hover);
}

/* Options */
.option-group {
  margin-bottom: 1rem;
}

.option-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.option-input {
  width: 80px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 0.875rem;
}

/* Toggle Switches */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

.toggle-input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 20px;
  background: #ccc;
  border-radius: 10px;
  position: relative;
  transition: background-color 0.2s ease;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
}

.toggle-input:checked + .toggle-slider {
  background: var(--accent-color);
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Visualization Panel */
.visualization-panel {
  background: var(--panel-bg);
  border-radius: 8px;
  overflow: visible;
  position: relative;
  grid-area: visualization;
  min-height: 400px;
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 400px;
}

#optimization-canvas {
  width: 100%;
  height: 100%;
  background: #fafafa;
  border: 1px solid var(--border-color);
}

.canvas-overlay {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.zoom-controls {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: #f8f9fa;
  border-color: var(--accent-color);
}

/* Stats Panel */
.stats-panel {
  background: var(--panel-bg);
  border-radius: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  grid-area: stats;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Cuts Table */
.cuts-table-container {
  overflow-x: auto;
}

.cuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.cuts-table th,
.cuts-table td {
  padding: 0.25rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.cuts-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--text-primary);
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .interface-container {
    grid-template-columns: 300px 1fr 300px;
  }
}

@media (max-width: 1024px) {
  .interface-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: 
      "input"
      "visualization"
      "stats";
    height: auto;
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  .input-panel {
    grid-area: input;
    max-height: none;
    min-height: 250px;
  }
  
  .visualization-panel {
    grid-area: visualization;
    min-height: 250px;
    max-height: 350px;
  }
  
  .stats-panel {
    grid-area: stats;
    max-height: none;
    min-height: 250px;
    overflow-y: visible;
  }
}

@media (max-width: 768px) {
  .tool-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 1rem;
  }
  
  .tool-title h1 {
    font-size: 1.25rem;
  }
  
  .tool-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .action-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
  
  .tool-toolbar {
    padding: 0.5rem 1rem;
    justify-content: center;
  }
  
  .toolbar-group {
    gap: 0.25rem;
  }
  
  .toolbar-btn {
    padding: 0.75rem;
    font-size: 1rem;
  }
  
  .interface-container {
    padding: 0.5rem;
    gap: 0.5rem;
    height: auto;
    min-height: calc(100vh - 200px);
  }
  
  .input-panel {
    min-height: 250px;
    max-height: 350px;
  }
  
  .visualization-panel {
    min-height: 250px;
    max-height: 350px;
  }
  
  .stats-panel {
    min-height: 250px;
    max-height: 350px;
    overflow-y: visible;
  }
  
  .section-header {
    padding: 0.75rem;
  }
  
  .section-content {
    padding: 0.75rem;
  }
  
  .input-table {
    font-size: 0.8rem;
  }
  
  .input-table th,
  .input-table td {
    padding: 0.4rem;
  }
  
  .input-table input {
    font-size: 0.8rem;
    padding: 0.4rem;
  }
  
  .stat-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
  }
  
  .stat-label,
  .stat-value {
    font-size: 0.8rem;
    word-break: break-word;
  }
  
  .cuts-table {
    font-size: 0.7rem;
  }
  
  .cuts-table th,
  .cuts-table td {
    padding: 0.3rem;
    word-break: break-word;
  }
  
  /* Fix footer on mobile */
  .footer {
    padding: 1rem 0.5rem;
    text-align: center;
    font-size: 0.8rem;
  }
  
    .footer a {
    word-break: break-all;
  }
}
  
  .input-table th,
  .input-table td {
    padding: 0.25rem;
  }
  
  .input-table input {
    font-size: 0.75rem;
    padding: 0.25rem;
  }
  
  .action-icon {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  
  .stat-item {
    padding: 0.25rem 0;
  }
  
  .stat-label,
  .stat-value {
    font-size: 0.75rem;
  }


@media (max-width: 480px) {
  .tool-header {
    padding: 0.75rem;
  }
  
  .tool-title h1 {
    font-size: 1.1rem;
  }
  
  .tool-subtitle {
    font-size: 0.75rem;
  }
  
  .action-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
  
  .interface-container {
    padding: 0.25rem;
    gap: 0.25rem;
  }
  
  .section-header {
    padding: 0.5rem;
  }
  
  .section-content {
    padding: 0.5rem;
  }
  
  .input-table {
    font-size: 0.7rem;
  }
  
  .input-table th,
  .input-table td {
    padding: 0.2rem;
  }
  
  .input-table input {
    font-size: 0.7rem;
    padding: 0.2rem;
  }
  
  .add-row-btn {
    padding: 0.4rem;
    font-size: 0.75rem;
  }
  
  .option-label {
    font-size: 0.75rem;
  }
  
  .option-input {
    width: 60px;
    font-size: 0.75rem;
  }
  
  .toggle-label {
    font-size: 0.75rem;
  }
  
  .toggle-slider {
    width: 32px;
    height: 16px;
  }
  
  .toggle-slider:before {
    width: 12px;
    height: 12px;
  }
  
  .toggle-input:checked + .toggle-slider:before {
    transform: translateX(16px);
  }
  
  /* Additional mobile fixes for statistics and footer */
  .stats-panel {
    overflow-y: auto;
  }
  
  .stat-item {
    padding: 0.3rem 0;
  }
  
  .stat-label,
  .stat-value {
    font-size: 0.7rem;
    word-break: break-word;
  }
  
  .cuts-table {
    font-size: 0.65rem;
  }
  
  .cuts-table th,
  .cuts-table td {
    padding: 0.2rem;
    word-break: break-word;
  }
  
  .footer {
    padding: 0.75rem 0.25rem;
    text-align: center;
    font-size: 0.7rem;
  }
  
  .footer a {
    word-break: break-all;
  }
}

/* Animation for collapsible sections */
.section-content {
  display: none;
  transition: all 0.3s ease;
}

.section-content.active {
  display: block;
}

.section-toggle {
  transition: transform 0.3s ease;
}

.section-header.active .section-toggle {
  transform: rotate(180deg);
}
