/* WiWell Film Cutting Planner Styles */

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Header */
.planner-header {
  background: linear-gradient(135deg, #00788a 0%, #004d5a 100%);
  color: white;
  padding: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo-section .back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.logo-section .back-link:hover {
  opacity: 0.8;
}

.title-section {
  flex: 1;
  text-align: center;
}

.title-section h1 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  margin-bottom: 0.25rem;
}

.title-section p {
  margin: 0;
  opacity: 0.9;
  font-size: 1rem;
}



/* Main Content */
.planner-main {
  padding: 2rem 0;
  background: #f8f9fa;
  min-height: calc(100vh - 200px);
}

/* Cards */
.specs-card,
.management-card,
.controls-card,
.results-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid #e9ecef;
}

/* Film Specifications */
.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.spec-item label {
  font-weight: 500;
  color: #495057;
  min-width: 120px;
}

.spec-value {
  font-weight: 600;
  color: #00788a;
  font-size: 1.1rem;
}

.spec-input {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  color: #00788a;
}

.unit {
  color: #6c757d;
  font-size: 0.9rem;
}

/* Object Management */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.card-header h2 {
  margin: 0;
  color: #212529;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: #00788a;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #005a6b;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #545b62;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-success:hover {
  background: #218838;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-outline {
  background: transparent;
  color: #00788a;
  border: 1px solid #00788a;
}

.btn-outline:hover {
  background: #00788a;
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

/* Object Form */
.object-form {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.object-form.hidden {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #495057;
}

.form-input {
  padding: 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #00788a;
  box-shadow: 0 0 0 3px rgba(0, 120, 138, 0.1);
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #00788a;
}

.form-actions {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 1rem;
  justify-content: flex-end;
}

/* Objects Table */
.objects-table-container {
  overflow-x: auto;
  border: 1px solid #e9ecef;
  border-radius: 8px;
}

.objects-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.objects-table th,
.objects-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
}

.objects-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #495057;
  position: sticky;
  top: 0;
}

 .objects-table tbody tr:hover {
   background: #f8f9fa;
 }

 .objects-table .total-row {
   background: #e3f2fd;
   border-top: 2px solid #00788a;
   font-weight: 600;
 }

 .objects-table .total-row:hover {
   background: #e3f2fd;
 }

.objects-table td:last-child {
  white-space: nowrap;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  padding: 0.5rem;
  border: none;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #e9ecef;
  color: #495057;
}

.btn-edit:hover {
  color: #00788a;
}

.btn-delete:hover {
  color: #dc3545;
}

.btn-duplicate:hover {
  color: #28a745;
}

/* No Objects State */
.no-objects {
  text-align: center;
  padding: 3rem 2rem;
  color: #6c757d;
}

.no-objects i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Bulk Actions */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 8px 8px;
}

.bulk-actions.hidden {
  display: none;
}

.selected-count {
  color: #6c757d;
  font-size: 0.9rem;
}

/* Optimization Controls */
.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.controls-header h2 {
  margin: 0;
}

.controls-actions {
  display: flex;
  gap: 1rem;
}

.import-export {
  display: flex;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
}

/* Results Section */
.results-section.hidden {
  display: none;
}

/* Summary Statistics */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.stat-icon {
  width: 50px;
  height: 50px;
  background: #00788a;
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-content {
  flex: 1;
}

.stat-content label {
  display: block;
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: #00788a;
}

/* Cutting Plan */
.cutting-plan {
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
}

.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.plan-header h3 {
  margin: 0;
  color: #495057;
}

.plan-controls {
  display: flex;
  gap: 0.5rem;
}

.plan-container {
  padding: 1rem;
  background: white;
  overflow: auto;
  text-align: center;
}

#cutting-plan-container {
  border: 1px solid #e9ecef;
  border-radius: 4px;
  max-width: 100%;
  min-height: 600px;
  height: auto;
  overflow: auto;
  background: #f9f9f9;
}

/* HTML-based visualization styles */
.cutting-plan-viz {
  position: relative;
  background: white;
  border: 2px solid #2196f3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin: 20px;
}

.cutting-object {
  transition: transform 0.2s ease, z-index 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cutting-object:hover {
  transform: scale(1.02);
  z-index: 10;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.cutting-plan-legend {
  position: absolute;
  right: 20px;
  top: 20px;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 15px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 100;
}

/* Print styles for the visualization */
@media print {
  .cutting-plan-viz {
    transform: none !important;
    box-shadow: none;
    border: 2px solid #000;
  }
  
  .cutting-plan-legend {
    position: static;
    margin: 20px;
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .plan-controls {
    display: none;
  }
}

/* Mobile responsiveness for visualization */
@media (max-width: 768px) {
  #cutting-plan-container {
    min-height: 400px;
    height: auto;
  }
  
  .cutting-plan-legend {
    position: static;
    margin: 10px;
    max-width: none;
    font-size: 12px;
  }
  
  .cutting-plan-legend h4 {
    font-size: 14px;
  }
  
  .cutting-object {
    font-size: 10px;
  }
}

/* Footer */
.planner-footer {
  background: #343a40;
  color: white;
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #00788a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

 @keyframes spin {
   0% { transform: rotate(0deg); }
   100% { transform: rotate(360deg); }
 }

 /* Notifications */
 .notification {
   position: fixed;
   top: 20px;
   right: 20px;
   padding: 1rem 1.5rem;
   border-radius: 8px;
   color: white;
   font-weight: 500;
   z-index: 1001;
   animation: slideIn 0.3s ease-out;
   max-width: 400px;
   word-wrap: break-word;
 }

 .notification-success {
   background: #28a745;
 }

 .notification-error {
   background: #dc3545;
 }

 .notification-info {
   background: #00788a;
 }

 @keyframes slideIn {
   from {
     transform: translateX(100%);
     opacity: 0;
   }
   to {
     transform: translateX(0);
     opacity: 1;
   }
 }

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .header-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .title-section h1 {
    font-size: 1.5rem;
  }
  
  .specs-grid {
    grid-template-columns: 1fr;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .card-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .controls-header {
    flex-direction: column;
    gap: 1rem;
  }
  
  .controls-actions {
    justify-content: center;
  }
  
  .import-export {
    flex-direction: column;
  }
  
  .summary-stats {
    grid-template-columns: 1fr;
  }
  
  .plan-header {
    flex-direction: column;
    gap: 1rem;
  }
  
  .plan-controls {
    justify-content: center;
  }
  
  .objects-table {
    font-size: 0.9rem;
  }
  
  .objects-table th,
  .objects-table td {
    padding: 0.75rem 0.5rem;
  }
  
  .action-buttons {
    flex-direction: column;
    gap: 0.25rem;
  }
}

@media (max-width: 480px) {
  .specs-card,
  .management-card,
  .controls-card,
  .results-card {
    padding: 1rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
  
  .stat-item {
    flex-direction: column;
    text-align: center;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* Print Styles */
@media print {
  .planner-header,
  .optimization-controls,
  .loading-overlay {
    display: none !important;
  }
  
  .planner-main {
    padding: 0;
    background: white;
  }
  
  .specs-card,
  .management-card,
  .controls-card {
    box-shadow: none;
    border: 1px solid #000;
    margin-bottom: 1rem;
  }
  
  .results-card {
    box-shadow: none;
    border: 2px solid #000;
  }
  
  #cutting-canvas {
    border: 1px solid #000;
    max-width: 100%;
    height: auto;
  }
}

/* Waste Calculation Section */
.waste-calculation-section {
  margin: 2rem 0;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  display: none; /* Hidden by default, shown when results are available */
}

#toggle-waste-calculation {
  width: 100%;
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  border: none;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.2s;
  font-weight: 500;
  color: #495057;
}

#toggle-waste-calculation:hover {
  background: #e9ecef;
}

#toggle-waste-calculation .toggle-icon {
  transition: transform 0.2s;
}

#toggle-waste-calculation.expanded .toggle-icon {
  transform: rotate(180deg);
}

.waste-calculation-details {
  background: white;
  padding: 1.5rem;
}

.waste-calculation-details.hidden {
  display: none;
}

.calculation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.calculation-item {
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.calculation-item label {
  display: block;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.calculation-values {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calculation-values span {
  font-size: 0.9rem;
  color: #6c757d;
}

.calculation-values strong {
  color: #495057;
  font-weight: 600;
}

.calculation-formula {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.formula-line {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #495057;
  padding: 0.25rem 0;
}

.formula-line:first-child,
.formula-line:nth-child(3) {
  font-weight: 600;
  color: #00788a;
}

/* Responsive adjustments for waste calculation */
@media (max-width: 768px) {
  .calculation-grid {
    grid-template-columns: 1fr;
  }
  
  .calculation-item {
    padding: 0.75rem;
  }
  
  .formula-line {
    font-size: 0.8rem;
  }
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #2c5aa0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-footer .btn {
  min-width: 100px;
}
