/* =========================================================
   [BƯỚC 5] MÀN ĐĂNG NHẬP — khớp phong cách app (Nunito, xanh dương,
   gradient pastel, thẻ trắng/kem, viền #d9eaf7).
   ========================================================= */

/* auth.css nạp SAU style.css nên các lớp .auth-* (có display) sẽ thắng .hidden-section.
   Quy tắc này bảo đảm .hidden-section vẫn ẩn đúng cho các phần tử đăng nhập (theo
   đúng cách app đang làm với các modal khác). */
.auth-overlay.hidden-section,
.auth-form.hidden-section,
.auth-account-box.hidden-section,
.auth-message.hidden-section,
.no-student-list.hidden-section {
    display: none !important;
}

/* Lớp phủ toàn màn hình, căn giữa thẻ đăng nhập */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 214, 102, 0.35) 0 70px, transparent 72px),
        radial-gradient(circle at 88% 12%, rgba(111, 168, 220, 0.28) 0 90px, transparent 92px),
        radial-gradient(circle at 82% 82%, rgba(147, 196, 125, 0.28) 0 85px, transparent 87px),
        linear-gradient(135deg, #eef7ff 0%, #fff8e8 48%, #f0fff4 100%);
}

/* Thẻ đăng nhập (card) */
.auth-card {
    width: 100%;
    max-width: 380px;
    box-sizing: border-box;
    background: #fffaf0;
    border: 1px solid #d9eaf7;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(31, 78, 121, 0.15);
    padding: 28px 24px 24px;
    text-align: center;
    animation: authCardIn .25s ease;
}

@keyframes authCardIn {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* [CHỐNG NHẤP NHÁY] Màn "đang tải" trung tính (spinner). Dùng chung nền gradient
   của .auth-overlay, z-index cao hơn để che cả login lẫn app khi mới mở/F5. */
.boot-loading { z-index: 1100; }
.boot-loading-inner { text-align: center; }
.boot-spinner {
    width: 44px;
    height: 44px;
    margin: 14px auto 10px;
    border: 4px solid #d9eaf7;
    border-top-color: #1f4e79;
    border-radius: 50%;
    animation: bootSpin .8s linear infinite;
}
@keyframes bootSpin { to { transform: rotate(360deg); } }
.boot-loading-text {
    color: #1f4e79;
    font-weight: 700;
    font-size: 15px;
    margin: 0;
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
}

.auth-logo {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 6px;
}

.auth-title {
    color: #1f4e79;
    font-size: 22px;
    font-weight: 800;
    margin: 4px 0 2px;
}

.auth-subtitle {
    color: #5b6b7a;
    font-size: 15px;
    margin: 0 0 18px;
    line-height: 1.45;
}

/* Khu thông báo lỗi / thành công */
.auth-message {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 14.5px;
    font-weight: 600;
    text-align: left;
    line-height: 1.4;
}
.auth-message.is-error {
    background: #fde2e1;
    border: 1px solid #e06666;
    color: #a83232;
}
.auth-message.is-success {
    background: #e6f4ea;
    border: 1px solid #6aa84f;
    color: #2f6b2f;
}

/* Form + nhãn */
.auth-form {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.auth-label {
    color: #1f4e79;
    font-size: 14px;
    font-weight: 700;
    margin: 10px 2px 5px;
}

/* QUAN TRỌNG (chống tự phóng to trên điện thoại):
   cỡ chữ ô nhập >= 16px → Safari/iOS KHÔNG tự zoom khi chạm vào ô. */
.auth-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    font-family: inherit;
    padding: 12px 14px;
    border: 1.5px solid #d9eaf7;
    border-radius: 10px;
    background: #ffffff;
    color: #1f2d3d;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-input::placeholder { color: #9fb2c4; }
.auth-input:focus {
    outline: none;
    border-color: #2f75b5;
    box-shadow: 0 0 0 3px rgba(47, 117, 181, 0.15);
}

/* [GHI NHỚ TÀI KHOẢN] Checkbox dưới ô mật khẩu — vùng chạm đủ lớn cho ngón tay. */
.auth-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 2px 2px;
    padding: 8px 4px;
    font-size: 14.5px;
    font-weight: 600;
    color: #1f4e79;
    cursor: pointer;
    user-select: none;
}
.auth-remember input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    accent-color: #2f75b5;
    cursor: pointer;
}
.auth-remember em {
    font-style: normal;
    color: #6a86a0;
    font-weight: 500;
}

/* Nút */
.auth-btn {
    width: 100%;
    box-sizing: border-box;
    margin-top: 18px;
    min-height: 50px;
    font-size: 17px;
    font-weight: 800;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s ease;
}
.auth-btn-primary {
    background: #2f75b5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(47, 117, 181, 0.3);
}
.auth-btn-primary:hover { background: #285f93; }
.auth-btn-primary:active { transform: translateY(1px); }
.auth-btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* Liên kết phụ */
.auth-links {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.auth-links a {
    color: #2f75b5;
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }

/* [GĐ1 GOOGLE] Dòng "hoặc" ngăn cách form email và nút Google. */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 4px;
    color: #8aa0b4;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: #e1ecf5;
}

/* [GĐ1 GOOGLE] Nút "Đăng nhập bằng Google" — nền trắng, viền, chữ tối, icon G nhiều màu.
   Vùng chạm ≥50px (kế thừa min-height của .auth-btn). */
.auth-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    background: #ffffff;
    color: #3c4043;
    border: 1.5px solid #d9eaf7;
    box-shadow: 0 1px 3px rgba(31, 78, 121, 0.08);
}
.auth-btn-google:hover { background: #f3f8fc; border-color: #9fc3e6; }
.auth-btn-google:active { transform: translateY(1px); }
.auth-btn-google:disabled { opacity: .6; cursor: not-allowed; }
.auth-google-icon { flex: 0 0 auto; display: block; }

/* [GĐ2] Khu "Cách đăng nhập" trong Cài đặt: dòng trạng thái provider + tiêu đề phụ. */
.account-link-status {
    font-size: 13.5px;
    font-weight: 600;
    color: #5b6b7a;
    margin: 2px 0 8px;
    line-height: 1.4;
}
.account-link-subtitle {
    font-size: 13.5px;
    font-weight: 600;
    color: #1f4e79;
    margin: 2px 0 8px;
    line-height: 1.4;
}

/* Khu tài khoản trên thanh trên cùng */
.auth-account-box {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.auth-account-name {
    color: #1f4e79;
    font-weight: 700;
    font-size: 14px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* [GỌN TOP-BAR] Khối tài khoản khi nằm ở HEADER góc phải (cạnh ⚙️/🚪). */
.auth-account-box-header {
    margin-left: 0;            /* bỏ margin-left:auto của bản top-bar cũ */
    max-width: 220px;
}
.auth-account-box-header .auth-account-name { max-width: 200px; }
@media (max-width: 640px) {
    .auth-account-box-header .auth-account-name { max-width: 100px; font-size: 12.5px; }
}
@media (max-width: 430px) {
    /* Màn rất hẹp: thu gọn để KHÔNG tràn (vẫn thấy 1 phần tên + "…"). */
    .auth-account-box-header .auth-account-name { max-width: 64px; }
}
/* Nút Đăng xuất dạng ICON tròn, nhỏ gọn (giống nút logout của các trang web).
   Giữ nguyên id/onclick; chữ "Đăng xuất" chuyển sang title + aria-label cho dễ hiểu. */
.auth-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #1f4e79;
    background: #eaf3fb;
    border: 1px solid #d9eaf7;
    border-radius: 50%;
    cursor: pointer;
    transition: all .15s ease;
}
.auth-logout-btn svg { display: block; }
/* Hover: đỏ nhẹ để gợi ý hành động đăng xuất (quy ước phổ biến). */
.auth-logout-btn:hover {
    background: #fde2e1;
    border-color: #f3b6b2;
    color: #d9362d;
}
.auth-logout-btn:active { transform: scale(0.94); }

/* Khi đăng nhập rồi thì khoá cuộn nền phía sau lớp phủ */
body.auth-locked { overflow: hidden; }

/* [BƯỚC 9] Ẩn nút học sinh KHÔNG thuộc phụ huynh đang đăng nhập (ẩn theo vai). */
.hidden-by-role { display: none !important; }

/* [BƯỚC 10] Cổng mật khẩu cài đặt + ô nhập mật khẩu (≥16px để không tự phóng to trên ĐT). */
.settings-pw-input,
.admin-password-input { font-size: 16px !important; }
.admin-auth-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings-forgot-link {
    color: #2f75b5; font-weight: 700; font-size: 14px; text-decoration: none;
}
.settings-forgot-link:hover { text-decoration: underline; }

/* ============================================================================
   [THÊM HỌC SINH + MÀN THIẾT LẬP] Biệt danh/Ngày sinh trong modal + màn thiết lập
   #noStudentScreen 2 trạng thái. Khớp tông xanh #1f4e79 / #2f75b5 hiện có.
   ============================================================================ */

/* Gợi ý nhỏ, mờ bên cạnh nhãn (vd "(không bắt buộc)"). */
.auth-label-hint {
    font-weight: 600;
    font-size: 12px;
    color: #8aa0b4;
}

/* Modal thêm học sinh giờ có 5 ô → top-align để cuộn xem hết trên màn thấp. */
#addStudentModal {
    align-items: flex-start;
}
/* Khoảng cách nhãn gọn hơn cho form nhiều ô. */
#addStudentModal .auth-label { margin-top: 8px; }
#addStudentModal .auth-input { padding: 10px 13px; }

/* Nút PHỤ (outline) — dùng cho "Thêm học sinh" khi đã có nút chính "Vào trang chính". */
.auth-btn-secondary {
    background: #ffffff;
    color: #2f75b5;
    border: 1.5px solid #9fc3e6;
    box-shadow: none;
    margin-top: 12px;
}
.auth-btn-secondary:hover { background: #eef4f9; border-color: #2f75b5; }
.auth-btn-secondary:active { transform: translateY(1px); }

/* ----- Màn thiết lập: danh sách con đã tạo ----- */
.no-student-card .auth-subtitle { margin-bottom: 14px; }

.no-student-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    margin: 4px 0 6px;
}

.no-student-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    background: #f3f8fc;
    border: 1px solid #d9eaf7;
    border-radius: 12px;
}

.no-student-emoji {
    font-size: 26px;
    line-height: 1;
    flex: 0 0 auto;
}

.no-student-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.no-student-name {
    font-weight: 800;
    color: #1f4e79;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-student-sub {
    font-size: 13px;
    color: #5b6b7a;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Điện thoại ===== */
@media (max-width: 480px) {
    .auth-card {
        max-width: 100%;
        padding: 24px 18px 20px;
        border-radius: 14px;
    }
    .auth-title { font-size: 20px; }
    .auth-account-name { max-width: 110px; }
    .no-student-emoji { font-size: 23px; }
    .no-student-name { font-size: 15px; }
}

/* =========================================================
   [GUEST MODE — GĐ2] Màn Welcome chọn lớp. Tái dùng .auth-overlay/.auth-card.
   Mobile-first: nút lớp full-width, vùng chạm lớn, cỡ chữ ≥16px.
   ========================================================= */
.welcome-overlay.hidden-section { display: none !important; }
.welcome-card { max-width: 420px; }
.welcome-greeting {
    font-size: 16px;
    color: #2c6b3f;
    font-weight: 700;
    line-height: 1.4;
}
.welcome-trial-highlight { color: #e8590c; }
.welcome-prompt {
    margin: 14px 0 8px;
    font-size: 16px;
    font-weight: 700;
    color: #1f4e79;
}
.welcome-grade-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.welcome-grade-btn {
    width: 100%;
    box-sizing: border-box;
    min-height: 52px;
    padding: 12px 16px;
    border: 1px solid #d9eaf7;
    border-radius: 12px;
    background: #ffffff;
    color: #1f4e79;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    text-align: left;
    line-height: 1.35;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
    box-shadow: 0 2px 6px rgba(31, 78, 121, 0.08);
}
.welcome-grade-btn:hover { background: #f3f9ff; box-shadow: 0 4px 12px rgba(31, 78, 121, 0.14); }
.welcome-grade-btn:active { transform: translateY(1px); }
.welcome-grade-btn:disabled { opacity: .55; cursor: default; }
.welcome-grade-btn strong { color: #0b5cad; }
.welcome-grade-sub { color: #6b86a3; font-weight: 600; font-size: 14px; }
.welcome-login-row {
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    font-size: 15px;
    color: #555;
}
.welcome-login-row a { font-weight: 800; }

/* =========================================================
   [GUEST MODE — GĐ4] Popup bức tường đăng nhập (modal mờ + confetti) + chỉ báo lượt học thử.
   ========================================================= */
.guest-gate-overlay.hidden-section { display: none !important; }
/* Modal MỜ phủ lên app (KHÁC nền gradient của welcome/login) — confetti (zIndex 2000) bắn đè lên. */
.guest-gate-overlay { background: rgba(16, 42, 67, 0.55); }
.guest-gate-card {
    position: relative;
    max-width: 400px;
    padding-top: 30px;
}
.guest-gate-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #9bb0c4;
    font-size: 28px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    border-radius: 50%;
}
.guest-gate-close:hover { color: #1f4e79; background: #eef5fc; }
.guest-gate-emoji { font-size: 52px; line-height: 1; margin-bottom: 2px; }
.guest-gate-title { font-size: 22px; margin: 4px 0 6px; }
.guest-gate-msg { font-size: 16px; color: #444; line-height: 1.45; margin: 0 0 10px; }
.guest-gate-offer {
    font-size: 15px;
    font-weight: 700;
    color: #2c6b3f;
    background: #f0fff4;
    border: 1px solid #cdeed5;
    border-radius: 12px;
    padding: 10px 12px;
    margin: 0 0 16px;
    line-height: 1.45;
}
.guest-gate-google {
    width: 100%;
    box-sizing: border-box;
    min-height: 52px;
    font-size: 17px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.guest-gate-email-link {
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 10px;
    background: transparent;
    border: none;
    color: #1f4e79;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}
.guest-gate-email-link:hover { color: #0b5cad; }

.guest-trial-progress {
    display: inline-block;
    align-self: flex-start;
    background: #fff4d6;
    color: #b3611a;
    border: 1px solid #ffe2a8;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 6px;
}
.guest-trial-progress.hidden-section { display: none !important; }

/* =========================================================
   [GUEST MODE — GĐ6A] Selectbox SỐ THÁNG dùng thử (tab Quản lý tài khoản, admin-only).
   ========================================================= */
.trial-months-box { margin-bottom: 14px; }
.trial-months-hint {
    margin: 4px 0 10px;
    font-size: 14px;
    color: #555;
    line-height: 1.45;
}
.trial-months-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.trial-months-select {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 16px;
    font-weight: 700;
    color: #1f4e79;
    border: 1px solid #d9eaf7;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}
.trial-months-saved {
    font-size: 14px;
    font-weight: 700;
    color: #2c6b3f;
}
.trial-months-saved.hidden-section { display: none !important; }
