/* ==========================================================================
   Giao diện dùng chung cho mọi trang: cổng đăng nhập, tên người đang đăng
   nhập, cửa sổ Kho bảng giá. Nạp SAU style.css của từng trang.
   ========================================================================== */

/* Chưa xác định đăng nhập xong thì ẩn nội dung trang, tránh nháy form trước khi hiện cổng đăng nhập */
body.vtm-auth-pending .container,
body.vtm-auth-pending #adminContent { display: none !important; }

/* ===== Màn hình "Sắp ra mắt" (chế độ kiểm thử trước khi phát hành) ===== */
body.vtm-preview-locked #modal,
body.vtm-preview-locked .app-topbar,
body.vtm-preview-locked .admin-topbar { display: none !important; }
#loginGate:has(#comingSoon) { background: #8b1e23; }
#loginGate .soon-box {
  width: 460px; max-width: calc(100vw - 32px); box-sizing: border-box;
  text-align: center; color: #fff;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
#loginGate .soon-brand { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; opacity: 0.75; }
#loginGate .soon-box h1 { font-size: 34px; margin: 10px 0 18px; font-weight: 700; }
#loginGate .soon-title {
  display: inline-block; margin: 0 0 16px; padding: 6px 18px;
  border: 1px solid rgba(255,255,255,0.55); border-radius: 999px;
  font-size: 15px; font-weight: 600;
}
#loginGate .soon-sub { font-size: 14.5px; line-height: 1.6; margin: 0 0 34px; opacity: 0.85; }
#loginGate .soon-tester { font-size: 12.5px; color: rgba(255,255,255,0.6); text-decoration: none; }
#loginGate .soon-tester:hover { color: #fff; text-decoration: underline; }
#loginGate .soon-form { width: 280px; margin: 0 auto; }
#loginGate .soon-form input { border-color: transparent; }
#loginGate .soon-form button { background: #fff; color: #8b1e23; font-weight: 700; }
#loginGate .soon-form button:hover { background: #f7e9e9; }
#loginGate .soon-form .gate-error { color: #ffd9d9; }

/* ===== Cổng đăng nhập ===== */
#loginGate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #f3f5f8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Pro Display', Arial, sans-serif;
}
#loginGate .gate-box {
  background: #fff;
  padding: 32px 36px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  width: 320px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  text-align: center;
}
#loginGate h2 { margin-top: 0; font-size: 18px; color: #2c3e50; }
#loginGate input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 10px;
}
#loginGate select:focus { outline: none; border-color: #8b1e23; }
#loginGate select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 10px;
  background: #fff;
  color: #2c3e50;
}
#loginGate input:focus { outline: none; border-color: #8b1e23; box-shadow: 0 0 0 3px rgba(139,30,35,0.12); }
#loginGate button {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #8b1e23;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
#loginGate button:hover { background: #6c1519; }
#loginGate button:disabled { opacity: 0.6; cursor: wait; }
#loginGate button.gate-secondary { background: #eef2f6; color: #2c3e50; }
#loginGate .gate-note { font-size: 12.5px; color: #667; text-align: left; line-height: 1.5; }
.gate-error { color: #e74c3c; font-size: 13px; margin-top: 10px; min-height: 16px; line-height: 1.4; }
#loginGate .gate-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12.5px;
}
#loginGate .gate-links a { color: #8b1e23; text-decoration: none; }
#loginGate .gate-links a:hover { text-decoration: underline; }
#loginGate .gate-emergency-contact {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eceef2;
  font-size: 12px;
  color: #8a8f99;
}

/* ===== Người đang đăng nhập (góc trên khung nhập liệu) ===== */
#userBadge {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 12.5px;
}
#userBadge .user-name { font-weight: 600; color: #2c3e50; }
#userBadge .user-showroom { font-weight: 400; color: #778; }
#userBadge .user-link { color: #2196F3; text-decoration: none; white-space: nowrap; }
#userBadge .user-link:hover { text-decoration: underline; }

/* Form nhỏ trong hộp thoại (VD Đổi mật khẩu) */
#confirmModal .vtm-form input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}

/* ===== Cửa sổ Kho bảng giá ===== */
:is(#fileBrowserModal, #originModal, #accountModal) {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
:is(#fileBrowserModal, #originModal, #accountModal) .modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  width: min(820px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  box-sizing: border-box;
}
:is(#fileBrowserModal, #originModal, #accountModal) .fb-head { display: flex; align-items: center; justify-content: space-between; }
:is(#fileBrowserModal, #originModal, #accountModal) h3 { margin: 0; font-size: 17px; color: #2c3e50; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-close {
  border: 1px solid #e5ddd8; background: #fff; border-radius: 8px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; color: #4a403e; cursor: pointer; white-space: nowrap;
}
:is(#fileBrowserModal, #originModal, #accountModal) .fb-close:hover { background: #f4eeec; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-search {
  margin: 12px 0 6px;
  padding: 9px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 13px;
}
:is(#fileBrowserModal, #originModal, #accountModal) .fb-status { font-size: 12px; color: #667; margin-bottom: 8px; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table-wrap { overflow: auto; flex: 1; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table th,
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table td { border-bottom: 1px solid #eceef2; padding: 7px 8px; text-align: left; vertical-align: top; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table th { background: #f4f7fa; position: sticky; top: 0; color: #2c3e50; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-actions { white-space: nowrap; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-actions a { color: #2196F3; text-decoration: none; margin-right: 10px; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-actions a:hover { text-decoration: underline; }

/* ===== Ô thông báo (kiểu ô chat) — thay cho thông báo xanh/đỏ tự mất ===== */
#notifyPanel {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px solid #e5ddd8;
  border-radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 12.5px;
  color: #2a2222;
  text-align: left;
}
#notifyPanel .n-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 1px solid #f0ebe8;
  font-size: 11.5px;
  font-weight: 600;
  color: #7b706d;
}
#notifyPanel .n-clear { color: #9a8f8b; font-weight: 400; text-decoration: none; }
#notifyPanel .n-clear:hover { color: #8b1e23; text-decoration: underline; }
#notifyPanel .n-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 78px;
  overflow-y: auto;
  scrollbar-width: thin;
}
#notifyPanel .n-list li { padding: 3px 10px 3px 8px; line-height: 1.4; border-left: 3px solid transparent; }
#notifyPanel .n-list li.n-ok { border-left-color: #2e7d32; }
#notifyPanel .n-list li.n-error { border-left-color: #c0392b; color: #b3261e; }
#notifyPanel .n-list li.n-empty { color: #aaa09c; }
#notifyPanel .n-list li.n-new { animation: vtmNotifyFlash 2s ease-out; }
#notifyPanel .n-time { color: #9a8f8b; margin-right: 6px; font-variant-numeric: tabular-nums; }
@keyframes vtmNotifyFlash { from { background: #fbeec4; } to { background: transparent; } }

/* Trang không có cột nhập liệu (VD Quản trị): ô thông báo nổi ở góc dưới bên phải */
#notifyPanel.floating {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 340px;
  z-index: 9000;
  box-shadow: 0 8px 24px rgba(40, 20, 20, 0.18);
}
#notifyPanel.floating .n-list { max-height: 180px; }

/* ===== Khung Báo lỗi / Góp ý (ẩn danh) ===== */
#confirmModal .feedback-form { width: 460px; max-width: calc(100vw - 32px); text-align: left; }
#confirmModal .feedback-form h3 { text-align: center; }
.feedback-form .feedback-anon { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 12.5px; color: #4a5a4a; background: #eef7ee; border-radius: 8px; padding: 8px 10px; cursor: pointer; line-height: 1.45; }
#confirmModal .feedback-form .feedback-anon input { display: inline; width: auto; margin: 2px 0 0; }
.feedback-form .feedback-kind { display: flex; gap: 18px; margin-bottom: 8px; font-size: 13.5px; }
.feedback-form .feedback-kind label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#confirmModal .feedback-form .feedback-kind input { display: inline; width: auto; margin: 0; }
#confirmModal .feedback-form textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
}

/* Ảnh đính kèm góp ý */
.feedback-form .feedback-images { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.feedback-form .feedback-thumbs { display: flex; gap: 8px; }
.feedback-form .feedback-thumb { position: relative; width: 84px; height: 64px; border: 1px solid #d7dbe0; border-radius: 6px; overflow: hidden; background: #f6f6f6; }
.feedback-form .feedback-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#confirmModal .feedback-form .feedback-thumb button {
  position: absolute; right: 2px; top: 2px; padding: 1px 6px; font-size: 11px;
  background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 4px;
}
#confirmModal .feedback-form .feedback-add { padding: 7px 12px; border: 1px dashed #8b1e23; background: #f7e9e9; color: #8b1e23; font-weight: 600; }
.feedback-form .feedback-hint { flex-basis: 100%; font-size: 11.5px; color: #8a8f99; }
/* Ô chọn file gốc của trình duyệt luôn ẩn — dùng nút "Thêm ảnh" thay thế */
#confirmModal .feedback-form input[type=file] { display: none; }

/* Kho bảng giá: bấm tiêu đề cột để sắp xếp A-Z / Z-A */
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table th.fb-sort { cursor: pointer; user-select: none; white-space: nowrap; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table th.fb-sort:hover { color: #8b1e23; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-table th.fb-sort.active { color: #8b1e23; }
:is(#fileBrowserModal, #originModal, #accountModal) .fb-dir { font-weight: 400; font-size: 11.5px; }

/* Tra cứu xuất xứ */
#originModal .origin-missing { color: #aaa09c; font-style: italic; }
#originModal .origin-coo { font-weight: 600; }
#originModal .fb-table td.origin-code { white-space: nowrap; font-weight: 600; }
.feedback-form .feedback-contact { margin-top: 10px; font-size: 12.5px; color: #7b706d; line-height: 1.5; }
.feedback-form .feedback-contact a { color: #8b1e23; }

/* Tra cứu xuất xứ: mỗi dòng 1 hàng, tên dài cắt bằng "..." (rê chuột xem đủ tên) */
#originModal .modal-content { width: min(1040px, 95vw); }
#originModal .fb-table { table-layout: fixed; }
#originModal .fb-table th,
#originModal .fb-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#originModal col.c-code { width: 130px; }
#originModal col.c-brand { width: 130px; }
#originModal col.c-coo { width: 110px; }
#originModal col.c-war { width: 90px; }
#originModal col.c-act { width: 112px; }

/* ===== Tài khoản của tôi ===== */
#userBadge button.user-name {
  padding: 6px 12px; margin: 0; border-radius: 8px;
  border: 1px solid #e3c9c9; background: #f7e9e9; color: #8b1e23;
  font: inherit; font-weight: 700; cursor: pointer;
}
#userBadge button.user-name .user-showroom { color: #9a6b6d; font-weight: 500; }
#userBadge button.user-name:hover { background: #8b1e23; border-color: #8b1e23; color: #fff; }
#userBadge button.user-name:hover .user-showroom { color: #f3dcdc; }
#accountModal .modal-content { width: min(760px, 94vw); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
#accountModal .acc-head-actions { display: flex; gap: 8px; align-items: center; }
#accountModal .acc-pw-toggle {
  border: 1px solid #e3c9c9; background: #f7e9e9; color: #8b1e23; font: inherit; font-size: 13px;
  font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
#accountModal .acc-pw-toggle:hover { background: #8b1e23; border-color: #8b1e23; color: #fff; }
#accountModal .acc-pw {
  display: grid; grid-template-columns: repeat(3, 1fr) auto auto; gap: 8px; align-items: center;
  margin: 12px 0 0; padding: 12px; border: 1px solid #e5ddd8; border-radius: 8px; background: #fbf8f7;
}
#accountModal .acc-pw[hidden] { display: none; }
#accountModal .acc-pw input:not([hidden]) {
  min-width: 0; padding: 8px 10px; border: 1px solid #d9cfcb; border-radius: 7px; font: inherit; font-size: 13px;
}
#accountModal .acc-pw input:focus { outline: none; border-color: #8b1e23; box-shadow: 0 0 0 3px rgba(139,30,35,0.12); }
#accountModal .acc-pw button {
  padding: 8px 14px; border-radius: 7px; border: 1px solid #8b1e23; background: #8b1e23; color: #fff;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#accountModal .acc-pw button:hover { background: #6c1519; }
#accountModal .acc-pw button:disabled { opacity: 0.6; cursor: wait; }
#accountModal .acc-pw .acc-pw-cancel { background: #fff; color: #5a4f4c; border-color: #d9cfcb; }
#accountModal .acc-pw .acc-pw-cancel:hover { background: #f4eeec; }
#accountModal .acc-pw .gate-error { grid-column: 1 / -1; margin-top: 0; min-height: 0; }
#accountModal .acc-pw .gate-error:empty { display: none; }
#accountModal .acc-info { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0 6px; }
#accountModal .acc-info div { background: #f7f2f0; border-radius: 8px; padding: 8px 10px; min-width: 0; }
#accountModal .acc-info span { display: block; font-size: 11.5px; color: #7b706d; }
#accountModal .acc-info b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#accountModal .acc-body { overflow-y: auto; flex: 1; padding-right: 4px; }
#accountModal h4 { margin: 14px 0 6px; font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; color: #8b1e23; }
#accountModal .acc-status { font-size: 13px; color: #5a4f4c; margin-bottom: 8px; }
#accountModal .acc-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
#accountModal .acc-tile { border: 1px solid #e5ddd8; border-radius: 8px; padding: 8px 10px; }
#accountModal .acc-tile b { display: block; font-size: 20px; }
#accountModal .acc-tile span { font-size: 11.5px; color: #7b706d; }
#accountModal .acc-tile.good b { color: #2e7d32; }
#accountModal .acc-tile.bad b { color: #b3261e; }
#accountModal .acc-issue, #accountModal .acc-fb { border: 1px solid #efe6e3; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
#accountModal .acc-issue-head, #accountModal .acc-fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
#accountModal .acc-issue-head a { margin-left: auto; color: #8b1e23; font-weight: 600; }
#accountModal .acc-tag { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #fbeeed; color: #b3261e; font-weight: 600; }
#accountModal .acc-issue-detail { font-size: 12.5px; color: #6b605d; margin-top: 4px; line-height: 1.5; }
#accountModal .acc-fb-head { font-size: 12px; color: #7b706d; }
#accountModal .acc-fb-kind { font-weight: 700; color: #2a2222; }
#accountModal .acc-fb-state { margin-left: auto; font-weight: 700; color: #b8720a; }
#accountModal .acc-fb-state.done { color: #2e7d32; }
#accountModal .acc-fb-text { font-size: 13px; margin-top: 4px; white-space: pre-wrap; line-height: 1.5; }
#accountModal .acc-note { font-size: 12px; color: #9a8f8b; margin: 6px 0 0; }
#accountModal .acc-note a { color: #8b1e23; }
#accountModal .modal-content { text-align: left; }
#accountModal .acc-info div { text-align: left; }

/* Level thi đua: ô nhỏ chung hàng thông tin tài khoản (rê chuột xem chi tiết) */
#accountModal .acc-level { cursor: help; }
