/* ==========================================================================
   Giao diện VNCID (đăng nhập SSO), nằm ở theme vinacontrol và dùng ở cả hai môi trường.
   Xuất phát từ nền sáng, thẻ trắng, token Tập đoàn, khối LoginForm của vhkit; tệp này chỉ thêm:
   logo ô vuông xanh + tên VNCID, nút đăng nhập nhanh có icon, màn xác thực lại.
   Tên tệp có số bản (vncid-N.css): trình duyệt giữ tài nguyên theme tới 30 ngày cùng URL;
   đổi theme thì tăng N và sửa styles= trong theme.properties.
   ========================================================================== */

/* --- Khung: lề hai bên 16px ở điện thoại, thẻ không dính mép; tiêu đề thẻ sát đầu thẻ --- */
.pf-v5-c-login__container { padding-left: 16px !important; padding-right: 16px !important; }
.pf-v5-c-login__main-header, .pf-v5-c-login__main-body { padding-top: 0 !important; }
.pf-v5-c-login__main-header { padding-bottom: 0 !important; margin: 0 !important; }

/* --- Đầu trang: logo ô vuông xanh 40px (brand/ICONS.md), tên, mô tả --- */
#kc-header-wrapper, .login-pf-brand {
  width: auto !important;
  height: auto !important;
  margin: 0 auto !important;
  padding-top: 52px !important;
  background: url('../img/vncid-logo.svg') no-repeat top center !important;
  background-size: 40px 40px !important;
  text-indent: 0 !important;
  overflow: visible !important;
  color: var(--vnc-foreground) !important;
}
.vnc-brand-name { display: block; font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--vnc-foreground); }
.vnc-brand-desc { display: block; font-size: 14px; font-weight: 400; margin-top: 2px; color: var(--vnc-muted-foreground); }

/* --- Ô mật khẩu: phần tử helper của Keycloak không có nội dung ở bản thật; margin:0 giữ bố cục như khi có chữ «Quên mật khẩu?».
       Chữ «Quên mật khẩu?» nằm ở tệp riêng của môi trường thử (V5 đợt VNCID; bản thật ẩn đến đợt 2). --- */
.pf-v5-c-form__group:has(> .pf-v5-c-input-group #password) .pf-v5-c-form__helper-text { margin: 0; }

/* --- Đăng nhập nhanh: dòng «hoặc», nút viền trọn chiều ngang, có icon vân tay (cùng icon trang tài khoản VNCID) --- */
#authenticateWebAuthnButton, #authenticateWebAuthnButton:hover {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto !important;
  box-sizing: border-box;
  position: relative;
  margin: 44px 0 0 0 !important;
  padding: 10px 16px !important;
  background: #ffffff !important;
  color: var(--vnc-foreground) !important;
  border: 1px solid var(--vnc-border) !important;
  border-radius: 8px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1.4;
  white-space: nowrap;
  text-decoration: none !important;
}
#authenticateWebAuthnButton:hover { background: var(--vnc-primary-soft) !important; border-color: var(--vnc-primary) !important; }
/* dòng «hoặc» phía trên nút: hai vạch hai bên chữ */
#authenticateWebAuthnButton.pf-m-secondary::after, #authenticateWebAuthnButton::after {
  display: block !important;
  border: none !important;
  inset: auto;
  content: "hoặc";
  position: absolute;
  left: 0 !important; right: 0 !important; top: -32px !important; bottom: auto !important;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  color: var(--vnc-muted-foreground);
  background:
    linear-gradient(var(--vnc-border), var(--vnc-border)) left center / calc(50% - 24px) 1px no-repeat,
    linear-gradient(var(--vnc-border), var(--vnc-border)) right center / calc(50% - 24px) 1px no-repeat;
}
#authenticateWebAuthnButton::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  background-color: var(--vnc-primary);
  -webkit-mask: var(--vnc-fingerprint) center / contain no-repeat;
  mask: var(--vnc-fingerprint) center / contain no-repeat;
}
:root {
  --vnc-fingerprint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4'/%3E%3Cpath d='M14 13.12c0 2.38 0 6.38-1 8.88'/%3E%3Cpath d='M17.29 21.02c.12-.6.43-2.3.5-3.02'/%3E%3Cpath d='M2 12a10 10 0 0 1 18-6'/%3E%3Cpath d='M2 16h.01'/%3E%3Cpath d='M21.8 16c.2-2 .131-5.354 0-6'/%3E%3Cpath d='M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2'/%3E%3Cpath d='M8.65 22c.21-.66.45-1.32.57-2'/%3E%3Cpath d='M9 6.8a6 6 0 0 1 9 5.2v2'/%3E%3C/svg%3E");
}

/* --- «Cài đăng nhập nhanh» dưới nút «Đăng nhập nhanh» (V9): chữ nhỏ kiểu «Quên mật khẩu?», khối giữa, vùng bấm cao 44px --- */
.vnc-install-link, .vnc-install-link:hover, .vnc-install-link:focus {
  display: block;
  box-sizing: border-box;
  margin-top: 12px;
  padding: 12px 0;
  min-height: 44px;
  line-height: 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--vnc-primary) !important;
  text-decoration: none;
  cursor: pointer;
}
.vnc-install-link:hover, .vnc-install-link:focus { text-decoration: underline; }

/* --- Màn xác thực lại (đang có phiên, app đòi nhập lại): mã hiện đủ, trọn hàng; lối đổi tài khoản là link chữ ngắn dưới ô --- */
.pf-v5-c-input-group:has(#kc-attempted-username) { display: flex; flex-wrap: wrap; }
.pf-v5-c-input-group:has(#kc-attempted-username) > .pf-m-fill { flex: 1 1 100%; min-width: 0; }
#kc-attempted-username {
  width: 100%;
  box-sizing: border-box;
  background-color: var(--vnc-background) !important;
  color: var(--vnc-foreground) !important;
  text-overflow: clip;
}
.pf-v5-c-input-group:has(#kc-attempted-username) > .pf-v5-c-input-group__item:not(.pf-m-fill) { flex: 1 1 100%; margin: 0; }
#reset-login, #reset-login:hover {
  display: block;
  margin: 6px 0 16px 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  color: var(--vnc-primary) !important;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
}
#reset-login:hover { text-decoration: underline; }
#reset-login i { display: none; }
#reset-login .kc-tooltip-text { display: inline !important; position: static !important; visibility: visible !important; opacity: 1 !important; background: none !important; color: inherit !important; padding: 0 !important; box-shadow: none !important; transform: none !important; font: inherit !important; }

/* --- Thông báo thông tin / thành công --- */
.pf-v5-c-alert.pf-m-info, .pf-v5-c-alert.pf-m-success {
  border-radius: 8px !important;
  font-size: 14px !important;
  margin-bottom: 20px !important;
}
.pf-v5-c-alert.pf-m-info { background-color: var(--vnc-primary-soft) !important; border: 1px solid #cfe5d8 !important; color: var(--vnc-primary-hover) !important; }
.pf-v5-c-alert.pf-m-info .pf-v5-c-alert__title, .pf-v5-c-alert.pf-m-success .pf-v5-c-alert__title { color: inherit !important; font-weight: 500 !important; }

/* --- Bước tạo đăng nhập nhanh: ẩn ô «Đăng xuất khỏi các thiết bị khác» (ADR-004 mục 8, anh Hưng quyết 09/11/2026).
       Chỉ ẩn bằng CSS: hộp mặc định không chọn nên giá trị gửi lên vẫn rỗng (không đăng xuất thiết bị khác); realm và SPI không đổi.
       Bật lại: bỏ khối này, tăng số bản tệp (vncid-9.css). Phần tử vẫn có trong DOM và trong form (chỉ ẩn, không xoá). --- */
form#register #logout-sessions,
form#register label[for="logout-sessions"],
form#register #kc-form-options {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}
form#register div:has(> #kc-form-options) {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* --- Màn xác nhận xoá, tạo đăng nhập nhanh: văn bản và nút có khoảng thở --- */
#kc-delete-text { margin-bottom: 20px; line-height: 1.5; }
.pf-v5-c-login__main-body .pf-v5-c-form__actions { margin-top: 8px; gap: 12px; }

/* --- Ô nhập luôn 16px: iOS Safari tự phóng to trang khi chạm ô có cỡ chữ dưới 16px (anh Hưng báo 09/11/2026).
       Không dùng maximum-scale / user-scalable=no: người cần phóng to vẫn phóng được. --- */
html body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
html body .pf-v5-c-form-control > input,
html body input.form-control,
html body #kc-attempted-username,
html body select,
html body textarea {
  font-size: 16px !important;
}
/* Không tràn ngang ở 320px: khung, thẻ và nhóm ô nhập co theo chiều rộng */
html { overflow-x: hidden; }
.pf-v5-c-login__container, .pf-v5-c-login__main, .pf-v5-c-input-group, .pf-v5-c-input-group__item.pf-m-fill { min-width: 0; max-width: 100%; box-sizing: border-box; }
/* Hàng nút (tạo / xoá đăng nhập nhanh): xuống dòng khi hẹp, nút co theo chiều rộng, không đẩy trang tràn ngang ở 320px */
.pf-v5-c-login__main-body .pf-v5-c-form__actions { flex-wrap: wrap; }
.pf-v5-c-login__main-body .pf-v5-c-form__actions .pf-v5-c-button { white-space: normal; flex: 1 1 auto; min-width: 0; }
@media (max-width: 420px) { .pf-v5-c-login__main-body .pf-v5-c-form__actions .pf-v5-c-button { flex: 1 1 100%; } }
/* PatternFly đặt flex-wrap: nowrap !important trên hàng nút này (lớp pf-v5-u-flex-nowrap): ở màn hẹp xếp dọc, nút trọn chiều ngang */
@media (max-width: 420px) {
  .pf-v5-c-login__main-body .pf-v5-c-form__actions.pf-v5-u-flex-nowrap { flex-direction: column !important; align-items: stretch !important; }
  .pf-v5-c-login__main-body .pf-v5-c-form__actions form { width: 100%; }
}

/* --- Cặp nút (tạo/xoá đăng nhập nhanh, màn lỗi): một nút chính, nút Huỷ dạng outline BÊN TRÁI (DESIGN.md: button-outline, «nút huỷ bên trái»).
       Nút phụ của Keycloak là button[type=submit] nên bị luật nút chính ở login.css tô xanh đặc: ghi đè ở đây bằng độ đặc hiệu cao hơn. --- */
html body .pf-v5-c-login__main-body button.pf-m-secondary,
html body .pf-v5-c-login__main-body button.pf-m-secondary:hover,
html body #kc-decline, html body #kc-decline:hover, html body #cancelWebAuthnAIA, html body #cancelWebAuthnAIA:hover {
  background-color: #ffffff !important;
  color: var(--vnc-foreground) !important;
  border: 1px solid var(--vnc-border) !important;
  box-shadow: none !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
}
html body .pf-v5-c-login__main-body button.pf-m-secondary:hover, html body #kc-decline:hover, html body #cancelWebAuthnAIA:hover {
  background-color: var(--vnc-primary-soft) !important;
  border-color: var(--vnc-primary) !important;
}
/* Vòng focus chuẩn (ring-3, màu --ring #207d57 ở độ trong 50%), thay viền xanh dương của trình duyệt */
html body .pf-v5-c-login__main-body button:focus-visible, html body .pf-v5-c-login__main-body a:focus-visible,
html body #authenticateWebAuthnButton:focus-visible, html body .vnc-install-link:focus-visible, html body #reset-login:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(32, 125, 87, 0.5) !important;
}
/* Nút Huỷ (form lồng trong hàng nút) đứng bên trái; ở ≤420px hàng xếp dọc, nút chính ở trên */
.pf-v5-c-login__main-body .pf-v5-c-form__actions > form { order: -1; flex: 0 0 auto !important; width: auto !important; }
.pf-v5-c-login__main-body .pf-v5-c-form__actions > #registerWebAuthn, .pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-try-again { flex: 1 1 0; width: auto !important; min-width: 0; }
.pf-v5-c-login__main-body .pf-v5-c-form__actions > form .pf-v5-c-button { min-width: 96px; }
@media (max-width: 420px) {
  .pf-v5-c-login__main-body .pf-v5-c-form__actions > form { order: 0; flex: 1 1 100% !important; width: auto !important; }
}
/* Màn lỗi: Keycloak lồng form trong form nên trình duyệt bỏ form trong, nút Huỷ nằm thẳng trong hàng nút: cũng đứng bên trái */
.pf-v5-c-login__main-body .pf-v5-c-form__actions > #cancelWebAuthnAIA { order: -1; flex: 0 0 auto; width: auto !important; min-width: 96px; }
@media (max-width: 420px) {
  .pf-v5-c-login__main-body .pf-v5-c-form__actions > #cancelWebAuthnAIA { order: 0; flex: 0 0 auto; width: auto !important; }
  .pf-v5-c-login__main-body .pf-v5-c-form__actions > #registerWebAuthn, .pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-try-again { flex: 0 0 auto; width: auto !important; }
}
/* Vòng focus của nút phụ: luật nút phụ ở trên có id nên thắng vòng focus chung, đặt lại cùng độ đặc hiệu */
html body #cancelWebAuthnAIA:focus-visible, html body #kc-decline:focus-visible, html body .pf-v5-c-login__main-body button.pf-m-secondary:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(32, 125, 87, 0.5) !important;
}
/* Màn xác nhận xoá: «Không xoá» (nút huỷ) bên trái, «Xoá» là nút chính; ≤420px xếp dọc, nút chính ở trên */
.pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-decline { order: -1; flex: 0 0 auto; width: auto !important; min-width: 96px; }
.pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-accept { flex: 1 1 0; width: auto !important; min-width: 0; }
@media (max-width: 420px) {
  .pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-decline, .pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-accept { order: 0; flex: 0 0 auto; width: auto !important; }
  .pf-v5-c-login__main-body .pf-v5-c-form__actions > #kc-accept { order: -1; }
}

/* --- Màn cài đăng nhập nhanh (lô L07, 10/11/2026): dòng dưới tiêu đề nói việc cần làm; chữ thường, không đậm, không chiếm chỗ của nút --- */
/* Tiêu đề và dòng dưới xếp dọc, dòng dưới căn giữa dưới tiêu đề (ở màn rộng, đầu thẻ là hàng ngang làm chữ tiêu đề vỡ dòng) */
.pf-v5-c-login__main-header:has(> .vnc-cai-sub) { display: block !important; }
.vnc-cai-sub {
  margin: 8px 0 16px 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: #475467;
  text-align: center;
}

/* Ở chế độ cài (body.vnc-cai-mode, vncid-cai-4.js) liên kết «Cài đăng nhập nhanh» dưới nút tự trỏ vào chính nó: ẩn. Nút «Đăng nhập nhanh» và «hoặc» giữ nguyên. */
.vnc-cai-mode #vnc-install-link { display: none !important; }
