/* ==========================================================================
   ACCOUNT AUTHENTICATION STYLESHEET
   -------------------------------------------------------------------------- *\
   | Stylesheet dùng chung cho 3 trang: login.php, register.php,              |
   | forgot-password.php                                                       |
   | Layout: Single centered box - tất cả gom vào 1 card trắng giữa màn hình  |
   | Theme: Pocoyo (dễ thương, thân thiện với trẻ em & giáo viên)            |
   | Quy ước đặt tên theo chuẩn BEM (Block__Element--Modifier)                |
   \* ========================================================================== */

/* --------------------------------------------------------------------------
   1. BIẾN TOÀN CỤC (DESIGN TOKENS)
   -------------------------------------------------------------------------- */
:root {
  /* Đồng bộ theo palette homepage QHUN22 */
  --pocoyo-blue: #00abff;
  --pocoyo-blue-dark: #1f5381;
  --pocoyo-blue-light: #eaf2ff;

  /* Màu nền & phụ trợ */
  --pocoyo-bg: #f2f8ff;
  --pocoyo-input-bg: #ffffff;
  --pocoyo-input-border: #dfeaf5;
  --pocoyo-input-border-focus: var(--pocoyo-blue);

  /* Màu chữ */
  --pocoyo-text-dark: #000000;
  --pocoyo-text-muted: #818d99;
  --pocoyo-text-white: #ffffff;

  /* Màu trạng thái */
  --pocoyo-error: #EF4444;
  --pocoyo-success: #10B981;

  /* Kích thước / bán kính */
  --pocoyo-radius-card: 24px;
  --pocoyo-radius-input: 12px;
  --pocoyo-radius-pill: 999px;

  /* Bóng đổ */
  --pocoyo-shadow-card: 0 10px 40px rgba(59, 130, 246, 0.10),
                         0 2px 8px rgba(0, 0, 0, 0.04);
  --pocoyo-shadow-input-focus: 0 0 0 3px rgba(59, 130, 246, 0.15);

  /* Font chữ phải đồng bộ với homepage */
  --pocoyo-font: 'Dinosaur', sans-serif;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE (GLOBAL CHO TẤT CẢ AUTH PAGES)
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--pocoyo-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--pocoyo-text-dark);
  background-color: var(--pocoyo-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page-wrapper {
  background: #eaf2ff;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--pocoyo-blue);
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

a:hover {
  color: var(--pocoyo-blue-dark);
}

button, input, textarea, select {
  font: inherit;
}

.page-wrapper {
  background: #eaf2ff;
  min-height: 100vh;
}

.auth-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 3rem);
  padding: 1rem 1rem 1.25rem;
}

/* --------------------------------------------------------------------------
   3. AUTH LAYOUT (SINGLE CENTERED BOX)
   --------------------------------------------------------------------------
   Layout mới: 1 card trắng duy nhất ở giữa màn hình.
   Không còn split-screen 2 cột nữa.
   -------------------------------------------------------------------------- */
main.auth {
  /* Reset padding/margin từ z1.css */
  padding-top: 0 !important;
  margin-top: 0 !important;
  /* Bỏ qua flex-direction mặc định của parent */
  display: block;
  width: 100%;
}

.auth {
  /* Container chính - dùng margin auto thay vì flex parent
     (để không phụ thuộc parent có display:flex hay không) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* margin-top auto + margin-bottom auto sẽ đẩy card ra giữa
     theo chiều dọc bên trong parent là block */
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
  min-height: calc(100vh - 4rem);
  padding: 2rem 1rem 2rem;
  /* box-sizing để padding không làm card vượt 520px */
  box-sizing: border-box;
}

/* Page wrapper (parent của .auth) - cần là flex column để
   .auth có thể căn giữa theo chiều dọc.
   Áp dụng cho cả .page-wrapper thường vì các trang auth không có gì khác
   ngoài .page-wrapper → an toàn, không ảnh hưởng homepage (homepage đặt
   .page-wrapper ngoài <main> nên rule .page-wrapper > main.auth bên dưới
   chỉ trigger khi main.auth là con trực tiếp). */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Đảm bảo main.auth (chỉ trên trang auth) chiếm full width và flex grow */
.page-wrapper > main.auth {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 6rem; /* chừa chỗ cho navbar fixed-top cao 6rem */
  padding-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   4. CARD CHÍNH (BOX TRẮNG DUY NHẤT)
   --------------------------------------------------------------------------
   Card chứa TẤT CẢ: header (brand + title) + form + footer
   Đặt ở giữa màn hình với max-width giới hạn.
   --------------------------------------------------------------------------
   Layout wireframe:
   ┌─────────────────────────────────┐
   │         [Pocoyo Image]          │  ← .auth__brand-image
   │         Tiêu đề trang           │  ← .auth__title
   │         Mô tả ngắn              │  ← .auth__subtitle
   │                                 │
   │  ┌──────────┐  ┌──────────┐    │  ← .auth__form-row (2 cột)
   │  │  Field 1 │  │  Field 2 │    │
   │  └──────────┘  └──────────┘    │
   │                                 │
   │  ┌──────────┐  ┌──────────┐    │  ← .auth__form-row (row 2)
   │  │  Field 3 │  │  Field 4 │    │
   │  └──────────┘  └──────────┘    │
   │                                 │
   │        [ Nút Đăng nhập ]       │  ← .auth__button (pill)
   │                                 │
   │     Đã có tài khoản? Đăng nhập  │  ← .auth__footer
   └─────────────────────────────────┘
   -------------------------------------------------------------------------- */
.auth__card {
  /* Card trắng - duy nhất trên trang */
  background-color: var(--pocoyo-text-white);
  border-radius: var(--pocoyo-radius-card);
  box-shadow: var(--pocoyo-shadow-card);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 520px;
  /* Animation nhẹ khi load */
  animation: card-appear 0.4s ease-out;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   5. HEADER (BRAND + TITLE + SUBTITLE)
   -------------------------------------------------------------------------- */
.auth__header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth__brand {
  display: inline-block;
  margin-bottom: 1rem;
}

.auth__brand-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: pocoyo-bounce 2.5s ease-in-out infinite;
}

@keyframes pocoyo-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.auth__title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--pocoyo-text-dark);
  margin: 0 0 0.5rem;
  letter-spacing: -0.025em;
}

.auth__subtitle {
  font-size: 0.95rem;
  color: var(--pocoyo-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   6. FORM ELEMENTS
   -------------------------------------------------------------------------- */
.auth__form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth__form-row {
  /* Register form xếp dọc theo kiểu 1 cột, đúng với thiết kế yêu cầu */
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.auth__field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.auth__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--pocoyo-text-dark);
  margin: 0;
}

.auth__input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth__input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--pocoyo-text-dark);
  background-color: var(--pocoyo-input-bg);
  border: 1.5px solid var(--pocoyo-input-border);
  border-radius: var(--pocoyo-radius-input);
  outline: none;
  transition: border-color 0.2s ease-in-out,
              box-shadow 0.2s ease-in-out,
              background-color 0.2s ease-in-out;
}

.auth__input::placeholder {
  color: var(--pocoyo-text-muted);
}

.auth__input:hover {
  border-color: #D1D5DB;
}

.auth__input:focus {
  border-color: var(--pocoyo-input-border-focus);
  background-color: var(--pocoyo-text-white);
  box-shadow: var(--pocoyo-shadow-input-focus);
}

.auth__input--error {
  border-color: var(--pocoyo-input-border);
}

.auth__input--error:focus {
  box-shadow: none;
}

/* Nút toggle hiển thị mật khẩu (mắt) */
.auth__toggle-password {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  background: rgba(0, 171, 255, 0.04);
  border: none;
  border-radius: 12px;
  color: var(--pocoyo-text-muted);
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.auth__toggle-password:hover {
  color: var(--pocoyo-blue);
  background-color: var(--pocoyo-blue-light);
}

.auth__toggle-password:focus-visible {
  outline: 2px solid var(--pocoyo-blue);
  outline-offset: 2px;
}

.auth__toggle-password svg {
  width: 20px;
  height: 20px;
}

.auth__input--has-toggle {
  padding-right: 3.25rem;
}

/* Thông báo lỗi dưới input */
.auth__error-message {
  display: none !important;
  font-size: 0.8125rem;
  color: var(--pocoyo-error);
  margin: 0;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   7. FORM OPTIONS (REMEMBER ME & FORGOT PASSWORD)
   -------------------------------------------------------------------------- */
.auth__options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: -0.5rem;
}

.auth__remember {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--pocoyo-text-dark);
  user-select: none;
  flex-shrink: 0;
}

.auth__checkbox {
  /* Custom checkbox */
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--pocoyo-input-border);
  border-radius: 5px;
  background-color: var(--pocoyo-text-white);
  cursor: pointer;
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
  position: relative;
  flex-shrink: 0;
}

.auth__checkbox:hover {
  border-color: var(--pocoyo-blue);
}

.auth__checkbox:checked {
  background-color: var(--pocoyo-blue);
  border-color: var(--pocoyo-blue);
}

.auth__checkbox:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3E%3Cpath d='M13.5 4.5 6 12 2.5 8.5l1-1L6 10l6.5-6.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

.auth__checkbox:focus-visible {
  outline: 2px solid var(--pocoyo-blue);
  outline-offset: 2px;
}

.auth__forgot-link {
  font-size: 0.9rem;
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

.auth__forgot-link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */
.auth__button {
  /* Nút bấm chính - dạng pill */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.95rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--pocoyo-text-white);
  background-color: var(--pocoyo-blue);
  border: none;
  border-radius: var(--pocoyo-radius-pill);
  cursor: pointer;
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out,
              box-shadow 0.2s ease-in-out;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
  margin-top: 0.25rem;
}

.auth__button:hover {
  background-color: var(--pocoyo-blue-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.auth__button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.auth__button:focus-visible {
  outline: 3px solid var(--pocoyo-blue-light);
  outline-offset: 2px;
}

.auth__button:disabled {
  background-color: #9CA3AF;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Account page */
.auth--account { max-width: 1280px; }
.auth--account,
.auth--account * { font-family: 'Signika', sans-serif; }
.account-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; width: 100%; }
.account-panel { max-width: none; padding: 0; overflow: hidden; }
.account-panel__header { padding: 1.45rem 1.5rem 1.15rem; border-bottom: 1px solid var(--pocoyo-input-border); }
.account-panel__title { margin: 0; color: var(--pocoyo-text-dark); font-size: 1.45rem; font-weight: 500; }
.account-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; padding: 1.45rem 1.5rem 1.55rem; margin: 0; }
.account-detail { min-width: 0; }
.account-detail dt { margin-bottom: 8px; color: var(--pocoyo-text-dark); font-size: 0.82rem; font-weight: 600; }
.account-detail dd { min-height: 40px; display: flex; align-items: center; margin: 0; padding: 0 12px; border: 1px solid var(--pocoyo-input-border); border-radius: 5px; background: #f7faff; color: var(--pocoyo-text-dark); font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.account-password-form { padding: 1.45rem 1.5rem 1.55rem; gap: 1rem; }
.account-password-form .auth__input { padding: 0.72rem 1rem; border-radius: 5px; background: #fff; }
.account-form-error { margin: -3px 0 0; color: var(--pocoyo-error); font-size: 0.78rem; line-height: 1.4; }
.account-actions { display: flex; justify-content: flex-end; gap: 10px; width: 100%; max-width: 1280px; margin-top: 16px; }
.account-actions .auth__button { width: auto; min-width: 150px; margin: 0; }
.auth__button--secondary { color: var(--pocoyo-blue-dark); background: #fff; border: 1px solid var(--pocoyo-input-border); box-shadow: none; }
.auth__button--secondary:hover { background: var(--pocoyo-blue-light); }

@media (max-width: 760px) {
  .account-layout { grid-template-columns: 1fr; }
  .account-details { grid-template-columns: 1fr; }
  .account-actions { flex-direction: column; }
  .account-actions .auth__button { width: 100%; }
}

/* --------------------------------------------------------------------------
   9. FOOTER LINK (Đăng ký / Quay lại đăng nhập)
   -------------------------------------------------------------------------- */
.auth__footer {
  text-align: center;
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--pocoyo-text-muted);
}

.auth__footer-link {
  font-weight: 700;
  color: var(--pocoyo-blue);
}

.auth__footer-link:hover {
  color: var(--pocoyo-blue-dark);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   10. RESPONSIVE (MOBILE / TABLET)
   -------------------------------------------------------------------------- */

/* Tablet & nhỏ hơn: card full width */
@media (max-width: 575px) {
  .auth-shell {
    min-height: calc(100vh - 2rem);
    padding: 1.5rem 0.75rem 1rem;
  }

  .auth {
    padding: 1rem 0.75rem;
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .auth__card {
    padding: 1.75rem 1.25rem;
    border-radius: 20px;
  }

  .auth__title {
    font-size: 1.5rem;
  }

  .auth__subtitle {
    font-size: 0.875rem;
  }

  /* Form row về 1 cột trên mobile */
  .auth__form-row {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Options giữ nguyên hàng, tự wrap nếu quá chật (gap nhỏ lại trên mobile) */
  .auth__options {
    gap: 0.5rem 0.75rem;
  }

  .auth__toggle-password {
    width: 40px;
    height: 40px;
    min-width: 40px;
    right: 0.6rem;
    border-radius: 10px;
  }

  .auth__input--has-toggle {
    padding-right: 3rem;
  }

  /* Brand image nhỏ hơn trên mobile */
  .auth__brand-image {
    width: 64px;
    height: 64px;
  }
}

/* Tablet lớn (576px - 991px): card rộng hơn một chút */
@media (min-width: 576px) and (max-width: 991px) {
  .auth__card {
    max-width: 480px;
    padding: 2rem 1.75rem;
  }
}

/* Desktop ≥992px: card max 520px, căn giữa hoàn hảo */
@media (min-width: 992px) {
  .auth-shell {
    min-height: calc(100vh - 5rem);
    padding: 0.75rem 1rem 1rem;
  }

  .auth {
    min-height: 0;
    padding: 1rem 1rem;
  }

  .auth__card {
    max-width: 520px;
    padding: 2rem 2rem;
  }
}

/* --------------------------------------------------------------------------
   12. ACCESSIBILITY - REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   13. LEGACY / DEPRECATED (giữ lại để backward compat nếu cần)
   --------------------------------------------------------------------------
   Các class cũ từ layout split-screen 2 cột - không còn dùng nhưng
   giữ lại để tránh lỗi nếu có partial include ở đâu đó.
   -------------------------------------------------------------------------- */
.auth__wrapper,
.auth__form-column,
.auth__image-column {
  display: none; /* Ẩn hoàn toàn - không còn layout cũ */
}
