/* ══════════════════════════════════════════════════════════════════
   LONG THÀNH GROUP — DESIGN SYSTEM
   Ý tưởng: bảng điều phối vận đơn (dispatch console). Phối màu và kiểu
   chữ lấy cảm hứng từ tem/nhãn vận chuyển: đường "xé phiếu" đục lỗ làm
   dấu ấn xuyên suốt, mã đơn/mã KH luôn hiển thị dạng monospace như mã
   vận đơn thật.
   ══════════════════════════════════════════════════════════════════ */

/* Font được nạp qua thẻ <link> trong index.html (nhanh hơn @import) */

:root {
  --ink:          #1C1917;
  --paper:        #EDEFF1;
  --surface:      #FFFFFF;
  --surface-alt:  #F5F6F7;
  --accent:       #E8452C;
  --accent-dark:  #C4381F;
  --accent-soft:  #FCE7E1;
  --success:      #1F7A4D;
  --success-soft: #E4F3EA;
  --danger:       #B3261E;
  --danger-soft:  #FBEAE8;
  --muted:        #6B7280;
  --muted-soft:   #9C9890;
  --border:       #E1E3E6;

  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 3px rgba(28,25,23,.07);
  --shadow-md: 0 8px 28px rgba(28,25,23,.14);

  --font-display: 'Archivo', sans-serif;
  --font-body:    'Be Vietnam Pro', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--accent-dark); }

::selection { background: var(--accent-soft); color: var(--accent-dark); }

/* Focus rõ ràng cho bàn phím — không loại bỏ, chỉ tinh chỉnh */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

[hidden] { display: none !important; }

/* ── Dấu ấn thị giác: đường "xé phiếu" đục lỗ ─────────────────────── */
.tear-line {
  height: 10px;
  margin: 2px 0 18px;
  background-image: radial-gradient(circle 1.6px, var(--border) 1.6px, transparent 1.7px);
  background-size: 12px 10px;
  background-position: 0 center;
  background-repeat: repeat-x;
}

/* ══════════════════════════════════════════════════════════════════
   MÀN HÌNH ĐĂNG NHẬP
   ══════════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(232,69,44,.14), transparent 45%),
    var(--ink);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-mark {
  width: 44px; height: 44px;
  border-radius: 10px;
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}

.login-card p.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 26px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 4px;
}

.login-links {
  margin-top: 18px;
  text-align: center;
}
.login-links button {
  background: none; border: none; color: var(--muted);
  font-size: 12.5px; cursor: pointer; text-decoration: underline;
  font-family: var(--font-body);
}
.login-links button:hover { color: var(--ink); }

/* ══════════════════════════════════════════════════════════════════
   KHUNG ỨNG DỤNG CHÍNH
   ══════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: #fff;
  padding: 14px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.brand-text .title {
  font-family: var(--font-display); font-weight: 800; font-size: 16px;
  letter-spacing: 0.01em; line-height: 1.2;
}
.brand-text .subtitle {
  font-size: 10.5px; color: var(--muted-soft);
  letter-spacing: 0.08em; text-transform: uppercase;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-pill {
  font-size: 12.5px; color: #D8D5CE;
  padding: 6px 12px; border: 1px solid #3A3634; border-radius: 99px;
}

.tabbar {
  display: flex; flex-wrap: wrap;
  background: #262220;
  padding: 0 16px;
  overflow-x: auto;
}
.tab-btn {
  font-family: var(--font-display);
  font-weight: 700; font-size: 12px; letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #B0ACA4; background: transparent; border: none;
  padding: 13px 15px 11px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color .12s ease;
}
.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #fff; border-bottom-color: var(--accent); }

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.tab-panel h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}
.tab-panel > .panel-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

/* ══════════════════════════════════════════════════════════════════
   THẺ / CARD
   ══════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 2px;
}
.card h3 {
  font-family: var(--font-display);
  font-weight: 800; font-size: 14px;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink); margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.card h3 .step-no {
  background: var(--ink); color: #fff;
  width: 20px; height: 20px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.card p.card-desc { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/* ══════════════════════════════════════════════════════════════════
   FORM
   ══════════════════════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
}
.form-grid.cols-1 { grid-template-columns: 1fr; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.field label .req { color: var(--accent); }

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}
.field.span-2 { grid-column: 1 / -1; }

.field input[type="file"] {
  font-size: 12.5px;
  padding: 6px 0;
}
.field input[type="file"]::file-selector-button {
  font-family: var(--font-display);
  font-weight: 700; font-size: 11.5px; letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 8px 14px; margin-right: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-alt); cursor: pointer;
}
.field input[type="file"]::file-selector-button:hover { background: var(--border); }

.hint { font-size: 11.5px; color: var(--muted-soft); }

/* ══════════════════════════════════════════════════════════════════
   NÚT BẤM
   ══════════════════════════════════════════════════════════════════ */
.btn {
  font-family: var(--font-display);
  font-weight: 700; font-size: 12.5px; letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, transform .05s ease, border-color .12s ease;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #17603C; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8F1E18; }

.btn-neutral { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-neutral:hover:not(:disabled) { background: var(--surface-alt); }

.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-alt); }

.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ══════════════════════════════════════════════════════════════════
   MÃ ĐƠN / MÃ KH — hiển thị kiểu mã vận đơn
   ══════════════════════════════════════════════════════════════════ */
.code-chip {
  font-family: var(--font-mono);
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  display: inline-block;
}

/* ══════════════════════════════════════════════════════════════════
   BẢNG DỮ LIỆU
   ══════════════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--surface-alt);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr:hover td { background: var(--surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .empty-row td {
  text-align: center; color: var(--muted); padding: 28px; font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   TIẾN TRÌNH (job progress) — dùng cho tách file / gửi email hàng loạt
   ══════════════════════════════════════════════════════════════════ */
.progress-track {
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: 12px 0 4px;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width .3s ease;
}
.progress-label {
  font-size: 11.5px; color: var(--muted); font-family: var(--font-mono);
}

.log-console {
  background: #17140F;
  color: #D8D5CE;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 10px;
}
.log-console:empty::before {
  content: "Chưa có hoạt động nào.";
  color: #6B6862;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   TRẠNG THÁI / THẺ NHỎ
   ══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-muted   { background: var(--surface-alt); color: var(--muted); }

.home-hero {
  text-align: center;
  max-width: 760px;
  margin: 24px auto 0;
}
.home-hero h2 { font-size: 26px; }
.home-hero .panel-subtitle { margin-bottom: 0; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 32px 0 20px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.feature-icon { font-size: 28px; margin-bottom: 8px; }
.feature-title {
  font-family: var(--font-display); font-weight: 800; font-size: 13.5px;
  color: var(--ink); margin-bottom: 4px;
}
.feature-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }

.home-datetime {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--muted-soft);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   ẢNH CCCD / LIGHTBOX
   ══════════════════════════════════════════════════════════════════ */
.photo-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  height: 190px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
  color: var(--muted-soft);
  font-size: 12.5px;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(23,20,15,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000; cursor: zoom-out;
  padding: 30px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-md); }

/* ══════════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 4000;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 13px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-md);
  min-width: 260px; max-width: 360px;
  animation: toastIn .18s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23,20,15,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 2500; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius-md);
  padding: 28px 26px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-md);
}
.modal h3 {
  font-family: var(--font-display); font-weight: 800; font-size: 16px;
  margin: 0 0 16px;
}

/* ══════════════════════════════════════════════════════════════════
   TIỆN ÍCH BỐ CỤC
   ══════════════════════════════════════════════════════════════════ */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }
.section-label {
  font-family: var(--font-display); font-weight: 800; font-size: 12px;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  margin: 20px 0 2px;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .content { padding: 20px 14px 50px; }
}
