/* ========================================
   MR Repuestos - Products Module Styles
   Identidad Visual Corporativa
   ======================================== */

/* CSS Variables */
:root {
  --crushed-berry: #880d1eff;
  --raspberry: #dd2d4aff;
  --bubblegum-pink: #f26a8dff;
  --pink-mist: #f49cbbff;
  --light-cyan: #cbeef3ff;
  --white: #ffffff;
  --light-gray: #f8f9fa;
  --border-color: #dee2e6;
  --medium-gray: #6c757d;
  --dark-gray: #212529;
}

/* Numeric Inputs Alignment */
input[type="number"].form-control-corporate {
  text-align: right !important;
}

/* Table Numeric Columns Alignment */
#productsTable th:nth-child(7), /* Precio */
#productsTable th:nth-child(8), /* Stock */
#productsTable td:nth-child(7),
#productsTable td:nth-child(8) {
  text-align: right !important;
}

/* Products Container */
.products-container {
  animation: fadeInUp 0.6s ease-out;
}

/* Products Header */
.products-header {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.2);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--white);
}

.header-title i {
  font-size: 2rem;
  color: var(--light-cyan);
}

.header-title h3 {
  margin: 0;
  font-weight: 600;
  font-size: 1.5rem;
}

/* Add Product Button */
.btn-add-product {
  background: var(--white);
  color: var(--raspberry);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-add-product:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: var(--light-cyan);
}

.btn-add-product i {
  font-size: 1.1rem;
}

/* Table Container */
.products-table-container {
  background: var(--white);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Corporate Table */
.table-corporate {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}

/* DataTable Header Styles - High Specificity */
#productsTable thead,
.table-corporate thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
  position: relative;
}

#productsTable thead tr,
.table-corporate thead tr {
  background: transparent !important;
}

#productsTable thead th,
.table-corporate thead th {
  padding: 1rem !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  background: transparent !important;
  border: none !important;
  text-align: left;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Ubuntu', sans-serif;
}

/* DataTable sorting icons color */
#productsTable thead th.sorting::before,
#productsTable thead th.sorting::after,
#productsTable thead th.sorting_asc::before,
#productsTable thead th.sorting_asc::after,
#productsTable thead th.sorting_desc::before,
#productsTable thead th.sorting_desc::after {
  color: rgba(255, 255, 255, 0.7) !important;
  opacity: 0.7;
}

.table-corporate tbody tr {
  transition: all 0.3s ease;
  border-bottom: 1px solid var(--border-color);
}

.table-corporate tbody tr:hover {
  background: linear-gradient(90deg, rgba(136, 13, 30, 0.03), rgba(221, 45, 74, 0.03));
  transform: scale(1.01);
}

.table-corporate tbody td {
  padding: 1rem;
  vertical-align: middle;
  color: var(--dark-gray);
}

/* Product Image Thumbnail */
.product-image-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-gray);
  border: 2px solid var(--border-color);
}

.product-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-thumb i {
  font-size: 1.5rem;
  color: var(--medium-gray);
}

/* Product Code */
.product-code {
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, rgba(136, 13, 30, 0.1), rgba(221, 45, 74, 0.1));
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  color: var(--raspberry);
  font-size: 0.9rem;
}

/* Price Cell */
.price-cell {
  font-weight: 600;
  color: var(--crushed-berry);
  font-size: 1.05rem;
}

/* Stock Badge */
.badge-stock {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.875rem;
}

.badge-stock.stock-ok {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: var(--white);
}

.badge-stock.stock-low {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  color: var(--dark-gray);
}

.badge-stock.stock-empty {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: var(--white);
}

/* Status Badge */
.badge-status {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.85rem;
}

.badge-status.status-active {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.2), rgba(32, 201, 151, 0.2));
  color: #155724;
  border: 1px solid rgba(40, 167, 69, 0.3);
}

.badge-status.status-inactive {
  background: linear-gradient(135deg, rgba(108, 117, 125, 0.2), rgba(73, 80, 87, 0.2));
  color: #383d41;
  border: 1px solid rgba(108, 117, 125, 0.3);
}

/* Table Actions */
.table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-action-edit,
.btn-action-delete {
  width: 36px;
  height: 36px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  padding: 0;
}

.btn-action-edit {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.1), rgba(0, 86, 179, 0.1));
  color: #007bff;
  border: 1px solid rgba(0, 123, 255, 0.2);
  border-radius: 8px 0 0 8px;
}

.btn-action-edit:hover {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
  z-index: 1;
}

.btn-action-delete {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(200, 35, 51, 0.1));
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.2);
  border-radius: 0 8px 8px 0;
}

.btn-action-delete:hover {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
  z-index: 1;
}

/* Bootstrap button group adjustments */
.btn-group-sm > .btn {
  border-radius: 0;
}

.btn-group-sm > .btn:first-child {
  border-radius: 8px 0 0 8px;
}

.btn-group-sm > .btn:last-child {
  border-radius: 0 8px 8px 0;
}

/* Modal Corporate */
.modal-corporate .modal-header {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  color: var(--white);
  border-radius: 12px 12px 0 0;
  padding: 1.5rem 2rem;
  border: none;
}

.modal-corporate .modal-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1.25rem;
}

.modal-corporate .modal-title i {
  color: var(--light-cyan);
  font-size: 1.5rem;
}

.modal-corporate .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.modal-corporate .btn-close:hover {
  opacity: 1;
}

.modal-corporate .modal-body {
  padding: 2rem;
}

.modal-corporate .modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color);
  background: var(--light-gray);
}

/* Section Title */
.section-title {
  color: var(--raspberry);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(221, 45, 74, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Form Labels */
.form-label-corporate {
  color: var(--dark-gray);
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
  font-size: 0.9rem;
}

.form-label-corporate.required::after {
  content: ' *';
  color: var(--raspberry);
  font-weight: 600;
}

/* Input Groups */
.input-group-corporate {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  position: relative;
}

.input-group-corporate:focus-within {
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
}

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  background: var(--light-gray);
  color: var(--raspberry);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  min-width: 45px;
}

.input-icon i {
  font-size: 1rem;
}

.form-control-corporate {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  outline: none;
  font-family: 'Ubuntu', sans-serif;
  font-size: 0.95rem;
  color: var(--dark-gray);
  background: var(--white);
  width: 100%;
  min-height: 42px;
}

.form-control-corporate::placeholder {
  color: var(--medium-gray);
  opacity: 0.6;
}

.form-control-corporate:focus {
  outline: none;
}

textarea.form-control-corporate {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

select.form-control-corporate {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23880d1e' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px;
  padding-right: 2.5rem;
}

select.form-control-corporate::-ms-expand {
  display: none;
}

/* Input Number - Remove Spinners */
input[type="number"].form-control-corporate::-webkit-outer-spin-button,
input[type="number"].form-control-corporate::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"].form-control-corporate {
  -moz-appearance: textfield;
}

/* Validation Feedback */
.invalid-feedback {
  color: #dc3545;
  font-size: 0.85rem;
  margin-top: 0.25rem;
  display: none;
}

.was-validated .form-control-corporate:invalid ~ .invalid-feedback {
  display: block;
}

/* Image Upload Section */
.image-upload-section {
  height: 100%;
}

.image-upload-container {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  background: var(--light-gray);
  transition: all 0.3s ease;
}

.image-upload-container:hover {
  border-color: var(--raspberry);
  background: rgba(221, 45, 74, 0.03);
}

.image-preview {
  width: 100%;
  aspect-ratio: 1;
  max-width: 300px;
  margin: 0 auto 1rem;
  border-radius: 12px;
  overflow: hidden;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
}

.image-preview i {
  font-size: 4rem;
  color: var(--medium-gray);
  margin-bottom: 0.5rem;
}

.image-preview p {
  color: var(--medium-gray);
  margin: 0;
  font-size: 0.9rem;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Image Actions */
.image-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.btn-image-action {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.btn-image-action.btn-select {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  color: var(--white);
}

.btn-image-action.btn-select:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
}

.btn-image-action.btn-remove {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(200, 35, 51, 0.1));
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.btn-image-action.btn-remove:hover {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: var(--white);
  border-color: transparent;
}

.image-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--medium-gray);
  font-size: 0.85rem;
}

.image-hint i {
  color: var(--raspberry);
}

/* Modal Buttons */
.btn-modal-primary {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  color: var(--white);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.btn-modal-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
}

.btn-modal-secondary {
  background: var(--white);
  color: var(--dark-gray);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.btn-modal-secondary:hover {
  background: var(--light-gray);
  border-color: var(--medium-gray);
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  color: var(--dark-gray);
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-left: 0.5rem;
  color: var(--dark-gray);
}

.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  margin: 0 2px;
  border: 1px solid var(--border-color) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  color: var(--white) !important;
  border-color: transparent !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--light-gray) !important;
  color: var(--raspberry) !important;
  border-color: var(--raspberry) !important;
}

/* DataTables Info and Empty State */
.dataTables_wrapper .dataTables_info {
  color: var(--medium-gray);
  font-size: 0.875rem;
  padding-top: 1rem;
}

.dataTables_wrapper .dataTables_empty {
  color: var(--medium-gray);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

/* Force thead solid color - Override DataTables defaults */
#productsTable_wrapper table.table-corporate thead,
#productsTable_wrapper #productsTable thead,
table.dataTable.table-corporate thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
}

#productsTable_wrapper table.table-corporate thead th,
#productsTable_wrapper #productsTable thead th,
table.dataTable.table-corporate thead th {
  color: #ffffff !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* Override any Bootstrap or DataTables default thead styles */
table.dataTable thead > tr > th,
table.dataTable thead > tr > td {
  color: #ffffff !important;
  background: transparent !important;
}

/* Responsive */
@media (max-width: 1200px) {
  .products-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-corporate {
    min-width: 800px;
  }
}

@media (max-width: 991px) {
  .products-header {
    padding: 1.25rem 1.5rem;
  }
  
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header-title h3 {
    font-size: 1.25rem;
  }
  
  .header-title i {
    font-size: 1.5rem;
  }
  
  .btn-add-product {
    width: 100%;
    justify-content: center;
  }
  
  .modal-corporate .modal-body {
    padding: 1.5rem;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    width: 100% !important;
  }
}

@media (max-width: 767px) {
  .products-header {
    padding: 1rem;
  }
  
  .header-title h3 {
    font-size: 1.1rem;
  }
  
  .products-table-container {
    padding: 1rem;
  }
  
  .table-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
    padding: 0.5rem;
    font-size: 0.875rem;
  }
  
  .image-upload-container {
    padding: 1rem;
  }
  
  .image-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-image-action {
    width: 100%;
    justify-content: center;
  }
  
  .modal-header h5 {
    font-size: 1rem;
  }
  
  .product-image-preview {
    max-height: 200px;
  }
}

@media (max-width: 576px) {
  .header-title i {
    font-size: 1.25rem;
  }
  
  .header-title h3 {
    font-size: 1rem;
  }
  
  .btn-add-product {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .table-corporate {
    font-size: 0.75rem;
  }
  
  .table-corporate th,
  .table-corporate td {
    padding: 0.5rem 0.25rem;
  }
  
  .badge {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .form-label {
    font-size: 0.875rem;
  }
  
  .form-control,
  .form-select {
    font-size: 0.875rem;
    padding: 0.5rem;
}
