/* ../styles/products.css */

/* General Page Enhancements (can be shared or from dashboard.css) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 1.8em;
}

/* Card and Table Styling (can be shared or from dashboard.css) */
.card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e9ecef;
}

.card-header h2 {
  margin: 0;
  font-size: 1.2em;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 10px;
}

.form-select {
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background-color: #fff;
  font-size: 0.9em;
}

.card-body {
  padding: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

.data-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  font-size: 0.9em;
  text-transform: uppercase;
  color: #495057;
}

.data-table tbody tr:hover {
  background-color: #f1f3f5;
}

/* Product Specific Table Cell */
.product-info-cell {
  display: flex;
  align-items: center;
  gap: 15px;
}

.product-image {
  width: 50px;
  height: 50px;
  background-color: #e9ecef; /* Placeholder background */
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em; /* For icon placeholder */
  color: #6c757d;
  overflow: hidden; /* For actual images */
}
.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-details {
  display: flex;
  flex-direction: column;
}

.product-name {
  font-weight: 500;
  color: #212529;
  margin-bottom: 3px;
}

.product-sku {
  font-size: 0.85em;
  color: #6c757d;
}

/* Status Badges (can be shared or from dashboard.css) */
.status-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.in-stock {
  background-color: #d1e7dd; /* Light green */
  color: #0f5132; /* Dark green */
}

.status-badge.low-stock {
  background-color: #fff3cd; /* Light yellow */
  color: #664d03; /* Dark yellow */
}

.status-badge.out-of-stock {
  background-color: #f8d7da; /* Light red */
  color: #842029; /* Dark red */
}
/* Add other statuses if needed (e.g., 'archived', 'discontinued') */

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 5px;
  font-size: 1.1em;
  transition: color 0.2s ease;
}

.btn-icon:hover {
  color: #007bff;
}
.btn-icon.delete:hover {
  color: #dc3545;
}

/* Pagination (can be shared or from dashboard.css) */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  gap: 5px;
}

.pagination-btn {
  background-color: #fff;
  border: 1px solid #dee2e6;
  color: #007bff;
  padding: 8px 12px;
  text-decoration: none;
  transition: background-color 0.3s;
  border-radius: 4px;
  cursor: pointer;
}

.pagination-btn:hover:not([disabled]) {
  background-color: #e9ecef;
}

.pagination-btn.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.pagination-btn:disabled {
  color: #6c757d;
  cursor: not-allowed;
  background-color: #f8f9fa;
}

/* Modal Styling (can be shared or from dashboard.css) */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  padding-top: 50px;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 0;
  border: 1px solid #888;
  width: 80%;
  max-width: 700px; /* Slightly wider for product forms */
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 15px 20px;
  background-color: #007bff;
  color: white;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3em;
}

.close-modal {
  color: white;
  float: right;
  font-size: 28px;
  font-weight: bold;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.close-modal:hover,
.close-modal:focus {
  color: #f1f1f1;
  text-decoration: none;
}

.modal-body {
  padding: 20px;
  max-height: 75vh; /* Allow scrolling for long forms */
  overflow-y: auto;
}

/* Form Styling within Modals (can be shared or from dashboard.css) */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 0.9em;
}

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 0.95em;
}
.form-control:focus {
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-row {
  display: flex;
  gap: 15px;
}
.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

/* File Upload Styling */
.file-upload-container {
  position: relative;
  border: 1px dashed #ced4da;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.file-upload-container:hover {
  border-color: #007bff;
}
.file-upload-input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}
.file-upload-label {
  display: block;
  margin-bottom: 5px;
  color: #007bff;
  font-weight: 500;
}
.file-upload-label i {
  margin-right: 8px;
}
.file-name {
  display: block;
  font-size: 0.85em;
  color: #6c757d;
  margin-top: 5px;
}
.image-preview {
  width: 100px;
  height: 100px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 10px;
  object-fit: cover;
  display: none; /* Hidden by default */
}

/* View Product Modal Specifics */
.product-view-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e9ecef;
}

.product-view-image {
  width: 100px;
  height: 100px;
  background-color: #e9ecef;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3em;
  color: #6c757d;
  overflow: hidden; /* For actual images */
}
.product-view-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-view-info h3 {
  margin: 0 0 5px 0;
  font-size: 1.4em;
}
.product-view-info p {
  /* For SKU */
  margin: 0 0 8px 0;
  color: #6c757d;
  font-size: 0.9em;
}
.product-view-info .status-badge {
  font-size: 0.9em;
}

.product-view-details .detail-item {
  margin-bottom: 12px;
  font-size: 0.95em;
}
.product-view-details .detail-label {
  font-weight: 600;
  color: #495057;
  width: 100px; /* Adjust as needed */
  display: inline-block; /* Or flex for alignment */
  margin-right: 10px;
}
.product-view-details #view-product-description {
  line-height: 1.6;
  color: #495057;
  margin-top: 5px; /* If label is above */
}

/* Buttons (General, assuming from dashboard.css but can be customized here) */
.btn {
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}
.btn-primary:hover {
  background-color: #0056b3;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}
.btn-secondary:hover {
  background-color: #545b62;
}

.btn-danger {
  background-color: #dc3545;
  color: white;
}
.btn-danger:hover {
  background-color: #b02a37;
}

/* --- NEW STYLES for Add/Edit Product Form --- */

/* Add a divider line in the form */
.form-divider {
  margin: 25px 0;
  border: 0;
  border-top: 1px solid #e9ecef;
}

/* Style the header for the details section */
.form-section-header {
  margin-bottom: 15px;
}
.form-section-header h4 {
  margin: 0 0 5px 0;
  font-size: 1.1em;
  font-weight: 600;
}
.form-section-header p {
  margin: 0;
  font-size: 0.9em;
  color: #6c757d;
}

/* Styling for the dynamic detail row container */
#product-details-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

/* A single dynamic row of details */
.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Make the inputs in the row fill the available space */
.detail-row .form-control {
  flex: 1;
}

/* Style the remove button for a detail row */
.remove-detail-row {
  flex-shrink: 0; /* Prevent the button from shrinking */
  padding: 8px;
  height: 38px; /* Match form control height */
  width: 38px;
}
.remove-detail-row:hover {
  color: #dc3545; /* Red hover for delete action */
  background-color: #f8d7da; /* Light red background on hover */
}

/* Style the "Add Detail" button */
#add-detail-row-btn {
  /* Use a secondary, less prominent style */
  background-color: #f8f9fa;
  color: #495057;
  border: 1px solid #ced4da;
  font-weight: 500;
  width: auto; /* Don't make it full width */
}
#add-detail-row-btn:hover {
  background-color: #e9ecef;
}

#sub-category-container {
  transition: opacity 0.3s ease-in-out;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.details-grid .detail-item {
  display: flex;
  flex-direction: column;
  padding-bottom: 5px;
  border-bottom: 1px solid #e9ecef;
}

.details-grid .detail-label {
  font-weight: 600;
  font-size: 0.85em;
  color: #495057;
  margin-bottom: 3px;
}

.details-grid span:not(.detail-label) {
  color: #212529;
}

.details-section-container {
  background-color: #f8f9fa; /* Light grey background */
  padding: 15px;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  margin-top: 10px;
}

/* Make the dynamic container inside have no extra margin */
#edit-details-container,
#product-details-container {
  margin-bottom: 0;
}

/* Style for the "Add Detail" button inside the new container */
#edit-add-detail-btn,
#add-detail-row-btn {
  margin-top: 15px; /* Add space above the button */
  border: 1px solid #ced4da;
  background-color: #fff;
  color: #495057;
}

#edit-add-detail-btn:hover,
#add-detail-row-btn:hover {
  background-color: #e9ecef;
}

/* A smaller button variant for less important actions */
.btn.btn-small {
  padding: 5px 10px;
  font-size: 0.85em;
}

/* Better vertical alignment in form rows */
.form-row .form-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.btn.btn-info {
  background-color: #17a2b8;
  color: white;
}
.btn.btn-info:hover {
  background-color: #117a8b;
}

/* A larger variant for the modal content for tables */
.modal-content.large {
  max-width: 800px;
}

/* Header for the product name in the history modal */
#price-history-product-name {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.2em;
  font-weight: 600;
  color: #343a40;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 10px;
}

/* Container to allow for scrolling if the table is too long */
.table-container {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

/* Make table headers sticky inside the scrolling container */
#price-history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: #f8f9fa; /* Match your existing header style */
}

/* Center-align some of the table columns for better readability */
#price-history-table td:nth-child(3),
#price-history-table th:nth-child(3),
#price-history-table td:nth-child(4),
#price-history-table th:nth-child(4) {
  text-align: center;
}

#price-history-table td:nth-child(3) {
  font-family: "Courier New", Courier, monospace;
  font-weight: 600;
}

.btn-icon.history:hover {
  color: #17a2b8; /* A nice info/teal color for the history icon */
}
