/**
 * Giao diện đăng nhập Hệ thống Quản lý Dữ liệu Lâm sản An Giang
 * Màu xanh chủ đạo: #006B3C
 * Hỗ trợ hiệu ứng kính (Glassmorphism), viền gương đậm,
 * Căn chỉnh logo & chữ đồng đều, ưu tiên hiển thị form đăng nhập trên di động.
 */

:root {
  --primary: #006B3C;
  --primary-dark: #004d2b;
  --primary-deep: #00361e;
  --primary-light: #008a4e;
  --primary-subtle: #e9f6ef;
  --primary-border: #b0dfc6;
  --primary-shadow: rgba(0, 107, 60, 0.28);

  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #94a3b8;
  --border-focus: #006B3C;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body.login-page {
  margin: 0;
  padding: 24px 16px;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-dark);
  background:
    radial-gradient(circle at 12% 18%, rgba(0, 138, 78, 0.38) 0%, transparent 40%),
    radial-gradient(circle at 88% 82%, rgba(0, 60, 33, 0.6) 0%, transparent 45%),
    linear-gradient(135deg, #004a29 0%, #006B3C 52%, #00331d 100%);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Khung bọc toàn bộ trang đăng nhập */
.login-container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

/* Card chính chia 2 cột với hiệu ứng gương (Glassmorphism) & viền đậm nét */
.login-card-wrapper {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 22px;
  overflow: hidden;
  border: 2.5px solid var(--primary);
  /* Viền gương đậm màu xanh chủ đạo #006B3C */
  box-shadow:
    0 25px 60px -15px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.45) inset,
    0 12px 30px rgba(0, 107, 60, 0.22);
  display: flex;
  flex-direction: row;
}

/* ========================================================
   CỘT TRÁI: THÔNG TIN ĐỀ TÀI & CÁC ĐƠN VỊ LIÊN QUAN
   ======================================================== */
.login-info-side {
  flex: 1.15;
  background: linear-gradient(165deg, rgba(0, 90, 50, 0.95) 0%, rgba(0, 107, 60, 0.93) 50%, rgba(0, 66, 36, 0.96) 100%);
  color: #ffffff;
  padding: 44px 38px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  order: 1;
}

/* Họa tiết trang trí mờ ở nền cột trái */
.login-info-side::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.login-info-side::after {
  content: "";
  position: absolute;
  bottom: -100px;
  left: -80px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 160, 90, 0.25) 0%, rgba(0, 160, 90, 0) 70%);
  pointer-events: none;
}

.info-header {
  position: relative;
  z-index: 2;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  /* Khoảng cách đều nhau tuyệt đối giữa huy hiệu đề tài, tên đề tài và chủ nhiệm */
}

.info-header-badge-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Huy hiệu Đề tài */
.badge-detai {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(254, 240, 138, 0.15);
  color: #fef08a;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(253, 224, 71, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  margin-bottom: 0 !important;
  /* Xóa margin thừa để gap phân chia đều */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  text-align: center;
  text-wrap: balance;
}

.badge-detai i {
  color: #fde047;
}

.badge-chunhiem {
  text-transform: none;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
  background: rgba(254, 240, 138, 0.2);
  color: #fff9c4;
  border-color: rgba(253, 224, 71, 0.5);
}

.badge-chunhiem i {
  color: #facc15;
}

/* Tên đề tài */
.project-title {
  color: #ffea79;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.5;
  margin: 0 !important;
  /* Xóa margin thừa để khoảng cách trên và dưới đều nhau */
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 234, 121, 0.25);
  letter-spacing: -0.2px;
  text-wrap: balance;
  word-break: normal;
}

/* Danh sách các đơn vị */
.org-list {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.org-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.13);
  border: 1.8px solid rgba(255, 255, 255, 0.32);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-height: 76px;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.org-item:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.48);
  transform: translateY(-1px);
}

/* Hộp chứa Logo đơn vị - Căn chỉnh kích thước đồng đều 96px cho tất cả các đơn vị */
.org-logo-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  flex: 0 0 96px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.6);
}

.org-logo-box img {
  max-height: 44px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  display: block;
}

/* Hộp 2 logo cho Đơn vị chủ trì (ĐHQG-HCM + AGU) - cùng kích thước 96px */
.org-logo-box.multi-logo {
  gap: 4px;
  padding: 4px 5px;
}

.org-logo-box.multi-logo img.vnu-logo {
  max-height: 28px;
  max-width: 44px;
}

.org-logo-box.multi-logo img.agu-logo {
  max-height: 38px;
  max-width: 38px;
}

.org-logo-box .logo-divider {
  width: 1px;
  height: 24px;
  background: #cbd5e1;
  margin: 0 2px;
  flex-shrink: 0;
}

.org-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.org-label {
  font-size: 0.74rem;
  font-weight: 800;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 3px;
}

.org-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fffbeb;
  line-height: 1.4;
  text-wrap: balance;
}

.info-footer {
  position: relative;
  z-index: 2;
  padding-top: 14px;
  border-top: 1px solid rgba(253, 224, 71, 0.3);
  font-size: 0.78rem;
  color: #fef08a;
  text-align: center;
  text-wrap: balance;
}

.info-footer i {
  color: #facc15;
}

/* ========================================================
   CỘT PHẢI: FORM ĐĂNG NHẬP
   ======================================================== */
.login-form-side {
  flex: 0.95;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 42px 36px 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  order: 2;
}

.form-header {
  margin-bottom: 18px;
  text-align: center;
}

.form-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--primary-border);
  margin-bottom: 8px;
}

.form-header-title {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 5px;
}

.form-header-subtitle {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-bottom: 0;
}

/* Custom Alert */
.custom-alert {
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  border-width: 1.5px;
}

/* Form Groups & Controls với viền đậm và hiệu ứng kính */
.form-group-item {
  margin-bottom: 15px;
  /* Khoảng cách đều đặn, cân đối */
}

.form-group-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-group-label i {
  color: var(--primary);
  margin-right: 4px;
}

.custom-input-group {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--border-color);
  /* Viền đậm hơn, rõ nét */
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.custom-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 107, 60, 0.2);
  background: #ffffff;
}

.input-addon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #64748b;
  font-size: 0.95rem;
  background: transparent;
  user-select: none;
}

.custom-input-group:focus-within .input-addon {
  color: var(--primary);
}

.custom-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 0.92rem;
  color: var(--text-dark);
  font-weight: 500;
  outline: none;
  width: 100%;
}

.custom-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* Nút ẩn/hiện mật khẩu */
.btn-toggle-eye {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 0 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  outline: none;
}

.btn-toggle-eye:hover {
  color: var(--primary);
}

/* Khối Captcha */
.captcha-container {
  display: flex;
  gap: 10px;
  align-items: center;
}

.captcha-input-wrap {
  flex: 1;
}

.captcha-input {
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
}

.captcha-image-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(241, 245, 249, 0.9);
  backdrop-filter: blur(8px);
  border: 2px solid var(--border-color);
  /* Viền đậm khớp với input */
  border-radius: 10px;
  padding: 4px 6px;
}

.captcha-image-box img {
  height: 38px;
  width: 110px;
  object-fit: cover;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.btn-refresh-captcha {
  border: 1.5px solid var(--primary-border);
  background: #ffffff;
  color: var(--primary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.btn-refresh-captcha:hover {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}

.btn-refresh-captcha i.spinning {
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* ========================================================
   NÚT ĐĂNG NHẬP & TRẠNG THÁI ĐANG XỬ LÝ
   ======================================================== */
.btn-submit-login {
  width: 100%;
  margin-top: 6px;
  padding: 10px 18px;
  border: none !important;
  border-radius: 10px;
  background: linear-gradient(135deg, #006B3C 0%, #004f2c 100%) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 5px 14px var(--primary-shadow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

.btn-submit-login:hover:not(:disabled):not(.is-processing) {
  background: linear-gradient(135deg, #007d46 0%, #005a33 100%) !important;
  box-shadow: 0 8px 22px rgba(0, 107, 60, 0.38);
  transform: translateY(-1.5px);
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.btn-submit-login:focus,
.btn-submit-login:focus-visible,
.btn-submit-login:active {
  background: linear-gradient(135deg, #005630 0%, #004225 100%) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(0, 107, 60, 0.35) !important;
}

/* Trạng thái đang xử lý / disabled: luôn giữ màu nền xanh đậm đặc trưng, chữ trắng rõ nét tuyệt đối */
.btn-submit-login:disabled,
.btn-submit-login.is-processing,
.btn-submit-login[aria-disabled="true"] {
  background: #004d2b !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  opacity: 1 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: 0 4px 14px rgba(0, 107, 60, 0.35) !important;
  border: none !important;
  outline: none !important;
}

.btn-submit-login.is-processing *,
.btn-submit-login:disabled * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Hiệu ứng loading spinner trắng sáng rõ ràng */
.btn-submit-login .spinner-border {
  width: 1.15rem;
  height: 1.15rem;
  border-width: 0.18em;
  color: #ffffff !important;
  border-color: #ffffff !important;
  border-right-color: transparent !important;
}

/* ========================================================
   3 CON VẬT 3D GẮN Ở GỐC FORM:
   - Cầy vòi hương (góc trái)
   - Voọc bạc Đông Dương (ở giữa 2 con)
   - Cá sấu nước ngọt (góc phải, quay vào)
   - Display absolute, hoàn toàn trong suốt, không nền trắng, không chữ
   ======================================================== */
.corner-animal-3d {
  position: absolute;
  bottom: 0;
  z-index: 5;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.corner-animal-3d.corner-civet {
  left: 8px;
  bottom: 0px;
}

.corner-animal-3d.center-langur {
  left: 50%;
  transform: translateX(-52%);
  bottom: 0px;
}

.corner-animal-3d.corner-croc {
  right: 8px;
  bottom: 0px;
}

.corner-animal-img {
  display: block;
  object-fit: contain;
  background: transparent !important;
  pointer-events: auto;
  cursor: pointer;
  /* Đổ bóng 3D chân thực tách lớp con vật nổi khối trên form */
  filter:
    drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35)) drop-shadow(0 2px 5px rgba(0, 75, 40, 0.25));
  transform: translateZ(16px);
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.32s ease;
  user-select: none;
}

/* Cầy vòi hương (trái) - tăng to lên */
.corner-civet .corner-animal-img {
  height: 145px;
  width: auto;
  max-width: 150px;
}

/* Voọc bạc Đông Dương (ở giữa) - tăng to lên */
.center-langur .corner-animal-img {
  height: 150px;
  width: auto;
  max-width: 150px;
}

/* Cá sấu nước ngọt (phải) - tăng to lên */
.corner-croc .corner-animal-img {
  height: 85px;
  width: auto;
  max-width: 185px;
}

/* Hiệu ứng rê chuột 3D nổi bật */
.corner-animal-3d:hover .corner-animal-img {
  transform: translateY(-6px) scale(1.08) translateZ(28px);
  filter:
    drop-shadow(0 16px 22px rgba(0, 0, 0, 0.42)) drop-shadow(0 4px 10px rgba(0, 107, 60, 0.35));
}

/* ========================================================
   RESPONSIVE (MOBILE & TABLET):
   Ưu tiên hiển thị FORM ĐĂNG NHẬP TRƯỚC trên điện thoại
   ======================================================== */
@media (max-width: 991.98px) {
  .login-card-wrapper {
    flex-direction: column;
    max-width: 580px;
    margin: 0 auto;
    border-radius: 20px;
  }

  /* Đưa form đăng nhập lên trước, tăng khoảng đệm đáy để 3 con vật to lên vừa đủ chiều rộng form mà không che nút đăng nhập */
  .login-form-side {
    order: 1 !important;
    padding: 30px 24px 150px !important;
    border-bottom: 2.5px solid rgba(0, 107, 60, 0.3);
    position: relative;
  }

  /* Nút đăng nhập luôn nổi lên trên, z-index cao và cách ly an toàn với các con vật */
  .btn-submit-login {
    position: relative;
    z-index: 10;
    margin-bottom: 8px;
  }

  /* Kích thước 3 con vật trên màn hình vừa / tablet (576px - 991px) */
  .corner-animal-3d {
    bottom: 0px;
    z-index: 5;
    pointer-events: none;
  }

  .corner-animal-3d.corner-civet {
    left: 8px;
    bottom: 0px;
  }

  .corner-animal-3d.center-langur {
    left: 50%;
    transform: translateX(-50%);
    bottom: 0px;
  }

  .corner-animal-3d.corner-croc {
    right: 8px;
    bottom: 0px;
  }

  .corner-civet .corner-animal-img {
    height: 98px;
    max-width: 110px;
  }

  .center-langur .corner-animal-img {
    height: 135px;
    max-width: 105px;
  }

  .corner-croc .corner-animal-img {
    height: 58px;
    max-width: 155px;
  }

  .corner-animal-3d:hover .corner-animal-img {
    transform: none;
  }

  /* Đưa thông tin đề tài xuống sau */
  .login-info-side {
    order: 2 !important;
    padding: 32px 24px 28px;
  }

  .project-title {
    font-size: 1.15rem;
  }

  .org-list {
    margin-bottom: 16px;
  }
}

@media (max-width: 575.98px) {
  body.login-page {
    padding: 12px 10px;
  }

  /* Tăng padding-bottom lên 156px để 3 con vật to lên vừa đủ chiều rộng form mà hoàn toàn không chạm/che nút Đăng nhập */
  .login-form-side {
    padding: 22px 16px 156px !important;
  }

  /* Nút đăng nhập nổi bật, không bị che khuất */
  .btn-submit-login {
    position: relative;
    z-index: 10;
    margin-top: 8px;
    margin-bottom: 6px;
  }

  .form-header-title {
    font-size: 1.25rem;
  }

  .info-header {
    gap: 10px;
    margin-bottom: 16px;
  }

  .login-info-side {
    padding: 22px 16px 18px;
  }

  .badge-detai {
    font-size: 0.72rem;
    padding: 5px 12px;
    margin-bottom: 0 !important;
    text-wrap: balance;
  }

  .badge-chunhiem {
    font-size: 0.78rem;
    padding: 5px 12px;
    text-wrap: balance;
  }

  .project-title {
    font-size: 0.98rem;
    line-height: 1.45;
    padding: 0 2px;
    text-wrap: balance;
  }

  .org-item {
    padding: 8px 10px;
    gap: 10px;
    min-height: 70px;
  }

  .org-logo-box {
    height: 52px;
    width: 86px;
    min-width: 86px;
    max-width: 86px;
    flex: 0 0 86px;
    padding: 3px;
  }

  .org-logo-box img {
    max-height: 38px;
    max-width: 72px;
  }

  .org-logo-box.multi-logo img.vnu-logo {
    max-height: 24px;
    max-width: 38px;
  }

  .org-logo-box.multi-logo img.agu-logo {
    max-height: 34px;
    max-width: 34px;
  }

  .org-name {
    font-size: 0.8rem;
  }

  /* Giữ mã bảo vệ hiển thị trên 1 dòng với mã hình bên phải trên điện thoại */
  .captcha-container {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .captcha-input-wrap {
    flex: 1;
    min-width: 0;
  }

  .captcha-input {
    letter-spacing: 2px;
    padding: 10px 6px;
    font-size: 0.92rem;
  }

  .captcha-image-box {
    flex-shrink: 0;
    padding: 3px 5px;
    gap: 4px;
  }

  .captcha-image-box img {
    width: 92px;
    height: 38px;
    object-fit: cover;
  }

  .btn-refresh-captcha {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  /* 3 con vật 3D ở gốc form trên điện thoại - to lên vừa đủ chiều rộng form, không che nút Đăng nhập */
  .corner-animal-3d {
    bottom: 0px;
    z-index: 5;
    pointer-events: none;
  }

  .corner-animal-3d.corner-civet {
    left: 0px;
    bottom: 0px;
  }

  .corner-animal-3d.center-langur {
    left: 50%;
    transform: translateX(-50%);
    bottom: 0px;
  }

  .corner-animal-3d.corner-croc {
    right: 0px;
    bottom: 0px;
  }

  .corner-civet .corner-animal-img {
    height: 102px;
    max-width: 100px;
  }

  .center-langur .corner-animal-img {
    height: 138px;
    max-width: 110px;
  }

  .corner-croc .corner-animal-img {
    height: 64px;
    max-width: 150px;
  }

  .corner-animal-3d:hover .corner-animal-img {
    transform: none;
  }
}