@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --background: 0 0% 100%;
  --foreground: 224 71.4% 4.1%;
  --card: 0 0% 100%;
  --card-foreground: 224 71.4% 4.1%;
  --popover: 0 0% 100%;
  --popover-foreground: 224 71.4% 4.1%;
  --primary: 199 89% 48%;
  /* #0ea5e9 */
  --primary-foreground: 0 0% 100%;
  --secondary: 220 14.3% 95.9%;
  --secondary-foreground: 220.9 39.3% 11%;
  --muted: 220 14.3% 95.9%;
  --muted-foreground: 220 8.9% 46.1%;
  --accent: 220 14.3% 95.9%;
  --accent-foreground: 220.9 39.3% 11%;
  --destructive: 0 84.2% 60.2%;
  /* Vibrant Red */
  --destructive-foreground: 210 40% 98%;
  --warning: 38 92% 50%;
  /* Vibrant Amber/Yellow */
  --warning-foreground: 222.2 47.4% 11.2%;
  --border: 220 13% 91%;
  --input: 220 13% 91%;
  --ring: 199 89% 48%;
  --radius: 0.5rem;

  /* Layout dimensions */
  --sidebar-width: 16rem;
  --header-height: 4rem;

  /* Shadow system */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

  /* Transition timing */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

.dark {
  --background: 224 71.4% 4.1%;
  --foreground: 210 20% 98%;
  --card: 224 71.4% 4.1%;
  --card-foreground: 210 20% 98%;
  --popover: 224 71.4% 4.1%;
  --popover-foreground: 210 20% 98%;
  --primary: 199 89% 48%;
  --primary-foreground: 224 71.4% 4.1%;
  --secondary: 215 27.9% 16.9%;
  --secondary-foreground: 210 20% 98%;
  --muted: 215 27.9% 16.9%;
  --muted-foreground: 217.9 10.6% 64.9%;
  --accent: 215 27.9% 16.9%;
  --accent-foreground: 210 20% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 210 20% 98%;
  --border: 215 27.9% 16.9%;
  --input: 215 27.9% 16.9%;
  --ring: 199 89% 48%;
}

* {
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Custom styles for Toastr notifications to align with shadcn Toast style */
#toast-container>div {
  opacity: 1 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
  border: 1px solid hsl(var(--border)) !important;
  border-radius: var(--radius) !important;
  background-color: hsl(var(--card)) !important;
  color: hsl(var(--card-foreground)) !important;
  font-family: 'Inter', sans-serif !important;
  padding: 16px 16px 16px 50px !important;
}

#toast-container>.toast-success {
  border-left: 4px solid #10b981 !important;
}

#toast-container>.toast-error {
  border-left: 4px solid hsl(var(--destructive)) !important;
}

#toast-container>.toast-warning {
  border-left: 4px solid #f59e0b !important;
}

#toast-container>.toast-info {
  border-left: 4px solid hsl(var(--primary)) !important;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.2);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.4);
}

/* Hide legacy desktop elements */
.left-side-bar,
.header,
.mobile-menu-overlay,
.main-container {
  display: none !important;
}

/* Redefine global layout container to make it clean & fullscreen */
.app-shell-modern {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: hsl(var(--background));
}

/* Loading Overlay shadcn-style */
.loading-overlay-modern {
  position: fixed;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.dark .loading-overlay-modern {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Support validation tags */
.field-validation-error,
span[data-valmsg-for],
span[asp-validation-for],
.text-danger.field-validation-error {
  color: hsl(var(--destructive)) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  margin-top: 0.25rem !important;
  display: block !important;
}

/* Custom Bootstrap Modal mapping to shadcn Dialog */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.show {
  display: flex !important;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  width: 100%;
  max-width: 440px;
  margin: auto;
}

.modal-content {
  background-color: rgb(255, 255, 255);
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
}

.modal-header .close {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: hsl(var(--muted-foreground));
  opacity: 0.5;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.modal-header .close:hover {
  opacity: 0.8;
}

.modal-body {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid hsl(var(--border));
  padding-top: 0.75rem;
}

.modal.fade {
  transition: opacity 0.15s linear;
}

.modal.fade:not(.show) {
  display: none !important;
}

/* --- Form and Layout Utility mappings to replicate shadcn/ui styles globally --- */

.page-shell {
  display: block;
  width: 100%;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header-card {
  display: flex;
  flex-direction: column;
  background-color: rgb(255, 255, 255);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.page-header-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .page-header-grid {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  background-color: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.625rem;
  text-transform: uppercase;
  width: fit-content;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: hsl(var(--foreground));
  margin-top: 0.375rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.surface-card {
  background-color: rgb(255, 255, 255);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.section-header {
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.section-subtitle {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .form-grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.field-help {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.field-frame {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--muted) / 0.3);
}

.field-frame input[type="checkbox"] {
  height: 1rem;
  width: 1rem;
  border-radius: 0.25rem;
  border-color: hsl(var(--border));
  color: hsl(var(--primary));
  cursor: pointer;
  margin-top: 0.125rem;
}

.field-frame span {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  font-weight: 500;
}

.section-divider {
  border-top: 1px solid hsl(var(--border));
  margin: 1.5rem 0;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Custom styled form inputs */
.form-control,
.custom-select,
select.form-control,
textarea.form-control {
  display: flex;
  height: 2.5rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.custom-select:focus,
select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* Global select dropdown styling to remove default OS arrow and use custom chevron */
select,
select.form-control,
.custom-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem 1rem;
  padding-right: 2.25rem !important;
}

textarea.form-control {
  height: auto;
  min-height: 80px;
}

/* Text warning overlays */
.text-danger {
  color: hsl(var(--destructive));
  font-size: 0.75rem;
  font-weight: 500;
}

/* Action button configurations */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  height: 2.5rem;
  padding: 0 1rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background-color: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover {
  background-color: hsl(var(--secondary) / 0.8);
}

.btn-danger {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-danger:hover {
  background-color: hsl(var(--destructive) / 0.9);
}

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
}

.btn-outline-secondary {
  border-color: hsl(var(--border));
  background-color: transparent;
  color: hsl(var(--foreground));
}

.btn-outline-secondary:hover {
  background-color: hsl(var(--muted));
}

.btn-outline-primary {
  border-color: hsl(var(--border));
  background-color: transparent;
  color: hsl(var(--primary));
}

.btn-outline-primary:hover {
  background-color: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary));
}

/* Table overrides */
.table-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table thead {
  background-color: hsl(var(--muted) / 0.4);
  border-bottom: 1px solid hsl(var(--border));
}

.table th {
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.05em;
}

.table th a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
}

.table th a:hover {
  color: hsl(var(--foreground));
}

.table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid hsl(var(--border));
}

.table tbody tr:hover {
  background-color: hsl(var(--muted) / 0.2);
}

/* Data pills */
.data-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.data-pill.neutral {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.data-pill.muted {
  color: hsl(var(--muted-foreground));
}

/* Status badge pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-pill.active {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #d1fae5;
}

.status-pill.inactive {
  background-color: hsl(var(--secondary));
  color: hsl(var(--muted-foreground));
  border-color: hsl(var(--border));
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state-icon {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: 9999px;
  background-color: hsl(var(--muted) / 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.empty-state-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.empty-state-copy {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
  max-width: 320px;
}

/* Custom Selectpicker Core (Standalone Bootstrap) - Tailwind UI Compatible */
.bootstrap-select select {
  display: none !important;
}

.bootstrap-select,
div.bootstrap-select,
.bootstrap-select.btn-group {
  position: relative !important;
  width: 100% !important;
  height: auto !important;
  padding: 0 !important;
  border: none !important;
  border-width: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

/* container: 'body' — cho phép JS neo fixed dưới nút; z-index 99999 cao hơn modal (9990) */
.bootstrap-select.bs-container {
  position: fixed !important;
  width: auto !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  z-index: 99999 !important;
}

.bootstrap-select.bs-container>.dropdown-menu {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: min(24rem, calc(100vw - 1.5rem)) !important;
  min-width: 100% !important;
  z-index: 99999 !important;
  background-color: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -4px rgba(0, 0, 0, 0.08) !important;
  padding: 0.5rem 0 !important;
}

.bootstrap-select .bs-searchbox .form-control,
.bootstrap-select.bs-container .bs-searchbox .form-control {
  height: 34px !important;
  border-radius: 0.375rem !important;
  border: 1px solid #cbd5e1 !important;
  background-color: #f8fafc !important;
  padding: 0.25rem 0.625rem !important;
  font-size: 0.8125rem !important;
  color: #1e293b !important;
  box-shadow: none !important;
  outline: none !important;
}

.bootstrap-select .bs-searchbox .form-control:focus,
.bootstrap-select.bs-container .bs-searchbox .form-control:focus {
  border-color: #0ea5e9 !important;
  background-color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2) !important;
}

/* Override focus ring on the container */
.bootstrap-select:focus,
.bootstrap-select:focus-within,
.bootstrap-select:active {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  border-width: 0 !important;
  background: transparent !important;
}

.bootstrap-select .dropdown-toggle {
  height: 40px !important;
  border-radius: 0.5rem !important;
  border: 1px solid #e2e8f0 !important;
  background-color: #fff !important;
  color: #1e293b !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  padding: 0 2rem 0 0.75rem !important;
  /* Left padding 0.75rem, right padding 2rem for caret */
  width: 100% !important;
  position: relative !important;
}

.bootstrap-select .dropdown-toggle:focus,
.bootstrap-select.show .dropdown-toggle {
  outline: none !important;
  border-color: #0ea5e9 !important;
  box-shadow: 0 0 0 2px #0ea5e9 !important;
}

/* Align and center filter option text vertically */
.bootstrap-select .dropdown-toggle .filter-option {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  height: 100% !important;
  width: 100% !important;
  padding: 0 2rem 0 0.75rem !important;
  display: flex !important;
  align-items: center !important;
  text-align: left !important;
}

/* Dropdown Menu positioning and style */
.bootstrap-select>.dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  transform: none !important;
  z-index: 1050 !important;
  display: none;
  min-width: max(100%, 140px) !important;
  margin: 2px 0 0 0 !important;
  border-radius: 0.5rem !important;
  border: 1px solid #e2e8f0 !important;
  background-color: #ffffff !important;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;
  padding: 0.5rem 0 !important;
}

.bootstrap-select.show>.dropdown-menu,
.bootstrap-select.open>.dropdown-menu,
.bootstrap-select>.dropdown-menu.show,
.bootstrap-select>.dropdown-menu.open,
.bootstrap-select.bs-container.open>.dropdown-menu,
.bootstrap-select.bs-container.show>.dropdown-menu {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Dropdown list items */
.bootstrap-select>.dropdown-menu li a {
  padding: 0.375rem 1rem !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: #334155 !important;
  display: block !important;
}

.bootstrap-select>.dropdown-menu li a span.text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

.bootstrap-select>.dropdown-menu li.active a,
.bootstrap-select>.dropdown-menu li a:hover {
  background-color: #f0f9ff !important;
  color: #0369a1 !important;
}

/* Custom Selectpicker Core (Standalone Bootstrap) - Tailwind UI Compatible */
.bootstrap-select select {
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  position: absolute !important;
  z-index: -1 !important;
}

/* Dropdown Menu positioning and style */
.bootstrap-select>.dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  transform: none !important;
  z-index: 1050 !important;
  display: none;
  min-width: max(100%, 140px) !important;
  margin: 2px 0 0 0 !important;
  border-radius: 0.5rem !important;
  border: 1px solid #e2e8f0 !important;
  background-color: #ffffff !important;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;
  padding: 0.5rem 0 !important;
}

.bootstrap-select.show>.dropdown-menu,
.bootstrap-select.open>.dropdown-menu,
.bootstrap-select>.dropdown-menu.show,
.bootstrap-select>.dropdown-menu.open,
.bootstrap-select.bs-container.open>.dropdown-menu,
.bootstrap-select.bs-container.show>.dropdown-menu,
.bootstrap-select.bs-container.open .dropdown-menu,
.bootstrap-select.bs-container.show .dropdown-menu {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Dropdown list items */
.bootstrap-select>.dropdown-menu li a {
  padding: 0.375rem 1rem !important;
  font-size: 0.75rem !important;
  color: #334155 !important;
  display: block !important;
}

.bootstrap-select>.dropdown-menu li a span.text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

.bootstrap-select>.dropdown-menu li.active a,
.bootstrap-select>.dropdown-menu li a:hover {
  background-color: #f0f9ff !important;
  color: #0369a1 !important;
}

/* Custom overrides for selectpicker searchbox and options */
.bootstrap-select .bs-searchbox input.form-control {
  font-size: 0.75rem !important;
  height: 32px !important;
  padding: 0.25rem 0.5rem !important;
}

.justify-content-end {
  justify-content: end !important;
}

/* Interactive controls: always show pointer cursor */
a,
button,
[type="button"],
[type="submit"],
[type="reset"],
[role="button"],
label[for],
summary {
  cursor: pointer;
}

a[aria-disabled="true"],
button:disabled,
[type="button"]:disabled,
[type="submit"]:disabled,
[type="reset"]:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

.z-max {
  z-index: 99999!important;
}

.nowrap {
  white-space: nowrap!important;
}

/* ══════════════════════════════════════════════════════════════════════════════════
   AMC MES - GLOBAL RESPONSIVE HARDENING & AUDIT SUITE
   Ensures seamless UX across:
   - Desktop: 1920x1080, 1440x900, 1280x720
   - Laptop:  1366x768, 1280x800
   - Tablet:  1024x1366, 834x1194, 768x1024
   - Mobile:  430x932, 390x844, 375x812
   ══════════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Universal Table Responsive Container & Cell Safety ── */
.table-responsive,
.overflow-x-auto,
.mes-table-container,
.dataTables_wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative;
    scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar,
.overflow-x-auto::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb,
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

.dark .table-responsive::-webkit-scrollbar-thumb,
.dark .overflow-x-auto::-webkit-scrollbar-thumb {
    background: #475569;
}

table th,
table td {
    vertical-align: middle;
}

@media (max-width: 768px) {
    .table-responsive table,
    .overflow-x-auto table {
        min-width: 580px;
    }
    
    table th, table td {
        padding: 0.5rem 0.625rem !important;
        font-size: 0.8125rem;
    }
}

/* ── 2. Universal Banner & Header Responsiveness ── */
.page-header,
.module-header,
.module-banner,
.dashboard-header {
    word-break: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    .page-header .flex-between,
    .module-header .flex-between,
    .module-banner .flex-between {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
}

/* ── 3. Universal Toolbar & Filter Bar Wrapping ── */
.toolbar,
.filter-bar,
.table-toolbar,
.action-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .toolbar,
    .filter-bar,
    .table-toolbar,
    .action-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar > *,
    .filter-bar > *,
    .table-toolbar > *,
    .action-toolbar > * {
        width: 100% !important;
    }
    
    .toolbar .btn,
    .filter-bar .btn,
    .table-toolbar .btn,
    .action-toolbar .btn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* ── 4. Bootstrap Selectpicker Mobile Elevation & Boundary Safety ── */
.bootstrap-select {
    max-width: 100% !important;
}

.bootstrap-select > .dropdown-toggle {
    width: 100% !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .bootstrap-select > .dropdown-menu {
        max-width: calc(100vw - 2rem) !important;
        left: 0 !important;
        right: auto !important;
        transform: none !important;
    }

    body > .bs-container {
        position: fixed !important;
        z-index: 2050 !important;
        left: 1rem !important;
        right: 1rem !important;
        width: calc(100vw - 2rem) !important;
    }
    
    body > .bs-container .dropdown-menu {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ── 5. Form Responsive Grids & Mobile Touch Targets ── */
@media (max-width: 640px) {
    .form-grid-2,
    .form-grid-3,
    .form-grid-4,
    .modal-form-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.875rem !important;
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .form-grid-3,
    .form-grid-4 {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1rem !important;
    }
}

/* ── 6. Card & Metric Consistency ── */
.card,
.mes-card,
.stat-card,
.dashboard-panel {
    border-radius: 1rem;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

.currency-value {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ── 7. Modal Responsive Hardening ── */
@media (max-width: 640px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
        width: auto !important;
    }

    .modal-content {
        max-height: calc(100vh - 1rem) !important;
        overflow-y: auto !important;
        border-radius: 0.875rem !important;
    }

    .modal-footer {
        flex-direction: column-reverse !important;
        gap: 0.5rem !important;
    }

    .modal-footer > * {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* ── 8. Text Safety for Long Vietnamese Strings ── */
.truncate-multiline {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.text-break-all {
    word-break: break-all;
    overflow-wrap: break-word;
}


