/* ========================================
   MR Repuestos - Sales Module Styles
   Identidad Visual Corporativa
   Last Updated: 2025-12-07 - v1.0
   ======================================== */

/* 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-sm,
input[type="number"].form-control-corporate {
  text-align: right !important;
}

/* Table Numeric Columns Alignment */
.table-items th:nth-child(3), /* Cantidad */
.table-items th:nth-child(4), /* Precio Unit. */
.table-items th:nth-child(5), /* Subtotal */
.table-items td:nth-child(3),
.table-items td:nth-child(4),
.table-items td:nth-child(5) {
  text-align: right !important;
}

#salesTable th:nth-child(6), /* Items */
#salesTable th:nth-child(7), /* Total */
#salesTable td:nth-child(6),
#salesTable td:nth-child(7) {
  text-align: right !important;
}

/* Sales Container */
.sales-container {
  animation: fadeInUp 0.6s ease-out;
}

/* Sales Header */
.sales-header {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  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;
}

.header-title h3 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'Ubuntu', sans-serif;
}

/* Add Sale Button */
.btn-add-sale {
  background: linear-gradient(135deg, var(--white), var(--light-gray));
  color: var(--raspberry);
  border: 2px solid var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
}

.btn-add-sale:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.4);
  background: var(--white);
}

/* Filtros de Ventas */
.sales-filters {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.filters-row {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

.filter-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--dark-gray);
  font-weight: 600;
  font-size: 0.875rem;
  font-family: 'Ubuntu', sans-serif;
}

.filter-input,
.filter-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9375rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
}

/* Filter Buttons */
.filter-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-filter-apply {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry));
  color: var(--white);
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
}

.btn-filter-apply:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
}

.btn-filter-clear {
  background: var(--white);
  color: var(--medium-gray);
  border: 1.5px solid var(--border-color);
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
}

.btn-filter-clear:hover {
  background: var(--light-gray);
  border-color: var(--medium-gray);
}

/* Sales Table Container */
.sales-table-container {
  background: var(--white);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Table Styles */
.table-sales {
  width: 100%;
  margin-bottom: 0;
  font-family: 'Ubuntu', sans-serif;
}

.table-sales thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
}

.table-sales thead th {
  color: var(--white) !important;
  font-weight: 600 !important;
  padding: 1rem !important;
  border: none !important;
  background: transparent !important;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  font-family: 'Ubuntu', sans-serif;
}

.table-sales tbody tr {
  transition: all 0.3s ease;
  border-bottom: 1px solid var(--border-color);
  border-top: none !important;
}

.table-sales tbody tr:first-child {
  border-top: none !important;
}

.table-sales tbody tr:hover {
  background: linear-gradient(90deg, #fff, #fcf0f3);
  transform: translateX(2px);
}

.table-sales tbody td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
  color: var(--dark-gray);
  font-size: 0.9375rem;
}

/* Badge Styles */
.badge-invoice-number {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry));
  color: var(--white);
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8125rem;
  display: inline-block;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  box-shadow: 0 2px 6px rgba(136, 13, 30, 0.25);
}

.badge-status {
  padding: 0.375rem 0.875rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.8125rem;
  display: inline-block;
  font-family: 'Ubuntu', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status.status-completed {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.badge-status.status-pending {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  color: var(--dark-gray);
  box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3);
}

.badge-status.status-cancelled {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

/* Action Buttons */
.table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-action {
  border: none;
  padding: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

.btn-action-view {
  background: linear-gradient(135deg, #17a2b8, #138496);
  color: var(--white);
}

.btn-action-view:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-action-edit {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  color: var(--dark-gray);
}

.btn-action-edit:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.btn-action-delete {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: var(--white);
}

.btn-action-delete:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

/* Modal Corporate Styles */
.modal-corporate .modal-content {
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 40px rgba(136, 13, 30, 0.25);
}

.modal-corporate .modal-header {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry));
  color: var(--white);
  border-radius: 12px 12px 0 0;
  padding: 1.25rem 1.5rem;
  border-bottom: none;
}

.modal-corporate .modal-title {
  font-weight: 700;
  font-size: 1.375rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Ubuntu', sans-serif;
}

.modal-corporate .btn-close {
  filter: brightness(0) invert(1);
  opacity: 1;
}

.modal-corporate .modal-body {
  padding: 1.5rem;
}

.modal-corporate .modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  background: var(--light-gray);
  border-radius: 0 0 12px 12px;
}

/* Form Sections */
.form-section {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--light-gray);
  border-radius: 8px;
  border-left: 4px solid var(--raspberry);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--raspberry);
}

.section-header i {
  font-size: 1.25rem;
}

.section-header h6 {
  margin: 0;
  font-weight: 700;
  font-size: 1.125rem;
  font-family: 'Ubuntu', sans-serif;
}

/* Form Labels */
.form-label {
  color: var(--dark-gray);
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  display: block;
  font-family: 'Ubuntu', sans-serif;
}

.form-label-required::after {
  content: ' *';
  color: var(--raspberry);
}

/* Input Group Corporate */
.input-group-corporate {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-group-corporate .input-icon {
  position: absolute;
  left: 0.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--raspberry);
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
}

.input-group-corporate .form-control-corporate,
.input-group-corporate .form-select-corporate {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.25rem;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9375rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  background-color: var(--white);
  position: relative;
  z-index: 1;
}

.form-control-corporate,
.form-select-corporate {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9375rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background-color: var(--white);
}

.form-select-corporate option {
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background-color: var(--white);
  padding: 0.5rem;
}

.form-control-corporate:focus,
.form-select-corporate:focus,
.input-group-corporate .form-control-corporate:focus,
.input-group-corporate .form-select-corporate:focus {
  outline: none;
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
}

/* Add Item Section */
.add-item-section {
  background: var(--white);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1.5px dashed var(--border-color);
}

.add-item-section .row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.add-item-section .col-md-4,
.add-item-section .col-md-2 {
  display: flex;
  flex-direction: column;
}

.add-item-section .form-label-sm {
  margin-bottom: 0.375rem;
  min-height: 1.2rem;
  display: block;
}

.add-item-section .form-control-sm {
  height: 38px;
  display: flex;
  align-items: center;
}

.form-label-sm {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--dark-gray);
  font-weight: 600;
  font-size: 0.8125rem;
  font-family: 'Ubuntu', sans-serif;
}

.form-select-sm,
.form-control-sm {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background-color: var(--white);
}

.form-select-sm option,
.form-select-corporate option {
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background-color: var(--white);
}

.form-select-sm:focus,
.form-control-sm:focus {
  outline: none;
  border-color: var(--raspberry);
  box-shadow: 0 0 0 2px rgba(221, 45, 74, 0.1);
}

.btn-add-item {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry));
  color: var(--white);
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  width: 100%;
  height: 38px;
  justify-content: center;
}

.btn-add-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
}

/* Items Table Container */
.items-table-container {
  background: var(--white);
  padding: 1rem;
  max-height: 400px;
  overflow-y: auto;
  border: 1.5px solid var(--border-color);
}

.table-items {
  width: 100%;
  margin-bottom: 0;
  font-family: 'Ubuntu', sans-serif;
}

.table-items thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-items thead th {
  color: var(--white);
  font-weight: 600;
  padding: 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  background: transparent !important;
}

.table-items tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.table-items tbody tr:hover {
  background: var(--light-gray);
}

.table-items tbody td {
  padding: 0.75rem;
  vertical-align: middle;
  color: var(--dark-gray);
  font-size: 0.875rem;
}

.table-items .no-items {
  text-align: center;
  padding: 2rem !important;
}

.table-items .no-items div {
  color: var(--medium-gray);
  font-style: italic;
}

.table-items .no-items i {
  font-size: 2.5rem;
  color: var(--border-color);
  margin-bottom: 0.5rem;
  display: block;
}

/* Totals Section */
.totals-section {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  padding: 1.25rem;
  border-radius: 8px;
  margin-top: 1rem;
  border: 2px solid var(--raspberry);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  font-family: 'Ubuntu', sans-serif;
}

.totals-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dark-gray);
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0;
}

.totals-row label i {
  color: var(--raspberry);
}

.totals-row .total-value {
  color: var(--crushed-berry);
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
}

.totals-row.total-final {
  border-top: 2px solid var(--raspberry);
  margin-top: 0.5rem;
  padding-top: 1rem;
}

.totals-row.total-final label {
  font-size: 1.125rem;
  color: var(--crushed-berry);
}

.totals-row.total-final .total-value {
  font-size: 1.5rem;
  color: var(--crushed-berry);
}

/* Corporate Buttons */
.btn-corporate-primary {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry));
  color: var(--white);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
}

.btn-corporate-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(136, 13, 30, 0.35);
  color: var(--white);
}

.btn-corporate-secondary {
  background: var(--white);
  color: var(--medium-gray);
  border: 1.5px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
}

.btn-corporate-secondary:hover {
  background: var(--light-gray);
  border-color: var(--medium-gray);
  transform: translateY(-1px);
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-family: 'Ubuntu', sans-serif;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--raspberry);
  box-shadow: 0 0 0 2px rgba(221, 45, 74, 0.1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: linear-gradient(135deg, var(--crushed-berry), var(--raspberry)) !important;
  color: var(--white) !important;
  border: none !important;
  border-radius: 6px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--light-gray) !important;
  color: var(--dark-gray) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 6px !important;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 1200px) {
  .sales-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-sales {
    min-width: 1000px;
  }
  
  .cart-table-container {
    overflow-x: auto;
  }
  
  .cart-table {
    min-width: 600px;
  }
}

@media (max-width: 991px) {
  .sales-header {
    padding: 1.25rem 1.5rem;
  }
  
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-add-sale {
    width: 100%;
    justify-content: center;
    margin-top: 1rem;
  }
  
  .filters-row {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .filter-actions {
    width: 100%;
    flex-direction: column;
  }

  .btn-filter-apply,
  .btn-filter-clear {
    width: 100%;
    justify-content: center;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    width: 100% !important;
  }
  
  .modal-xl {
    max-width: calc(100% - 1rem);
  }
}

@media (max-width: 768px) {
  .sales-header {
    padding: 1rem;
  }

  .header-title h3 {
    font-size: 1.25rem;
  }
  
  .header-title i {
    font-size: 1.5rem;
  }

  .sales-filters {
    padding: 1rem;
  }

  .table-sales {
    font-size: 0.8125rem;
  }

  .table-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .product-search-container {
    padding: 1rem;
  }
  
  .cart-summary {
    padding: 1rem;
  }

  .add-item-section .row {
    flex-direction: column;
  }

  .add-item-section .col-md-4,
  .add-item-section .col-md-2 {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 576px) {
  .sales-header {
    padding: 0.75rem;
  }
  
  .header-title h3 {
    font-size: 1.1rem;
  }
  
  .header-title i {
    font-size: 1.25rem;
  }
  
  .btn-add-sale {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .table-sales,
  .cart-table {
    font-size: 0.75rem;
  }
  
  .table-sales th,
  .table-sales td,
  .cart-table th,
  .cart-table td {
    padding: 0.5rem 0.25rem;
  }
  
  .sales-filters {
    padding: 0.75rem;
  }
  
  .modal-header h5 {
    font-size: 1rem;
  }
  
  .form-label {
    font-size: 0.875rem;
  }
  
  .form-control,
  .form-select {
    font-size: 0.875rem;
    padding: 0.5rem;
  }
  
  .cart-summary h5 {
    font-size: 1rem;
  }
  
  .cart-summary .summary-row {
    font-size: 0.875rem;
  }
  
  .badge {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
}
