/* ============================================================
   GIAO DIỆN TRANG ĐĂNG NHẬP MỚI — VIỆT TÂM
   css/login.css — Thiết kế theo mẫu mau-may-tinh và mau-dien-thoai.
   Mọi class dùng tiền tố .lg-* để tránh xung đột với style.css.
   Hỗ trợ cả giao diện SÁNG (mặc định) và TỐI (body.dark-mode / không có .light-theme).
   ============================================================ */

/* ── BIẾN MÀU CHO TRANG ĐĂNG NHẬP ── */
:root {
  /* Giao diện sáng (mặc định cho trang đăng nhập theo ảnh mẫu) */
  --lg-bg: #f4f8fb;
  --lg-bg-pattern: #0284c7;
  --lg-card-bg: #ffffff;
  --lg-card-border: rgba(226, 232, 240, 0.8);
  --lg-card-shadow: 0 12px 36px -4px rgba(2, 132, 199, 0.08), 0 4px 16px -2px rgba(15, 23, 42, 0.04);
  --lg-title: #0f2744;
  --lg-subtitle: #627d98;
  --lg-input-bg: #ffffff;
  --lg-input-border: #cbd5e1;
  --lg-input-border-focus: #0284c7;
  --lg-input-text: #0f172a;
  --lg-input-placeholder: #94a3b8;
  --lg-input-icon: #0284c7;
  --lg-checkbox-border: #94a3b8;
  --lg-checkbox-bg-checked: #0284c7;
  --lg-checkbox-label: #1e293b;
  --lg-hint-text: #64748b;
  --lg-forgot-link: #0284c7;
  --lg-forgot-link-hover: #0369a1;
  --lg-btn-bg: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  --lg-btn-bg-hover: linear-gradient(90deg, #0369a1 0%, #0ea5e9 100%);
  --lg-btn-shadow: 0 8px 20px -4px rgba(2, 132, 199, 0.35);
  --lg-dept-bg: #e0f2fe;
  --lg-dept-icon: #0284c7;
  --lg-dept-label: #0f2744;
  --lg-dept-divider: #e2e8f0;
  --lg-copyright: #829ab1;
  --lg-svg-stroke: #bae6fd;
  --lg-svg-accent: #7dd3fc;
  --lg-focus-ring: rgba(2, 132, 199, 0.2);
}

/* Giao diện tối (khi body KHÔNG có class light-theme / light-mode) */
body:not(.light-theme):not(.light-mode) {
  --lg-bg: #090d16;
  --lg-bg-pattern: #0ea5e9;
  --lg-card-bg: #111827;
  --lg-card-border: rgba(255, 255, 255, 0.08);
  --lg-card-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
  --lg-title: #f8fafc;
  --lg-subtitle: #94a3b8;
  --lg-input-bg: #1f2937;
  --lg-input-border: #374151;
  --lg-input-border-focus: #38bdf8;
  --lg-input-text: #f9fafb;
  --lg-input-placeholder: #9ca3af;
  --lg-input-icon: #38bdf8;
  --lg-checkbox-border: #6b7280;
  --lg-checkbox-bg-checked: #0284c7;
  --lg-checkbox-label: #e2e8f0;
  --lg-hint-text: #94a3b8;
  --lg-forgot-link: #38bdf8;
  --lg-forgot-link-hover: #7dd3fc;
  --lg-btn-bg: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  --lg-btn-bg-hover: linear-gradient(90deg, #0369a1 0%, #0ea5e9 100%);
  --lg-btn-shadow: 0 8px 24px -4px rgba(2, 132, 199, 0.4);
  --lg-dept-bg: rgba(14, 165, 233, 0.12);
  --lg-dept-icon: #38bdf8;
  --lg-dept-label: #f1f5f9;
  --lg-dept-divider: rgba(255, 255, 255, 0.08);
  --lg-copyright: #64748b;
  --lg-svg-stroke: #1e3a5f;
  --lg-svg-accent: #2563eb;
  --lg-focus-ring: rgba(56, 189, 248, 0.25);
}

/* ── THIẾT LẬP NỀN TRANG ĐĂNG NHẬP ── */
body.lg-body, html {
  min-height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--lg-bg);
  color: var(--lg-input-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}

.lg-viewport {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 32px 16px;
  background-color: var(--lg-bg);
  overflow-x: hidden;
}

/* ── HOẠ TIẾT BÁNH RĂNG BẢN VẼ KỸ THUẬT (SVG BACKGROUND) ── */
.lg-bg-pattern {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.lg-gear-svg {
  position: absolute;
  stroke: var(--lg-svg-stroke);
  fill: none;
  stroke-width: 1.2;
}

/* Bánh răng góc trên bên trái */
.lg-gear-top-left {
  top: -80px;
  left: -80px;
  width: 420px;
  height: 420px;
  opacity: 0.85;
}

/* Bánh răng góc dưới bên phải */
.lg-gear-bottom-right {
  bottom: -90px;
  right: -90px;
  width: 460px;
  height: 460px;
  opacity: 0.85;
}

/* ── KHUNG CHỨA TRUNG TÂM ── */
.lg-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 470px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── LOGO VIỆT TÂM PHÍA TRÊN ── */
.lg-brand {
  margin-bottom: 22px;
  text-align: center;
}

.lg-brand-logo {
  width: 190px;
  max-width: 80vw;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.04));
}

/* Logo có chữ xám đậm trên nền trong suốt → trên nền tối chữ "CONSTRUCTION MECHANICAL" gần như biến mất, nên đặt tấm nền sáng bo tròn phía sau */
body:not(.light-theme):not(.light-mode) .lg-brand-logo {
  background: #f1f5f9;
  border-radius: 28px;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.5);
}

/* ── THẺ ĐĂNG NHẬP TRẮNG ── */
.lg-card {
  width: 100%;
  background: var(--lg-card-bg);
  border: 1px solid var(--lg-card-border);
  border-radius: 20px;
  box-shadow: var(--lg-card-shadow);
  box-sizing: border-box;
  padding: 36px 36px 32px;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.lg-card-header {
  text-align: center;
  margin-bottom: 24px;
}

.lg-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--lg-title);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.lg-subtitle {
  font-size: 14px;
  color: var(--lg-subtitle);
  margin: 0;
  font-weight: 400;
}

/* ── FORM & CÁC Ô NHẬP ── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lg-input-group {
  position: relative;
  width: 100%;
}

.lg-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--lg-input-icon);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lg-input-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lg-form-input {
  width: 100%;
  height: 48px;
  box-sizing: border-box;
  padding: 0 44px 0 44px;
  background-color: var(--lg-input-bg);
  border: 1.5px solid var(--lg-input-border);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--lg-input-text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.lg-form-input::placeholder {
  color: var(--lg-input-placeholder);
  opacity: 1;
}

.lg-form-input:focus {
  border-color: var(--lg-input-border-focus);
  box-shadow: 0 0 0 3.5px var(--lg-focus-ring);
}

/* Nút mắt hiện / ẩn mật khẩu */
.lg-pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  color: var(--lg-subtitle);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.lg-pwd-toggle:hover {
  color: var(--lg-input-icon);
  background-color: rgba(2, 132, 199, 0.08);
}

.lg-pwd-toggle:focus-visible {
  outline: 2px solid var(--lg-input-border-focus);
}

.lg-pwd-toggle svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Dòng gợi ý bên dưới ô tài khoản */
.login-id-hint {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--lg-hint-text);
  margin-top: -6px;
  margin-bottom: 2px;
  padding: 0 2px;
}

.login-kb-toggle {
  background: none;
  border: none;
  padding: 0 4px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--lg-forgot-link);
  text-decoration: underline;
  cursor: pointer;
  border-radius: 4px;
}

.login-kb-toggle:hover {
  color: var(--lg-forgot-link-hover);
}

.login-kb-toggle:focus-visible {
  outline: 2px solid var(--lg-input-border-focus);
}

/* ── HÀNG GHI NHỚ ĐĂNG NHẬP & QUÊN MẬT KHẨU ── */
.lg-options-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  margin-bottom: 4px;
}

.lg-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--lg-checkbox-label);
  cursor: pointer;
  user-select: none;
}

.lg-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.8px solid var(--lg-checkbox-border);
  border-radius: 5px;
  background-color: var(--lg-input-bg);
  cursor: pointer;
  margin: 0;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.lg-checkbox:checked {
  background-color: var(--lg-checkbox-bg-checked);
  border-color: var(--lg-checkbox-bg-checked);
}

.lg-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.lg-checkbox:focus-visible {
  outline: 2px solid var(--lg-input-border-focus);
  outline-offset: 2px;
}

.lg-forgot-btn {
  background: none;
  border: none;
  padding: 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--lg-forgot-link);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
  border-radius: 4px;
}

.lg-forgot-btn:hover {
  color: var(--lg-forgot-link-hover);
  text-decoration: underline;
}

.lg-forgot-btn:focus-visible {
  outline: 2px solid var(--lg-input-border-focus);
}

/* Dòng chú thích máy dùng chung */
.login-remember-hint {
  display: block;
  font-size: 11.5px;
  color: var(--lg-hint-text);
  margin-top: -8px;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ── NÚT ĐĂNG NHẬP ── */
.lg-submit-btn {
  width: 100%;
  height: 48px;
  background: var(--lg-btn-bg);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--lg-btn-shadow);
  transition: all 0.2s ease;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}

.lg-submit-btn:hover:not(:disabled) {
  background: var(--lg-btn-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -4px rgba(2, 132, 199, 0.45);
}

.lg-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.lg-submit-btn:focus-visible {
  outline: 3px solid var(--lg-focus-ring);
  outline-offset: 2px;
}

.lg-submit-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
}

/* Mũi tên bằng CSS ::after để khi script ghi đè btn.textContent = 'Đang đăng nhập...' và set disabled thì mũi tên tự ẩn */
.lg-submit-btn:not(:disabled)::after {
  content: '→';
  font-family: inherit;
  font-size: 19px;
  line-height: 1;
  font-weight: 700;
  transition: transform 0.2s ease;
}

.lg-submit-btn:not(:disabled):hover::after {
  transform: translateX(4px);
}

/* ── HÀNG 4 BIỂU TƯỢNG PHÒNG BAN TRANG TRÍ (DEPARTMENTS) ── */
.lg-dept-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  padding: 12px 18px;
  width: 100%;
  box-sizing: border-box;
}

.lg-dept-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  user-select: none;
  cursor: default;
}

.lg-dept-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--lg-dept-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lg-dept-icon);
  transition: background-color 0.2s ease;
}

.lg-dept-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lg-dept-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--lg-dept-label);
  text-align: center;
  white-space: nowrap;
}

.lg-dept-divider {
  width: 1px;
  height: 36px;
  background-color: var(--lg-dept-divider);
  flex-shrink: 0;
}

/* ── DÒNG BẢN QUYỀN CUỐI TRANG ── */
.lg-footer {
  margin-top: 22px;
  text-align: center;
}

.lg-copyright {
  font-size: 12.5px;
  color: var(--lg-copyright);
  margin: 0;
  letter-spacing: 0.01em;
}

/* ── MODAL QUÊN MẬT KHẨU NHỎ GỌN ── */
.lg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lg-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.lg-modal-box {
  background: var(--lg-card-bg);
  border: 1px solid var(--lg-card-border);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.2s ease;
}

.lg-modal-backdrop.active .lg-modal-box {
  transform: scale(1);
}

.lg-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--lg-dept-bg);
  color: var(--lg-dept-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.lg-modal-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.lg-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--lg-title);
  margin: 0 0 8px;
}

.lg-modal-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--lg-subtitle);
  margin: 0 0 20px;
}

.lg-modal-btn {
  width: 100%;
  height: 42px;
  background: var(--lg-btn-bg);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.lg-modal-btn:hover {
  background: var(--lg-btn-bg-hover);
}

.lg-modal-btn:focus-visible {
  outline: 2px solid var(--lg-input-border-focus);
}

/* ── GIAO DIỆN ĐIỆN THOẠI (<= 480PX) ── */
@media (max-width: 480px) {
  .lg-viewport {
    padding: 20px 12px;
    justify-content: flex-start;
  }

  .lg-gear-top-left {
    top: -60px;
    left: -70px;
    width: 280px;
    height: 280px;
  }

  .lg-gear-bottom-right {
    bottom: -60px;
    right: -70px;
    width: 280px;
    height: 280px;
  }

  .lg-brand {
    margin-bottom: 16px;
  }

  .lg-brand-logo {
    width: 165px;
  }

  .lg-card {
    padding: 28px 20px 24px;
    border-radius: 18px;
  }

  .lg-title {
    font-size: 23px;
  }

  /* Trên iPhone, font-size >= 16px tránh trình duyệt tự phóng to khi bấm vào ô */
  .lg-form-input {
    font-size: 16px;
  }

  /* Điện thoại: lưới 2 x 2 có vạch chữ thập mảnh ở giữa như ảnh mẫu mau-dien-thoai */
  .lg-dept-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
    margin-top: 20px;
    padding: 16px 12px;
    position: relative;
  }

  .lg-dept-divider {
    display: none;
  }

  /* Vạch dọc chữ thập */
  .lg-dept-row::before {
    content: '';
    position: absolute;
    top: 10%;
    bottom: 10%;
    left: 50%;
    width: 1px;
    background-color: var(--lg-dept-divider);
    transform: translateX(-50%);
  }

  /* Vạch ngang chữ thập */
  .lg-dept-row::after {
    content: '';
    position: absolute;
    left: 12%;
    right: 12%;
    top: 50%;
    height: 1px;
    background-color: var(--lg-dept-divider);
    transform: translateY(-50%);
  }

  .lg-dept-item {
    gap: 6px;
  }

  .lg-dept-icon {
    width: 42px;
    height: 42px;
  }

  .lg-dept-icon svg {
    width: 20px;
    height: 20px;
  }

  .lg-dept-label {
    font-size: 12.5px;
  }

  .lg-options-row {
    flex-direction: row;
    align-items: center;
  }

  .lg-remember-label {
    font-size: 13px;
  }

  .lg-forgot-btn {
    font-size: 12.5px;
  }
}

/* ── MÀN HÌNH SIÊU NHỎ (<= 320PX) ── */
@media (max-width: 330px) {
  .lg-card {
    padding: 22px 14px 20px;
  }

  .lg-brand-logo {
    width: 140px;
  }

  .lg-title {
    font-size: 21px;
  }

  .lg-options-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .lg-forgot-btn {
    padding-left: 0;
  }

  /* Chữ gợi ý "Số điện thoại hoặc email" bị cắt 2 chữ cuối ở 320px; thu nhỏ riêng chữ gợi ý (cỡ chữ gõ vào vẫn 16px để iPhone không tự phóng to) */
  .lg-form-input::placeholder {
    font-size: 14px;
  }
}
