/* ==========================================================================
   MPG Vietnam — Design system (main.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@300;400;500&display=swap');

:root {
  /* Màu chủ đạo */
  --mpg-primary: #27ae60;
  --mpg-blue: #2980b9;
  --mpg-danger: #e74c3c;
  --mpg-warning: #f1c40f;
  --mpg-dark: #2c3e50;
  --mpg-white-soft: #ecf0f1;

  /* Biến thể sáng / tối */
  --mpg-primary-dark: #219a52;
  --mpg-primary-light: #d5f4e3;
  --mpg-blue-dark: #2471a3;
  --mpg-blue-light: #d6eaf8;
  --mpg-danger-dark: #c0392b;
  --mpg-danger-light: #fadbd8;
  --mpg-warning-dark: #d4ac0d;
  --mpg-warning-light: #fcf3cf;
  --mpg-dark-light: #34495e;
  --mpg-dark-muted: #566573;

  /* Trung tính */
  --mpg-white: #ffffff;
  --mpg-bg: var(--mpg-white-soft);
  --mpg-surface: #ffffff;
  --mpg-border: #dfe6e9;
  --mpg-border-strong: #bdc3c7;
  --mpg-text: #2c3e50;
  --mpg-text-muted: #7f8c8d;
  --mpg-text-inverse: var(--mpg-white-soft);

  /* Gradient thương hiệu */
  --mpg-gradient: linear-gradient(135deg, var(--mpg-primary) 0%, var(--mpg-blue) 100%);
  --mpg-gradient-hover: linear-gradient(135deg, var(--mpg-primary-dark) 0%, var(--mpg-blue-dark) 100%);

  /* Typography */
  --mpg-font: "Google Sans Flex", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mpg-font-weight-light: 300;
  --mpg-font-weight-regular: 400;
  --mpg-font-weight-bold: 500;
  --mpg-font-size-xs: 0.75rem;
  --mpg-font-size-sm: 0.875rem;
  --mpg-font-size-md: 1rem;
  --mpg-font-size-lg: 1.125rem;
  --mpg-font-size-xl: 1.25rem;
  --mpg-font-size-2xl: 1.5rem;
  --mpg-line-height: 1.6;

  /* Spacing */
  --mpg-space-1: 4px;
  --mpg-space-2: 8px;
  --mpg-space-3: 12px;
  --mpg-space-4: 16px;
  --mpg-space-5: 20px;
  --mpg-space-6: 24px;
  --mpg-space-8: 32px;

  /* Bo góc */
  --mpg-radius-sm: 8px;
  --mpg-radius-md: 12px;
  --mpg-radius-lg: 16px;
  --mpg-radius-xl: 20px;
  --mpg-radius-pill: 9999px;

  /* Đổ bóng */
  --mpg-shadow-sm: 0 1px 3px rgba(44, 62, 80, 0.08);
  --mpg-shadow-md: 0 4px 16px rgba(44, 62, 80, 0.12);
  --mpg-shadow-lg: 0 16px 45px rgba(44, 62, 80, 0.18);

  /* Chuyển động */
  --mpg-transition: 0.2s ease;

  /* Focus ring */
  --mpg-focus-ring: 0 0 0 3px rgba(39, 174, 96, 0.22);
  --mpg-focus-ring-blue: 0 0 0 3px rgba(41, 128, 185, 0.22);

  /* Layout shell */
  --mpg-sidebar-width: 250px;
  --mpg-topbar-height: 53px;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--mpg-font);
  font-size: var(--mpg-font-size-md);
  font-weight: var(--mpg-font-weight-regular);
  line-height: var(--mpg-line-height);
  color: var(--mpg-text);
  background: var(--mpg-bg);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--mpg-blue);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--mpg-space-3);
  color: var(--mpg-dark);
  line-height: 1.3;
}

h1 { font-size: var(--mpg-font-size-2xl); }
h2 { font-size: var(--mpg-font-size-xl); }
h3 { font-size: var(--mpg-font-size-lg); }

p {
  margin: 0 0 var(--mpg-space-4);
}

p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Typography utilities
   -------------------------------------------------------------------------- */

.text-xs { font-size: var(--mpg-font-size-xs); }
.text-sm { font-size: var(--mpg-font-size-sm); }
.text-lg { font-size: var(--mpg-font-size-lg); }
.text-muted { color: var(--mpg-text-muted); }
.text-primary { color: var(--mpg-primary); }
.text-blue { color: var(--mpg-blue); }
.text-danger { color: var(--mpg-danger); }
.text-warning { color: var(--mpg-warning-dark); }
.text-dark { color: var(--mpg-dark); }
.text-center { text-align: center; }
.font-light { font-weight: var(--mpg-font-weight-light); }
.font-regular { font-weight: var(--mpg-font-weight-regular); }
.font-bold { font-weight: var(--mpg-font-weight-bold); }
.font-semibold { font-weight: var(--mpg-font-weight-bold); }

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

.link {
  color: var(--mpg-blue);
  text-decoration: none;
  font-weight: var(--mpg-font-weight-bold);
  transition: color var(--mpg-transition);
}

.link:hover {
  color: var(--mpg-blue-dark);
  text-decoration: underline;
}

.link-muted {
  color: var(--mpg-text-muted);
  text-decoration: none;
}

.link-muted:hover {
  color: var(--mpg-dark);
}

/* --------------------------------------------------------------------------
   Buttons — bo tròn 2 đầu (pill)
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--mpg-space-2);
  border: 1px solid transparent;
  border-radius: var(--mpg-radius-pill);
  padding: 10px 20px;
  font-family: inherit;
  font-size: var(--mpg-font-size-sm);
  font-weight: var(--mpg-font-weight-bold);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--mpg-transition),
    border-color var(--mpg-transition),
    color var(--mpg-transition),
    box-shadow var(--mpg-transition),
    filter var(--mpg-transition);
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 6px 14px;
  font-size: var(--mpg-font-size-xs);
}

.btn-lg {
  padding: 13px 26px;
  font-size: var(--mpg-font-size-md);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  color: var(--mpg-white);
  background: var(--mpg-primary);
  border-color: var(--mpg-primary);
}

.btn-primary:hover {
  background: var(--mpg-primary-dark);
  border-color: var(--mpg-primary-dark);
}

.btn-blue {
  color: var(--mpg-white);
  background: var(--mpg-blue);
  border-color: var(--mpg-blue);
}

.btn-blue:hover {
  background: var(--mpg-blue-dark);
  border-color: var(--mpg-blue-dark);
}

.btn-danger {
  color: var(--mpg-white);
  background: var(--mpg-danger);
  border-color: var(--mpg-danger);
}

.btn-danger:hover {
  background: var(--mpg-danger-dark);
  border-color: var(--mpg-danger-dark);
}

.btn-warning {
  color: var(--mpg-dark);
  background: var(--mpg-warning);
  border-color: var(--mpg-warning);
}

.btn-warning:hover {
  background: var(--mpg-warning-dark);
  border-color: var(--mpg-warning-dark);
}

.btn-orange {
  color: var(--mpg-white);
  background: #e67e22;
  border-color: #e67e22;
}

.btn-orange:hover {
  background: #cf711d;
  border-color: #cf711d;
}

.btn-dark {
  color: var(--mpg-white);
  background: var(--mpg-dark);
  border-color: var(--mpg-dark);
}

.btn-dark:hover {
  background: var(--mpg-dark-light);
  border-color: var(--mpg-dark-light);
}

.btn-gradient {
  color: var(--mpg-white);
  background: var(--mpg-gradient);
  border-color: transparent;
}

.btn-gradient:hover {
  background: var(--mpg-gradient-hover);
  filter: brightness(1.03);
}

.btn-outline {
  color: var(--mpg-dark);
  background: var(--mpg-white);
  border-color: var(--mpg-border-strong);
}

.btn-outline:hover {
  border-color: var(--mpg-blue);
  color: var(--mpg-blue);
}

/* Nút lưu icon — dùng trên tiêu đề cột và trên từng dòng */
.btn-save-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #16a34a;
  border-radius: 999px;
  background: #fff;
  color: #16a34a;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.btn-save-icon:hover {
  background: #f0fdf4;
  border-color: #15803d;
  color: #15803d;
}

.btn-save-icon:disabled,
.btn-save-icon[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-save-icon svg {
  display: block;
  width: 14px;
  height: 14px;
}

.btn-save-icon--danger {
  border-color: #dc2626;
  color: #dc2626;
}

.btn-save-icon--danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #b91c1c;
  color: #b91c1c;
}

.btn-save-icon--arrow {
  border-color: #2563eb;
  color: #2563eb;
}

.btn-save-icon--arrow:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #1d4ed8;
  color: #1d4ed8;
}

.btn-outline-primary {
  color: var(--mpg-primary);
  background: transparent;
  border-color: var(--mpg-primary);
}

.btn-outline-primary:hover {
  color: var(--mpg-white);
  background: var(--mpg-primary);
}

.btn-ghost {
  color: var(--mpg-dark);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(44, 62, 80, 0.08);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-field {
  margin-bottom: var(--mpg-space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--mpg-space-2);
  font-size: var(--mpg-font-size-sm);
  font-weight: var(--mpg-font-weight-bold);
  color: var(--mpg-dark);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1px solid var(--mpg-border-strong);
  border-radius: var(--mpg-radius-md);
  padding: 11px 14px;
  font-family: inherit;
  font-size: var(--mpg-font-size-sm);
  color: var(--mpg-text);
  background: var(--mpg-white);
  outline: none;
  transition: border-color var(--mpg-transition), box-shadow var(--mpg-transition);
}

.form-textarea {
  min-height: 110px;
  resize: vertical;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--mpg-text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--mpg-primary);
  box-shadow: var(--mpg-focus-ring);
}

.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--mpg-danger);
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.18);
}

.form-hint {
  margin-top: var(--mpg-space-2);
  font-size: var(--mpg-font-size-xs);
  color: var(--mpg-text-muted);
}

.form-error {
  margin-top: var(--mpg-space-2);
  font-size: var(--mpg-font-size-xs);
  color: var(--mpg-danger);
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
  padding: 10px 14px;
  border-radius: var(--mpg-radius-md);
  border: 1px solid transparent;
  font-size: var(--mpg-font-size-sm);
  line-height: 1.5;
}

.alert-success {
  background: var(--mpg-primary-light);
  color: #1e6f43;
  border-color: #a9dfbf;
}

.alert-info {
  background: var(--mpg-blue-light);
  color: #1a5276;
  border-color: #aed6f1;
}

.alert-warning {
  background: var(--mpg-warning-light);
  color: #7d6608;
  border-color: #f9e79f;
}

.alert-danger,
.alert.error {
  background: var(--mpg-danger-light);
  color: var(--mpg-danger-dark);
  border-color: #f5b7b1;
}

.mpg-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.mpg-pagination__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #4a4a4a;
  border-radius: 8px;
  background: #fff;
  color: #111;
  text-decoration: none;
  font-size: 16px;
  line-height: 1;
}

.mpg-pagination__nav:hover {
  background: #f7f7f7;
}

.mpg-pagination__nav.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.mpg-pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #222;
  border-radius: 50%;
  background: #fff;
  color: #111;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}

.mpg-pagination__page:hover {
  background: #f7f7f7;
}

.mpg-pagination__page.is-active {
  background: var(--mpg-primary);
  border-color: var(--mpg-primary);
  color: #fff;
  font-weight: 600;
}

.mpg-pagination__ellipsis {
  padding: 0 2px;
  color: #111;
  letter-spacing: 1px;
  font-size: 14px;
  line-height: 36px;
}

.mpg-pagination__info {
  color: var(--mpg-text-muted);
  font-size: var(--mpg-font-size-sm);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--mpg-radius-pill);
  font-size: var(--mpg-font-size-xs);
  font-weight: var(--mpg-font-weight-bold);
  line-height: 1.2;
}

.badge-primary { background: var(--mpg-primary-light); color: #1e6f43; }
.badge-blue { background: var(--mpg-blue-light); color: #1a5276; }
.badge-danger { background: var(--mpg-danger-light); color: var(--mpg-danger-dark); }
.badge-warning { background: var(--mpg-warning-light); color: #7d6608; }
.badge-dark { background: #d5d8dc; color: var(--mpg-dark); }
.badge-stage-orange { background: #ffe8cc; color: #9a5b00; }
.badge-stage-green-soft { background: #e3f6e8; color: #1f7a3f; }
.badge-stage-green { background: #d1f0d8; color: #146c36; }
.badge-stage-red { background: #e74c3c; color: #fff; }
.badge-road-inspection { background: #f8c4d4; color: #9b1b4a; }

/* --------------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------------- */

.card,
.panel,
.section {
  background: var(--mpg-surface);
  border: 1px solid var(--mpg-border);
  border-radius: var(--mpg-radius-lg);
  box-shadow: var(--mpg-shadow-sm);
}

.card {
  padding: var(--mpg-space-4);
}

.panel,
.section {
  padding: var(--mpg-space-5);
}

.card-header,
.panel-header {
  margin-bottom: var(--mpg-space-4);
  padding-bottom: var(--mpg-space-3);
  border-bottom: 1px solid var(--mpg-border);
}

.card-title,
.panel-title {
  margin: 0;
  font-size: var(--mpg-font-size-lg);
}

.stat-label {
  color: var(--mpg-text-muted);
  font-size: var(--mpg-font-size-sm);
}

.stat-value {
  margin-top: var(--mpg-space-2);
  font-size: var(--mpg-font-size-2xl);
  font-weight: var(--mpg-font-weight-bold);
  color: var(--mpg-dark);
}

/* --------------------------------------------------------------------------
   Callout / note
   -------------------------------------------------------------------------- */

.note {
  margin-top: var(--mpg-space-4);
  padding: 10px 14px;
  border-radius: var(--mpg-radius-md);
  background: var(--mpg-bg);
  color: var(--mpg-text-muted);
  font-size: var(--mpg-font-size-sm);
  border-left: 4px solid var(--mpg-border-strong);
}

.note-primary { border-left-color: var(--mpg-primary); background: var(--mpg-primary-light); color: #1e6f43; }
.note-info { border-left-color: var(--mpg-blue); background: var(--mpg-blue-light); color: #1a5276; }
.note-warning { border-left-color: var(--mpg-warning); background: var(--mpg-warning-light); color: #7d6608; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--mpg-border);
  border-radius: var(--mpg-radius-md);
  background: var(--mpg-white);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--mpg-font-size-sm);
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--mpg-border);
}

.table th {
  background: var(--mpg-bg);
  color: var(--mpg-dark);
  font-weight: var(--mpg-font-weight-bold);
}

.table tbody tr:hover {
  background: rgba(39, 174, 96, 0.04);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--mpg-space-5);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--mpg-space-4);
}

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gap-2 { gap: var(--mpg-space-2); }
.gap-3 { gap: var(--mpg-space-3); }
.gap-4 { gap: var(--mpg-space-4); }

.divider {
  border: none;
  border-top: 1px solid var(--mpg-border);
  margin: var(--mpg-space-4) 0;
}

.bg-gradient {
  background: var(--mpg-gradient);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.list-export-dialog {
  border: none;
  border-radius: var(--mpg-radius-lg, 12px);
  padding: 0;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.list-export-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.list-export-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px 22px;
}

.list-export-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-export-dialog__title {
  margin: 0;
  font-size: 1.15rem;
}

.list-export-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--mpg-text-muted, #6b7280);
}

.list-export-dialog__toolbar,
.list-export-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.list-export-dialog__columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 14px;
  max-height: 50vh;
  overflow: auto;
  padding-right: 4px;
}

.list-export-dialog__column {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--mpg-border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
}

.list-export-dialog__column input {
  margin-top: 2px;
}

.ship-page__header-actions,
.sr-page__header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
