/* Orders Management Table Styles */

#orders-module .card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

#orders-module .card-header {
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0 !important;
}

#orders-module .search-bar .input-group {
  border: 1px solid #e9ecef;
  border-radius: 50px;
  transition: all 0.3s ease;
}

#orders-module .search-bar .input-group:focus-within {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#orders-module .search-bar .form-control {
  border: none;
  border-radius: 50px 0 0 50px;
  padding-left: 15px;
}

#orders-module .search-bar .input-group-text {
  border: none;
  border-radius: 0 50px 50px 0;
  background-color: transparent;
}

#orders-module .table {
  margin-bottom: 0;
}

#orders-module .table thead th {
  font-weight: 600;
  color: #495057;
  border-top: none;
  border-bottom: 2px solid #dee2e6;
}

#orders-module .table tbody td {
  vertical-align: middle;
  border-top: 1px solid #dee2e6;
  padding: 12px 8px;
}

#orders-module .table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

#orders-module .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.01);
}

#orders-module .table-striped tbody tr:nth-of-type(even) {
  background-color: rgba(0, 0, 0, 0.03);
}

#orders-module .table-striped tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

#orders-module .action-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}

#orders-module .action-buttons i {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

#orders-module .action-buttons i.bi-eye {
  background-color: #6c757d;
  color: white;
}

#orders-module .action-buttons i.bi-eye:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
}

#orders-module .action-buttons i.bi-pencil {
  background-color: #17a2b8;
  color: white;
}

#orders-module .action-buttons i.bi-pencil:hover {
  background-color: #138496;
  transform: translateY(-2px);
}

#orders-module .action-buttons i.bi-trash {
  background-color: #dc3545;
  color: white;
}

#orders-module .action-buttons i.bi-trash:hover {
  background-color: #c82333;
  transform: translateY(-2px);
}

#orders-module .action-buttons i.bi-check-circle {
  background-color: #28a745;
  color: white;
}

#orders-module .action-buttons i.bi-check-circle:hover {
  background-color: #218838;
  transform: translateY(-2px);
}

#orders-module .action-buttons i.bi-x-circle {
  background-color: #ffc107;
  color: #212529;
}

#orders-module .action-buttons i.bi-x-circle:hover {
  background-color: #e0a800;
  transform: translateY(-2px);
}

#orders-module .action-buttons i.bi-receipt {
  background-color: #6f42c1;
  color: white;
}

#orders-module .action-buttons i.bi-receipt:hover {
  background-color: #5a32a3;
  transform: translateY(-2px);
}

/* Dropdown menu for export options */
#orders-module .action-buttons .dropdown {
  display: inline-block;
  position: relative;
}

#orders-module .action-buttons .dropdown i.bi-receipt {
  background-color: #6f42c1;
  color: white;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

#orders-module .action-buttons .dropdown i.bi-receipt:hover {
  background-color: #5a32a3;
  transform: translateY(-2px);
}

#orders-module .action-buttons .dropdown-menu {
  min-width: 200px;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.375rem;
}

#orders-module .action-buttons .dropdown-item {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  transition: background-color 0.15s ease-in-out;
}

#orders-module .action-buttons .dropdown-item:hover {
  background-color: #f8f9fa;
}

#orders-module .action-buttons .dropdown-item i {
  width: 20px;
  text-align: center;
  margin-right: 8px;
  font-size: 16px;
}

#orders-module .action-buttons .dropdown-item i.bi-eye {
  color: #6c757d;
}

#orders-module .action-buttons .dropdown-item i.bi-file-earmark-text {
  color: #6c757d;
}

#orders-module .action-buttons .dropdown-item i.bi-file-pdf {
  color: #dc3545;
}

#orders-module .action-buttons .dropdown-item i.bi-file-earmark-excel {
  color: #28a745;
}

#orders-module .action-buttons .dropdown-item i.bi-file-earmark-spreadsheet {
  color: #20c997;
}

#orders-module .action-buttons .dropdown-item i.bi-truck {
  color: #007bff;
}

#orders-module .pagination-container {
  display: flex;
  justify-content: flex-end;
}

#orders-module .form-select {
  cursor: pointer;
}

#orders-module .form-select:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Currency formatting styles */
#orders-module .currency-cell {
  font-weight: 600;
  color: #28a745;
  text-align: right;
}

#orders-module .order-total-amount {
  font-weight: 700;
  font-size: 1.1rem;
  color: #28a745;
  text-align: right;
}

#orders-module .order-items-table .total-price-input,
#orders-module .order-items-table .unit-price-input,
#orders-module .order-items-table .processing-fee-input,
#orders-module .order-items-table .additional-costs-input {
  text-align: right;
}

#orders-module .order-items-table .total-price-input {
  font-weight: 600;
  color: #28a745;
}

#orders-module .order-items-table .tax-input {
  width: 80px;
}

/* Tổng tiền các trường input */
#orderSubtotalAmount, #orderTaxAmount, #orderTotalAmount {
  text-align: right;
  font-weight: 600;
  color: #28a745;
}

/* Status badge styles */
#orders-module .badge-status {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  display: inline-block;
  text-align: center;
  min-width: 120px;
  position: relative;
  overflow: hidden;
}

#orders-module .badge-status::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

#orders-module .badge-status:hover::before {
  left: 100%;
}

#orders-module .badge-status:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#orders-module .status-Mới:hover {
  box-shadow: 0 4px 8px rgba(23, 162, 184, 0.4);
}

#orders-module .status-Đã xác nhận:hover {
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

#orders-module .status-Đã tạo đơn tổng hợp:hover {
  box-shadow: 0 4px 8px rgba(111, 66, 193, 0.4);
}

#orders-module .status-Đã hủy:hover {
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

#orders-module .status-default:hover {
  box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}

#orders-module .status-Mới {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: 1px solid #0056b3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orders-module .status-Đã-xác-nhận {
  background: linear-gradient(135deg, #20c997 0%, #198754 100%);
  color: white;
  border: 1px solid #198754;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orders-module .status-Đã-tạo-đơn-tổng-hợp {
  background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
  color: white;
  border: 1px solid #5a32a3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orders-module .status-Đã-hủy {
  background: linear-gradient(135deg, #dc3545 0%, #bd2130 100%);
  color: white;
  border: 1px solid #bd2130;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orders-module .status-default {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  color: white;
  border: 1px solid #5a6268;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Status display in order details view */
#orderModal .status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Status dropdown in order form */
#orderModal #orderStatus {
  border-radius: 6px;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#orderModal #orderStatus:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Date filter labels */
#orders-module .form-label {
  margin-top: 5px;
  margin-bottom: 0;
}

/* Date filter adjustments */
#orders-module #ordersStartDateFilter,
#orders-module #ordersEndDateFilter {
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#orders-module #ordersStartDateFilter:focus,
#orders-module #ordersEndDateFilter:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Date filter labels */
#orders-module .form-label.date-label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

/* Date range container styling */
#orders-module .date-range-container {
  display: flex;
  gap: 0.5rem;
}

#orders-module .date-range-container > div {
  flex: 1;
}

/* Rows per page and row count */
#orders-module .rows-per-page .form-select {
  width: auto;
  display: inline-block;
}

/* Modal styles */
#orderModal .modal-content {
  border-radius: 10px;
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Tăng chiều rộng của modal thêm 10% */
#orderModal .modal-dialog {
  max-width: 75%; /* Tăng từ mặc định khoảng 500px lên khoảng 75% màn hình */
  margin: 1.75rem auto; /* Giữ nguyên margin để căn giữa */
}

/* Tăng chiều rộng tối đa cho modal lớn */
#orderModal .modal-dialog.modal-xl {
 max-width: 90%; /* Tăng kích thước lớn hơn */
}

#orderModal .modal-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0 !important;
}

#orderModal .modal-title {
  font-weight: 600;
  color: #fff;
}

#orderModal .modal-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 10px 10px !important;
}

#orderModal .form-label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
}

#orderModal .table th {
  font-weight: 600;
  color: #495057;
  background-color: #f8f9fa;
}

#orderModal .table td {
  vertical-align: middle;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #orders-module .table-responsive {
    border: none;
  }
  
  #orders-module .table thead th,
  #orders-module .table tbody td {
    padding: 8px 4px;
    font-size: 0.875rem;
  }
  
  #orders-module .action-buttons i {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  #orders-module .search-bar .form-control {
    padding-left: 10px;
    font-size: 0.875rem;
  }
  
  #orders-module .currency-cell {
    font-size: 0.875rem;
  }
}

@media (max-width: 576px) {
  #orders-module .card-header .row > div {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  #orders-module .action-buttons {
    gap: 4px;
  }
  
  #orders-module .action-buttons i {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  
  #orders-module .currency-cell {
    font-size: 0.8rem;
  }
  
  /* Stack filter rows on mobile */
  #orders-module .row.g-2 > .col-md-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Stack row count and rows per page on mobile */
  #orders-module .mt-1 > .col-md-4:last-child {
    flex: 0 0 100%;
    max-width: 100%;
    justify-content: flex-start !important;
    margin-top: 10px;
  }
  
  #orders-module .rows-per-page {
    margin-left: 0 !important;
    margin-top: 5px;
  }
}

/* Order Details Modal Styles */
#orderDetailsModal .modal-content {
  border-radius: 10px;
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#orderDetailsModal .modal-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0 !important;
}

#orderDetailsModal .modal-title {
  font-weight: 600;
  color: #fff;
}

#orderDetailsModal .modal-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 10px 10px !important;
}

#orderDetailsModal .card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

#orderDetailsModal .card-header {
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0 !important;
}

#orderDetailsModal .table th {
  font-weight: 600;
  color: #495057;
  background-color: #f8f9fa;
}

#orderDetailsModal .table td {
  vertical-align: middle;
  border: none;
}

#orderDetailsModal .table-borderless td {
  padding: 0.25rem 0.5rem;
}

#orderDetailsModal .table-responsive {
  overflow-x: auto;
}

/* Status badge styles in order details */
#orderDetailsModal .badge-status {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  display: inline-block;
  text-align: center;
  min-width: 120px;
  position: relative;
  overflow: hidden;
}

/* Apply the same styles as in orders module */
#orderDetailsModal .badge-status::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

#orderDetailsModal .badge-status:hover::before {
  left: 100%;
}

#orderDetailsModal .badge-status:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-Mới {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: 1px solid #0056b3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-Đã-xác-nhận {
  background: linear-gradient(135deg, #20c997 0%, #198754 100%);
  color: white;
  border: 1px solid #198754;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-Đã-tạo-đơn-tổng-hợp {
  background: linear-gradient(135deg, #6f42c1 0%, #5a32a3 100%);
  color: white;
  border: 1px solid #5a32a3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-Đã-hủy {
  background: linear-gradient(135deg, #dc3545 0%, #bd2130 100%);
  color: white;
  border: 1px solid #bd2130;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-default {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  color: white;
  border: 1px solid #5a6268;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#orderDetailsModal .status-Mới:hover {
  box-shadow: 0 4px 8px rgba(23, 162, 184, 0.4);
}

#orderDetailsModal .status-Đã-xác-nhận:hover {
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

#orderDetailsModal .status-Đã-tạo-đơn-tổng-hợp:hover {
  box-shadow: 0 4px 8px rgba(111, 66, 193, 0.4);
}

#orderDetailsModal .status-Đã-hủy:hover {
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

#orderDetailsModal .status-default:hover {
  box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}

/* Expand icon styles */
.expand-icon {
  transition: transform 0.2s ease-in-out;
  font-size: 12px;
}

.expand-icon.rotated {
  transform: rotate(90deg);
}

/* Update for transform-based rotation */
.expand-icon[style*="rotate"] {
  transition: transform 0.2s ease-in-out;
}

/* Specific styles for chevron icons */
.bi-chevron-right {
  /* Icon > - default state */
}

.bi-chevron-down {
  /* Icon v - expanded state */
}

/* Order detail row */
.order-detail-row {
  background-color: #f8f9fa;
}

.order-detail-content {
  padding: 15px;
}

.order-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.order-items-table th,
.order-items-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
}

.order-items-table th {
  background-color: #e9ecef;
  font-weight: 600;
}

/* Căn phải cho các cột số */
.order-items-table .text-end {
  text-align: right;
}

.order-summary {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #dee2e6;
}

.order-summary div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.order-summary .total {
  font-weight: bold;
  font-size: 1.1rem;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #dee2e6;
}

/* Improved table column width distribution */
#orders-module .table {
  table-layout: auto; /* Allow columns to adjust to content */
  width: 100%;
}

/* Set specific widths for columns that should have fixed width */
#orders-module .table th:nth-child(1), /* STT */
#orders-module .table td:nth-child(1) { /* STT */
  width: 60px;
  white-space: nowrap;
}

#orders-module .table th:nth-child(4), /* Ngày đặt */
#orders-module .table td:nth-child(4), /* Ngày đặt */
#orders-module .table th:nth-child(5), /* Tổng tiền */
#orders-module .table td:nth-child(5), /* Tổng tiền */
#orders-module .table th:nth-child(6), /* Trạng thái */
#orders-module .table td:nth-child(6), /* Trạng thái */
#orders-module .table th:nth-child(7), /* Ngày cập nhật */
#orders-module .table td:nth-child(7), /* Ngày cập nhật */
#orders-module .table th:nth-child(9) { /* Thao tác */
  white-space: nowrap;
}

/* Let the customer column expand more */
#orders-module .table th:nth-child(3), /* Khách hàng */
#orders-module .table td:nth-child(3) { /* Khách hàng */
  min-width: 150px;
}

/* Let the update person column expand */
#orders-module .table th:nth-child(8), /* Người cập nhật */
#orders-module .table td:nth-child(8) { /* Người cập nhật */
  min-width: 120px;
}

/* Make the table responsive and columns adjust to content */
@media (min-width: 768px) {
  #orders-module .table th:nth-child(2), /* Mã đơn */
  #orders-module .table td:nth-child(2) { /* Mã đơn */
    min-width: 80px;
  }
}

/* Cột sản phẩm trong bảng chi tiết đơn hàng */
#orderItems .product-select {
  min-width: 200px; /* Tăng chiều rộng tối thiểu cho ô chọn sản phẩm */
}

/* Cột sản phẩm trong bảng chi tiết đơn hàng trong modal */
#orderModal .table th:nth-child(1), /* Cột sản phẩm */
#orderModal .table td:nth-child(1) { /* Cột sản phẩm */
  min-width: 200px;
 width: 25%;
}

/* Đảm bảo dropdown mở lên phía trên khi nằm trong table-responsive */
/* The overflow: visible rule was causing layout issues with action buttons.
   It is removed. The dropdown positioning will be handled by JavaScript. */

/* Custom styles for action buttons in order modal */
#orderModal #orderItems .action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    white-space: nowrap;
    position: relative;
    z-index: 2;
    padding: 0.5rem;
    background-color: #fff; /* Thêm màu nền trắng */
}

#orderModal #orderItems .action-buttons .btn {
    padding: 0.25rem 0.5rem; /* Giảm padding cho nút nhỏ hơn */
    font-size: 0.875rem; /* Giảm kích thước font */
}

#orderModal #orderItems .action-buttons .price-standard-container {
    display: inline-flex;
    align-items: center;
}

/* Đặt z-index cho các ô khác thấp hơn */
#orderModal #orderItems td {
    position: relative;
    z-index: 1;
}

/* Styles for the supplier info row */
.supplier-info-row td {
    background-color: #f8f9fa !important;
    font-style: italic;
    color: #6c757d;
    padding: 0.25rem 0.75rem !important;
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}