/* ========================================
   MR Repuestos - Purchases Module Styles
   Identidad Visual Corporativa
   Last Updated: 2025-12-07 - v3.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;
}

#purchasesTable th:nth-child(6), /* Items */
#purchasesTable th:nth-child(7), /* Total */
#purchasesTable td:nth-child(6),
#purchasesTable td:nth-child(7) {
  text-align: right !important;
}

/* Purchases Container */
.purchases-container {
  animation: fadeInUp 0.6s ease-out;
}

/* Purchases Header */
.purchases-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 Purchase Button */
.btn-add-purchase {
  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-purchase:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.4);
  background: var(--white);
}

/* Filtros de Compras */
.purchases-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: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.5rem;
  font-family: 'Ubuntu', sans-serif;
  font-size: 0.9rem;
}

.filter-label i {
  color: var(--raspberry);
}

.form-control-filter,
.form-select-filter {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background: var(--white);
  width: 100%;
}

.form-control-filter:focus,
.form-select-filter:focus {
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
  outline: none;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-filter-apply,
.btn-filter-clear {
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-family: 'Ubuntu', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-filter-apply {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  color: var(--white);
}

.btn-filter-apply:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
}

.btn-filter-clear {
  background: var(--white);
  color: var(--medium-gray);
  border: 2px solid var(--border-color);
}

.btn-filter-clear:hover {
  background: var(--light-gray);
  border-color: var(--medium-gray);
}

/* Purchases Table Container */
.purchases-table-container {
  background: var(--white);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* DataTable Header Styles */
#purchasesTable thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
}

#purchasesTable 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;
}

#purchasesTable thead th.sorting::before,
#purchasesTable thead th.sorting::after,
#purchasesTable thead th.sorting_asc::before,
#purchasesTable thead th.sorting_asc::after,
#purchasesTable thead th.sorting_desc::before,
#purchasesTable thead th.sorting_desc::after {
  color: rgba(255, 255, 255, 0.7) !important;
}

.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);
}

/* Purchase Number Badge */
.badge-purchase-number {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, rgba(136, 13, 30, 0.1), rgba(221, 45, 74, 0.1));
  color: var(--raspberry);
  border: 1px solid rgba(221, 45, 74, 0.2);
}

/* Status Badges */
.badge-status {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.85rem;
}

.badge-status.status-received {
  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-pending {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.2));
  color: #856404;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.badge-status.status-cancelled {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.2), rgba(200, 35, 51, 0.2));
  color: #721c24;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

/* Table Actions */
.table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-action-view,
.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-view {
  background: linear-gradient(135deg, rgba(23, 162, 184, 0.1), rgba(19, 132, 150, 0.1));
  color: #17a2b8;
  border: 1px solid rgba(23, 162, 184, 0.2);
  border-radius: 8px 0 0 8px;
}

.btn-action-view:hover {
  background: linear-gradient(135deg, #17a2b8, #138496);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(23, 162, 184, 0.3);
  z-index: 1;
}

.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: 0;
}

.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;
}

/* 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-family: 'Ubuntu', sans-serif;
  font-size: 1.25rem;
}

.modal-corporate .modal-title i {
  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;
  background: var(--light-gray);
  max-height: 70vh;
  overflow-y: auto;
}

.modal-corporate .modal-footer {
  background: var(--white);
  border-top: 2px solid var(--border-color);
  padding: 1.25rem 2rem;
}

/* Form Section */
.form-section {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
}

.section-header i {
  font-size: 1.25rem;
  color: var(--raspberry);
}

.section-header h6 {
  margin: 0;
  font-weight: 600;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  font-size: 1.1rem;
}

/* Form Controls */
.form-label {
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.5rem;
  font-family: 'Ubuntu', sans-serif;
  font-size: 0.9rem;
}

.form-label-required::after {
  content: ' *';
  color: var(--raspberry);
}

.form-label-sm {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.375rem;
  font-family: 'Ubuntu', sans-serif;
}

/* Input Group Corporate */
.input-group-corporate {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-group-corporate .input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(136, 13, 30, 0.05), rgba(221, 45, 74, 0.05));
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 0 1rem;
  color: var(--raspberry);
  min-width: 45px;
  flex-shrink: 0;
}

.input-group-corporate .form-control-corporate,
.input-group-corporate .form-select-corporate {
  border-radius: 0 8px 8px 0;
  border-left: none;
}

/* Form Control Corporate */
.form-control-corporate,
.form-select-corporate {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background: var(--white);
  min-height: 42px;
  width: 100%;
}

.form-control-corporate:focus,
.form-select-corporate:focus {
  border-color: var(--raspberry);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.1);
  outline: none;
}

textarea.form-control-corporate {
  resize: vertical;
  min-height: 80px;
}

/* Form Controls Small */
.form-control-sm,
.form-select-sm {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  font-family: 'Ubuntu', sans-serif;
  color: var(--dark-gray);
  background: var(--white);
  width: 100%;
}

.form-control-sm:focus,
.form-select-sm:focus {
  border-color: var(--raspberry);
  box-shadow: 0 0 0 2px rgba(221, 45, 74, 0.1);
  outline: none;
}

/* Add Item Section */
.add-item-section {
  background: linear-gradient(135deg, rgba(136, 13, 30, 0.03), rgba(221, 45, 74, 0.03));
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.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;
}

.btn-add-item {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.15), rgba(32, 201, 151, 0.15));
  color: #155724;
  border: 2px solid rgba(40, 167, 69, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-family: 'Ubuntu', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-add-item:hover {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* Items Table */
.items-table-container {
  background: var(--white);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.table-items {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
}

.table-items thead {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff) !important;
  border-bottom: none !important;
}

.table-items thead th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #ffffff;
  text-align: left;
  font-size: 0.85rem;
  text-transform: uppercase;
  font-family: 'Ubuntu', sans-serif;
  border: none;
  background: transparent !important;
}

.table-items tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--dark-gray);
  font-size: 0.9rem;
}

.table-items tbody tr:last-child td {
  border-bottom: none;
}

.table-items tbody tr.no-items td {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--medium-gray);
  font-style: italic;
}

.table-items tbody tr.no-items i {
  font-size: 2rem;
  opacity: 0.5;
  margin-bottom: 0.5rem;
}

/* Totals Section */
.totals-section {
  background: linear-gradient(135deg, rgba(136, 13, 30, 0.05), rgba(221, 45, 74, 0.05));
  border-radius: 8px;
  padding: 1.5rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-family: 'Ubuntu', sans-serif;
}

.totals-row label {
  font-weight: 500;
  color: var(--dark-gray);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.totals-row .total-value {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--raspberry);
}

.totals-row.total-final {
  border-top: 2px solid var(--raspberry);
  margin-top: 0.5rem;
  padding-top: 1rem;
}

.totals-row.total-final label,
.totals-row.total-final .total-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--crushed-berry);
}

.tax-input {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  width: 100px;
  text-align: right;
  font-size: 0.9rem;
}

/* Buttons Corporate */
.btn-corporate-primary {
  background: linear-gradient(135deg, #880d1eff, #dd2d4aff);
  color: var(--white);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-family: 'Ubuntu', sans-serif;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.btn-corporate-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(136, 13, 30, 0.3);
  color: var(--white);
}

.btn-corporate-secondary {
  background: var(--white);
  color: var(--medium-gray);
  border: 2px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-family: 'Ubuntu', sans-serif;
  transition: all 0.3s ease;
  cursor: pointer;
}

.btn-corporate-secondary:hover {
  background: var(--light-gray);
  border-color: var(--medium-gray);
  color: var(--dark-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;
}

/* Responsive */
@media (max-width: 1200px) {
  .purchases-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-purchases {
    min-width: 1000px;
  }
  
  .cart-table-container {
    overflow-x: auto;
  }
  
  .cart-table {
    min-width: 600px;
  }
}

@media (max-width: 991px) {
  .purchases-header {
    padding: 1.25rem 1.5rem;
  }
  
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-add-purchase {
    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) {
  .purchases-header {
    padding: 1rem;
  }
  
  .header-title h3 {
    font-size: 1.25rem;
  }
  
  .header-title i {
    font-size: 1.5rem;
  }

  .purchases-table-container {
    padding: 1rem;
  }
  
  .purchases-filters {
    padding: 1rem;
  }

  .modal-corporate .modal-body {
    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;
  }
  
  .table-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
  }
  
  .product-search-container {
    padding: 1rem;
  }
  
  .cart-summary {
    padding: 1rem;
  }
}

@media (max-width: 576px) {
  .purchases-header {
    padding: 0.75rem;
  }
  
  .header-title h3 {
    font-size: 1.1rem;
  }
  
  .header-title i {
    font-size: 1.25rem;
  }
  
  .btn-add-purchase {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .table-purchases,
  .cart-table {
    font-size: 0.75rem;
  }
  
  .table-purchases th,
  .table-purchases td,
  .cart-table th,
  .cart-table td {
    padding: 0.5rem 0.25rem;
  }
  
  .purchases-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;
  }
}


/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
