/**
 * DataGrid Component Styles
 * Product Catalog style checkboxes and action buttons
 */

/* Product Catalog style checkboxes - Override toggle switches */
.table input[type="checkbox"].form-check-input {
  width: 16px !important;
  height: 16px !important;
  border: 1px solid var(--bs-border-color) !important;
  border-radius: 3px !important;
  background: var(--bs-body-bg) !important;
  transition: all 0.2s ease-in-out !important;
  margin: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  position: relative !important;
  z-index: 1 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

/* Remove any pseudo-elements from Bootstrap */
.table input[type="checkbox"].form-check-input::before,
.table input[type="checkbox"].form-check-input::after {
  display: none !important;
  content: none !important;
}

/* Checked state */
.table input[type="checkbox"].form-check-input:checked {
  background-color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}

/* Focus state */
.table input[type="checkbox"].form-check-input:focus {
  border-color: var(--bs-primary) !important;
  outline: 0 !important;
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25) !important;
}

/* Hover state */
.table input[type="checkbox"].form-check-input:hover {
  border-color: var(--bs-primary) !important;
}

/* Center checkbox in table cell */
.table th,
.table td {
  vertical-align: middle;
}

.table th[data-type="Checkbox"],
.table td:has(input[type="checkbox"]) {
  text-align: center !important;
  padding: 0.75rem 0.5rem !important;
}

/* Ensure checkbox is clickable */
.table input[type="checkbox"] {
  pointer-events: auto !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
}

/* Remove form-check wrapper styling conflicts */
.table .form-check {
  display: inline-block !important;
  margin-bottom: 0 !important;
  min-height: auto !important;
}

/* Product Catalog style action buttons */
.btn-group-sm .btn {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.8125rem !important;
  border-radius: var(--bs-border-radius-sm) !important;
  transition: all 0.2s ease-in-out !important;
}

.btn-group-sm .btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Action column styling */
.table th[data-type="Actions"],
.table td:has(.btn-group) {
  text-align: center !important;
  vertical-align: middle !important;
  padding: 0.75rem 0.5rem !important;
}

/* Ensure action buttons are properly spaced */
.btn-group .btn + .btn {
  margin-left: -1px;
}

.btn-group .btn:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.btn-group .btn:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Dropdown action menu styling */
.dropdown-toggle::after {
  display: none !important; /* Hide default dropdown arrow */
}

.dropdown-menu {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  min-width: 160px;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  transition: all 0.2s ease-in-out;
}

.dropdown-item:hover {
  background-color: var(--bs-light);
  transform: none; /* Override any global hover transforms */
}

.dropdown-item i {
  width: 16px;
  text-align: center;
}

/* Three dots button styling */
.btn:has(.bi-three-dots) {
  padding: 0.25rem 0.5rem !important;
  border: 1px solid var(--bs-border-color) !important;
  background: var(--bs-body-bg) !important;
}

.btn:has(.bi-three-dots):hover {
  background: var(--bs-light) !important;
  border-color: var(--bs-primary) !important;
}

/* DataGrid Header Styling */
.card-header[data-section="header"] {
  background: var(--bs-light);
  border-bottom: 1px solid var(--bs-border-color);
}

.card-header[data-section="header"] .card-title {
  color: var(--bs-dark);
  font-weight: 600;
}

/* DataGrid Toolbar Styling */
[data-section="toolbar"] .btn {
  font-size: 0.875rem;
  font-weight: 500;
}

[data-section="toolbar"] .btn-sm {
  padding: 0.375rem 0.75rem;
}

/* DataGrid Table Styling */
.table-responsive {
  border-radius: var(--bs-border-radius);
  overflow: hidden;
}

.table thead th {
  background: var(--bs-light);
  border-bottom: 2px solid var(--bs-border-color);
  font-weight: 600;
  color: var(--bs-dark);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background-color: var(--bs-light);
}

/* DataGrid Pagination Styling */
.pagination {
  margin-bottom: 0;
}

.pagination .page-link {
  border: 1px solid var(--bs-border-color);
  color: var(--bs-dark);
  font-weight: 500;
}

.pagination .page-item.active .page-link {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.pagination .page-link:hover {
  background-color: var(--bs-light);
  border-color: var(--bs-primary);
  color: var(--bs-primary);
}

/* DataGrid Loading State */
.datagrid-loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.datagrid-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* DataGrid Empty State */
.datagrid-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary);
}

.datagrid-empty i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* DataGrid Stats Cards */
.stats-card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 1rem;
  text-align: center;
  background: var(--bs-body-bg);
  transition: all 0.2s ease-in-out;
}

.stats-card:hover {
  border-color: var(--bs-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stats-card .stats-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--bs-primary);
  margin-bottom: 0.5rem;
}

.stats-card .stats-label {
  font-size: 0.875rem;
  color: var(--bs-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== MERGED FROM DEMO-GRID.CSS ===== */

/* Avatar styling */
.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

/* Enhanced table styling */
.table th {
  border-top: none;
  font-weight: 600;
  background-color: #343a40;
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.table-hover tbody tr:hover {
  background-color: rgba(0, 123, 255, 0.075);
  cursor: pointer;
}

.table td {
  vertical-align: middle;
  white-space: nowrap;
}

/* Progress bar styling */
.progress {
  background-color: #e9ecef;
}

.progress-bar {
  font-size: 11px;
  line-height: 20px;
  font-weight: 600;
}

/* Button group styling */
.btn-group-sm > .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Pagination styling */
.pagination .page-link {
  color: #007bff;
  border-color: #dee2e6;
  padding: 0.375rem 0.75rem;
}

.pagination .page-item.active .page-link {
  background-color: #007bff;
  border-color: #007bff;
  color: white;
}

.pagination .page-item.disabled .page-link {
  color: #6c757d;
  background-color: #fff;
  border-color: #dee2e6;
}

.pagination .page-item:first-child .page-link,
.pagination .page-item:last-child .page-link {
  border-radius: 0.375rem;
}

/* Card tools */
.card-tools .btn {
  margin-left: 0.25rem;
}

/* DataTables info */
.dataTables_info {
  padding-top: 0.75rem;
  font-size: 0.875rem;
  color: #6c757d;
}

/* Table responsive styling */
.table-responsive {
  border-radius: 0.375rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Badge styling */
.badge {
  font-size: 0.75em;
  font-weight: 500;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* Card enhancements */
.card {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border: 1px solid rgba(0, 0, 0, 0.125);
}

.card-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.card-title {
  margin-bottom: 0;
  font-weight: 600;
  color: #495057;
}

/* Form enhancements */
.form-control:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.input-group-append .btn {
  border-left: 0;
}

/* Button enhancements */
.btn {
  font-weight: 500;
  border-radius: 0.375rem;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Modal enhancements */
.modal-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.modal-title {
  font-weight: 600;
  color: #495057;
}

.modal-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

/* Alert enhancements */
.alert {
  border-radius: 0.5rem;
  border: none;
  font-weight: 500;
}

.alert-dismissible .close {
  padding: 0.75rem 1rem;
  color: inherit;
  opacity: 0.8;
}

.alert-dismissible .close:hover {
  opacity: 1;
}

/* Loading animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Custom scrollbar for table */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Enhanced checkbox styling */
input[type="checkbox"] {
  transform: scale(1.1);
  margin: 0;
}

/* Badge variations */
.badge-primary {
  background-color: #007bff;
}
.badge-secondary {
  background-color: #6c757d;
}
.badge-success {
  background-color: #28a745;
}
.badge-danger {
  background-color: #dc3545;
}
.badge-warning {
  background-color: #ffc107;
  color: #212529;
}
.badge-info {
  background-color: #17a2b8;
}
.badge-light {
  background-color: #f8f9fa;
  color: #212529;
}

/* Hover effects */
.table tbody tr:hover .btn {
  opacity: 1;
}

.table tbody tr .btn {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

/* Text utilities */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status indicators */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.status-indicator.active {
  background-color: #28a745;
}

.status-indicator.inactive {
  background-color: #6c757d;
}

.status-indicator.pending {
  background-color: #ffc107;
}

.status-indicator.suspended {
  background-color: #dc3545;
}

/* Enhanced responsive design */
@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.875rem;
  }

  .btn-group-sm > .btn {
    padding: 0.125rem 0.25rem;
    font-size: 0.6875rem;
  }

  .card-tools {
    margin-top: 0.5rem;
  }

  .card-tools .btn {
    margin-bottom: 0.25rem;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
  }

  .dropdown-menu {
    min-width: 140px;
  }
}

/* ===== LAYOUT CSS FIXES ===== */

/* Dropdown fixes */
.dropdown-menu.show {
  display: block !important;
}
.dropdown-toggle::after {
  display: none !important;
}
.btn:has(.bi-three-dots) {
  padding: 0.25rem 0.5rem !important;
}

/* Checkbox alignment fixes */
.table th:first-child,
.table td:first-child {
  width: 50px !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding: 0.75rem 0.5rem !important;
}

.table th:first-child input[type="checkbox"],
.table td:first-child input[type="checkbox"] {
  margin: 0 auto !important;
  display: block !important;
}

/* Icon column alignment */
.table td:nth-child(2) {
  text-align: center !important;
  vertical-align: middle !important;
  width: 60px !important;
}

.table td:nth-child(2) i {
  font-size: 1.5rem !important;
  color: var(--bs-primary) !important;
}

/* Actions column alignment */
.table th:last-child,
.table td:last-child {
  text-align: center !important;
  vertical-align: middle !important;
  width: 120px !important;
}

/* Table row hover effect */
.table tbody tr:hover {
  background-color: var(--bs-light) !important;
}

/* ===== VALIDATION ERROR STYLES ===== */
/* Validation error input - FOCUS ĐỎ RÕ RÀNG */
.validation-error,
input.validation-error,
select.validation-error,
textarea.validation-error {
  border: 3px solid #dc3545 !important;
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.4rem rgba(220, 53, 69, 0.6) !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
  outline: none !important;
}

/* Focus state cho validation error */
.validation-error:focus,
input.validation-error:focus,
select.validation-error:focus,
textarea.validation-error:focus {
  border: 4px solid #dc3545 !important;
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.6rem rgba(220, 53, 69, 0.8) !important;
  background-color: rgba(220, 53, 69, 0.15) !important;
  outline: none !important;
}

/* Error message styling */
.invalid-feedback {
  display: block !important;
  color: #dc3545 !important;
  font-weight: bold !important;
  font-size: 0.875rem !important;
  margin-top: 0.25rem !important;
}
