/* ============================= */
/* VARIABLES */
/* ============================= */

:root {
    --color-page: #f3f5f4;
    --color-card: #ffffff;
    --color-ink: #1c2b2a;
    --color-muted: #5d6b69;
    --color-line: #d5dcda;
    --color-accent: #0b6e4f;
    --color-accent-dark: #084f39;
    --color-error: #b42318;
    --color-error-bg: #fdecea;
    --color-success: #0b6e4f;
    --color-success-bg: #e4f4ed;
    --radius-card: 14px;
    --radius-field: 8px;
}

/* ============================= */
/* BASE */
/* ============================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Noto Sans Thai', 'Sarabun', Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-ink);
    background-color: var(--color-page);
}

[hidden] {
    display: none !important;
}

/* ============================= */
/* LOGIN PAGE */
/* ============================= */

.login-page {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 28px 24px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
    box-shadow: 0 6px 24px rgba(28, 43, 42, 0.08);
}

.login-title {
    margin: 0 0 4px 0;
    font-size: 26px;
    font-weight: 700;
    
}

.login-subtitle {
    margin: 0 0 24px 0;
    color: var(--color-muted);
}

/* ============================= */
/* FORM */
/* ============================= */

.field-label {
    display: block;
    margin: 16px 0 6px 0;
    font-weight: 600;
}

.field-input {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--color-ink);
    background-color: #ffffff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
}

.field-input:focus {
    outline: 3px solid rgba(11, 110, 79, 0.3);
    border-color: var(--color-accent);
}

/* ============================= */
/* BUTTONS */
/* ============================= */

.button {
    width: 100%;
    margin-top: 22px;
    padding: 13px 16px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-field);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.button:focus-visible {
    outline: 3px solid rgba(11, 110, 79, 0.4);
    outline-offset: 2px;
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.button-primary {
    color: #ffffff;
    background-color: var(--color-accent);
}

.button-primary:hover:not(:disabled) {
    background-color: var(--color-accent-dark);
}

.button-secondary {
    color: var(--color-ink);
    background-color: #ffffff;
    border-color: var(--color-line);
}

.button-secondary:hover:not(:disabled) {
    background-color: var(--color-page);
}

/* ============================= */
/* MESSAGES */
/* ============================= */

.message {
    margin: 18px 0 0 0;
    padding: 10px 14px;
    border-radius: var(--radius-field);
}

.message-error {
    color: var(--color-error);
    background-color: var(--color-error-bg);
}

.message-success {
    color: var(--color-success);
    background-color: var(--color-success-bg);
}

.signed-in-panel {
    padding: 14px 16px;
    margin-bottom: 8px;
    background-color: var(--color-success-bg);
    border-radius: var(--radius-field);
}

.signed-in-panel p {
    margin: 2px 0;
}

/* ============================= */
/* REDUCED MOTION */
/* ============================= */

@media (prefers-reduced-motion: reduce) {
    .button {
        transition: none;
    }
}

/* ============================= */
/* SITE HEADER */
/* ============================= */

.site-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--color-card);
    border-bottom: 1px solid var(--color-line);
}

.site-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-accent);
    text-decoration: none;
}

.site-link {
    color: var(--color-muted);
    font-size: 14px;
    text-decoration: none;
}

.site-link:hover {
    color: var(--color-ink);
    text-decoration: underline;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.button-small {
    padding: 6px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-ink);
    background-color: #ffffff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    cursor: pointer;
}

.button-small:hover {
    background-color: var(--color-page);
}

/* ============================= */
/* LAYOUT */
/* ============================= */

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 48px 20px;
}

.container-narrow {
    max-width: 560px;
}

.page-title {
    margin: 0 0 20px 0;
    font-size: 26px;
}

.section {
    margin-top: 36px;
}

.section-title {
    margin: 0 0 14px 0;
    font-size: 20px;
}

.muted {
    color: var(--color-muted);
}

.panel {
    margin-bottom: 20px;
    padding: 22px 20px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
}

/* ============================= */
/* HERO (หน้าแรก) */
/* ============================= */

.hero {
    padding: 28px 0 8px 0;
}

.hero-title {
    margin: 0 0 10px 0;
    font-size: 32px;
    line-height: 1.3;
}

.hero-text {
    margin: 0 0 20px 0;
    max-width: 520px;
    color: var(--color-muted);
}

.button-inline {
    display: inline-block;
    width: auto;
    margin-top: 0;
    padding-left: 24px;
    padding-right: 24px;
    text-align: center;
    text-decoration: none;
}

/* ============================= */
/* TRAINING LIST + FEATURE CARDS */
/* ============================= */

.training-item {
    margin-bottom: 10px;
    padding: 14px 16px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius-field);
}

.training-title {
    margin: 0;
    font-size: 17px;
}

.training-meta {
    margin: 2px 0 0 0;
    font-size: 14px;
    color: var(--color-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.feature-card {
    display: block;
    padding: 18px 16px;
    color: inherit;
    text-decoration: none;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
}

a.feature-card:hover {
    border-color: var(--color-accent);
}

.feature-card-disabled {
    background-color: transparent;
    border-style: dashed;
}

.feature-title {
    margin: 0 0 4px 0;
    font-size: 17px;
}

.feature-text {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--color-muted);
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    color: var(--color-muted);
    background-color: var(--color-page);
    border: 1px solid var(--color-line);
    border-radius: 999px;
}

/* ============================= */
/* FORM EXTRAS */
/* ============================= */

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

select.field-input {
    background-color: #ffffff;
}

.success-panel {
    border-color: var(--color-accent);
    background-color: var(--color-success-bg);
}

.reg-no {
    margin: 4px 0 8px 0;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--color-accent-dark);
}

/* ============================= */
/* ADMIN: STATS + TABLE */
/* ============================= */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 16px 18px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
}

.stat-number {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    margin: 0;
    font-size: 14px;
    color: var(--color-muted);
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-line);
}

.data-table th {
    font-weight: 600;
    background-color: var(--color-page);
}

@media (min-width: 700px) {
    .filter-row {
        grid-template-columns: 1fr 1.4fr auto;
    }
}

@media (max-width: 420px) {
    .field-row {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 26px;
    }
}

/* ============================= */
/* AUTH: ลิงก์สลับหน้า login / สมัครสมาชิก, หัวเว็บ */
/* ============================= */

.auth-switch {
    margin: 14px 0 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--color-muted);
}

.auth-switch a {
    color: var(--color-accent);
    font-weight: 600;
}



.header-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ============================= */
/* PHASE 1: หน้าผู้เข้าอบรม - หลักสูตรที่ลงทะเบียน (เพิ่มต่อท้าย ไม่แก้ class เดิม) */
/* ============================= */

.hero-banner {
    margin-bottom: 20px;
    padding: 26px 24px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--color-accent) 0%, #138a64 55%, #1aa37a 100%);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(11, 110, 79, 0.25);
}

.hero-eyebrow {
    margin: 0 0 2px 0;
    font-size: 14px;
    opacity: 0.85;
}

.hero-banner-title {
    margin: 0 0 6px 0;
    font-size: 28px;
}

.hero-banner-text {
    margin: 0;
    opacity: 0.95;
}

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: 999px;
}

.tab-button {
    flex: 1 1 auto;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-button:hover {
    color: var(--color-ink);
}

.tab-button.is-active {
    color: #ffffff;
    background-color: var(--color-accent);
}

.tab-button:focus-visible {
    outline: 3px solid rgba(11, 110, 79, 0.4);
    outline-offset: 2px;
}

.tab-count {
    display: inline-block;
    min-width: 22px;
    margin-left: 6px;
    padding: 0 7px;
    font-size: 13px;
    line-height: 22px;
    text-align: center;
    color: var(--color-accent-dark);
    background-color: #ffffff;
    border-radius: 999px;
}

.tab-panel {
    margin-top: 24px;
}

/* ---------- การ์ดหลักสูตร ---------- */

.course-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.course-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(28, 43, 42, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(28, 43, 42, 0.1);
}

.course-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.course-regno {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--color-muted);
}

.course-title {
    margin: 0 0 14px 0;
    font-size: 18px;
    line-height: 1.4;
}

.course-meta {
    margin: 0 0 18px 0;
}

.course-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    border-top: 1px dashed var(--color-line);
}

.course-meta-row dt {
    flex: 0 0 auto;
    color: var(--color-muted);
}

.course-meta-row dd {
    margin: 0;
    text-align: right;
    font-weight: 600;
}

.course-button {
    margin-top: auto;
    display: block;
    text-align: center;
    text-decoration: none;
}

/* ---------- ป้ายสถานะ ---------- */

.badge-phase {
    display: inline-block;
    padding: 3px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
}

.phase-upcoming {
    color: #8a5a00;
    background-color: #fff3d6;
}

.phase-ongoing {
    color: var(--color-accent-dark);
    background-color: var(--color-success-bg);
}

.phase-ended {
    color: var(--color-muted);
    background-color: #e8ecea;
}

/* ---------- สถานะว่าง / ผิดพลาด / กำลังโหลด ---------- */

.state-box {
    grid-column: 1 / -1;
    padding: 32px 20px;
    text-align: center;
    background-color: var(--color-card);
    border: 1px dashed var(--color-line);
    border-radius: 16px;
}

.state-box-error {
    border-style: solid;
    border-color: #f1b5af;
    background-color: var(--color-error-bg);
}

.state-title {
    margin: 0 0 6px 0;
    font-size: 18px;
}

.state-box p {
    margin: 0 0 16px 0;
}

.course-skeleton {
    min-height: 210px;
    background: linear-gradient(90deg, #eef1f0 25%, #f8faf9 50%, #eef1f0 75%);
    background-size: 200% 100%;
    animation: skeleton-move 1.4s ease-in-out infinite;
}

.detail-skeleton {
    min-height: 260px;
}

@keyframes skeleton-move {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------- หน้ารายละเอียดหลักสูตร ---------- */

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.detail-hero {
    margin-bottom: 20px;
    padding: 24px 22px;
    background: linear-gradient(135deg, #e4f4ed 0%, #ffffff 70%);
    border: 1px solid var(--color-line);
    border-radius: 18px;
}

.detail-title {
    margin: 10px 0 4px 0;
    font-size: 26px;
    line-height: 1.35;
}

.detail-organizer {
    margin: 0;
    color: var(--color-muted);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 0;
}

.info-item dt {
    font-size: 13px;
    color: var(--color-muted);
}

.info-item dd {
    margin: 2px 0 0 0;
    font-weight: 600;
    word-break: break-word;
}

.info-regno {
    font-size: 20px;
    letter-spacing: 1.5px;
    color: var(--color-accent-dark);
}

.placeholder-panel {
    border-style: dashed;
    background-color: transparent;
}

/* ---------- กล่องโต้ตอบ/Toast สำรอง (ใช้เมื่อโหลด SweetAlert2 ไม่ได้) ---------- */

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: rgba(28, 43, 42, 0.5);
}

.dialog-box {
    width: 100%;
    max-width: 380px;
    padding: 24px 22px;
    background-color: var(--color-card);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.dialog-title {
    margin: 0 0 8px 0;
    font-size: 19px;
}

.dialog-success { color: var(--color-success); }
.dialog-error { color: var(--color-error); }

.dialog-text {
    margin: 0 0 18px 0;
    color: var(--color-muted);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.button-small-primary {
    color: #ffffff;
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.button-small-primary:hover {
    background-color: var(--color-accent-dark);
}

.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    color: #ffffff;
    background-color: var(--color-ink);
    border-radius: var(--radius-field);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast-success { background-color: var(--color-accent); }
.toast-error { background-color: var(--color-error); }

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-button {
        flex: 0 0 auto;
    }
}

@media (min-width: 960px) {
    .course-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 420px) {
    .hero-banner-title,
    .detail-title {
        font-size: 22px;
    }

    .site-header {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .course-card,
    .tab-button {
        transition: none;
    }

    .course-skeleton {
        animation: none;
    }
}

/* ============================= */
/* MODULES: เนื้อหารายวัน (Admin + หน้ารายละเอียดหลักสูตร) */
/* เพิ่มต่อท้ายเท่านั้น ใช้ prefix .module- ไม่กระทบหน้าอื่น | Mobile-first: 640px (แท็บเล็ต) / 960px (Desktop) */
/* ============================= */

.module-select-label {
    margin-top: 0;
}

.module-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    margin-top: 20px;
}

.module-form-box {
    min-width: 0;
    padding-top: 20px;
    border-top: 1px solid var(--color-line);
}

.module-form-title {
    margin: 0;
    font-size: 18px;
}

.module-form-box .field-label:first-of-type {
    margin-top: 12px;
}

.module-form-box .field-row > div {
    min-width: 0;
}

.module-textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

.module-form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 22px;
}

.module-form-actions .button {
    margin-top: 0;
}

/* ---------- การ์ดรายการ (Admin) ---------- */

.module-card {
    min-width: 0;
    margin-bottom: 12px;
    padding: 14px 16px;
    background-color: #ffffff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
}

.module-card:last-child {
    margin-bottom: 0;
}

.module-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.module-card-day {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-dark);
}

.module-card-time {
    margin: 4px 0 0 0;
    font-size: 14px;
    color: var(--color-muted);
}

.module-card-title {
    margin: 6px 0 0 0;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.module-card-desc {
    margin: 6px 0 0 0;
    font-size: 14px;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.module-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.module-card-actions .button-small {
    min-height: 44px;
    padding: 8px 18px;
}

.module-card-actions .module-delete {
    color: var(--color-error);
    border-color: var(--color-error);
}

.module-card-actions .module-delete:hover {
    background-color: var(--color-error-bg);
}

/* ---------- หน้ารายละเอียดหลักสูตร (ผู้อบรม) ---------- */

.module-days {
    display: grid;
    gap: 22px;
    color: var(--color-ink);
}

.module-day-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    font-size: 17px;
    border-bottom: 2px solid var(--color-success-bg);
}

.module-day-number {
    color: var(--color-accent-dark);
}

.module-day-date {
    font-size: 14px;
    font-weight: 400;
    color: var(--color-muted);
}

.module-items {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.module-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 12px 14px;
    background-color: #ffffff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
}

.module-time {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-dark);
}

.module-content {
    min-width: 0;
}

.module-title {
    margin: 0;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.module-desc {
    margin: 4px 0 0 0;
    font-size: 15px;
    color: var(--color-muted);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* ---------- แท็บเล็ต ---------- */

@media (min-width: 640px) {
    .module-form-actions {
        display: flex;
        flex-wrap: wrap;
    }

    .module-form-actions .button {
        flex: 1 1 200px;
    }

    .module-item {
        grid-template-columns: 160px minmax(0, 1fr);
        gap: 16px;
    }
}

/* ---------- Desktop: รายการซ้าย / ฟอร์มขวา ---------- */

@media (min-width: 960px) {
    /* สองคอลัมน์เฉพาะเมื่อมีฟอร์ม (Staff ไม่เห็นฟอร์ม -> รายการเต็มความกว้าง) */
    .module-layout:has(> .module-form-box:not([hidden])) {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
        align-items: start;
        gap: 28px;
    }

    .module-form-box {
        padding-top: 0;
        padding-left: 28px;
        border-top: 0;
        border-left: 1px solid var(--color-line);
    }

    .module-form-box .field-label:first-of-type {
        margin-top: 12px;
    }
}

/* ============================= */
/* DOCUMENTS: เอกสารประกอบหลักสูตร (Admin + หน้ารายละเอียดหลักสูตร) */
/* เพิ่มต่อท้ายเท่านั้น ใช้ prefix .doc- ไม่กระทบหน้าอื่น | Mobile-first: 640px (แท็บเล็ต) / 960px (Desktop) */
/* ============================= */

.doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    margin-top: 20px;
}

.doc-list-box,
.doc-form-box {
    min-width: 0;
}

.doc-form-box {
    padding-top: 20px;
    border-top: 1px solid var(--color-line);
}

.doc-form-box .field-label:first-of-type {
    margin-top: 12px;
}

.doc-file-input {
    max-width: 100%;
}

/* ---------- ป้ายชนิดไฟล์ + บรรทัดข้อมูลไฟล์ ---------- */

.doc-type-badge {
    display: inline-block;
    flex: 0 0 auto;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-accent-dark);
    background-color: var(--color-success-bg);
    border-radius: 6px;
}

.doc-scope {
    font-size: 14px;
    color: var(--color-muted);
    overflow-wrap: anywhere;
}

.doc-file-line {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: var(--color-muted);
    overflow-wrap: anywhere;
}

.doc-card .doc-download {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* ---------- หน้ารายละเอียดหลักสูตร (ผู้อบรม) ---------- */

.doc-groups {
    display: grid;
    gap: 22px;
    color: var(--color-ink);
}

.doc-group-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    font-size: 17px;
    border-bottom: 2px solid var(--color-success-bg);
}

.doc-group-name {
    min-width: 0;
    color: var(--color-accent-dark);
    overflow-wrap: anywhere;
}

.doc-items {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.doc-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px 14px;
    background-color: #ffffff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
}

.doc-info {
    min-width: 0;
}

.doc-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.doc-item-title {
    min-width: 0;
    margin: 0;
    font-size: 16px;
    overflow-wrap: anywhere;
}

.doc-item-desc {
    margin: 6px 0 0 0;
    font-size: 15px;
    color: var(--color-muted);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.doc-download-button {
    display: inline-block;
    margin-top: 0;
    min-height: 44px;
    text-align: center;
    text-decoration: none;
}

/* ---------- แท็บเล็ต ---------- */

@media (min-width: 640px) {
    .doc-item {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 16px;
    }

    .doc-download-button {
        width: auto;
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* ---------- Desktop: รายการซ้าย / ฟอร์มขวา ---------- */

@media (min-width: 960px) {
    /* สองคอลัมน์เฉพาะเมื่อมีฟอร์ม (Staff ไม่เห็นฟอร์ม -> รายการเต็มความกว้าง) */
    .doc-layout:has(> .doc-form-box:not([hidden])) {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
        align-items: start;
        gap: 28px;
    }

    .doc-form-box {
        padding-top: 0;
        padding-left: 28px;
        border-top: 0;
        border-left: 1px solid var(--color-line);
    }
}

/* ============================= */
/* PHASE 3.1: เวลาเข้าถึง Module / อัปโหลดหลายไฟล์ / แทนที่ไฟล์ */
/* เพิ่มต่อท้ายเท่านั้น (ไม่แก้กฎเดิม) | Mobile-first: 640px (แท็บเล็ต) / 960px (Desktop) */
/* ============================= */

/* ---------- ป้ายสถานะการเข้าถึง Module ---------- */

.badge-access {
    display: inline-block;
    padding: 3px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 999px;
}

.access-open,
.access-always {
    color: var(--color-accent-dark);
    background-color: var(--color-success-bg);
}

.access-upcoming {
    color: #8a5a00;
    background-color: #fff3d6;
}

.access-ended {
    color: var(--color-muted);
    background-color: #e8ecea;
}

.access-override {
    color: #5b2a86;
    background-color: #efe5f9;
}

/* ---------- Admin: แถวสถานะ / Override ---------- */

.module-access-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 8px;
}

.module-lock-flag {
    font-size: 13px;
    color: var(--color-muted);
}

.module-override-note {
    margin: 6px 0 0 0;
    padding: 8px 10px;
    font-size: 13px;
    color: #5b2a86;
    background-color: #f7f1fc;
    border-radius: var(--radius-field);
    overflow-wrap: anywhere;
}

.module-card-actions .module-override {
    color: #5b2a86;
    border-color: #5b2a86;
}

.module-card-actions .module-override.is-on {
    color: #ffffff;
    background-color: #5b2a86;
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    margin-top: 16px;
    font-size: 15px;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 2px 0 0 0;
    accent-color: var(--color-accent);
}

/* ---------- Admin: ช่องอัปโหลดหลายไฟล์ ---------- */

.doc-slots {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.doc-slot {
    min-width: 0;
    margin: 0;
    padding: 4px 14px 14px 14px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    background-color: #fafcfb;
}

.doc-slot-legend {
    padding: 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-dark);
}

.doc-slot-file,
.doc-replace-box .doc-slot-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-top: 8px;
    padding: 8px 10px;
    background-color: var(--color-success-bg);
    border-radius: var(--radius-field);
}

.doc-slot-file-name {
    min-width: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.doc-slot-file .button-small {
    min-height: 44px;
    padding: 8px 16px;
}

.doc-slot-error {
    margin: 6px 0 0 0;
    font-size: 13px;
    color: var(--color-error);
}

.doc-slot-desc {
    min-height: 64px;
    resize: vertical;
}

.doc-replace-box {
    margin-top: 18px;
    padding: 12px 14px 14px 14px;
    border: 1px dashed var(--color-line);
    border-radius: var(--radius-field);
}

.doc-replace-heading {
    margin-top: 0;
}

.doc-current-file {
    margin: 4px 0 0 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

/* ---------- Participant: Module พร้อมสถานะและเอกสาร ---------- */

.module-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.module-title-row .module-title {
    min-width: 0;
}

.module-lock-note {
    margin: 6px 0 0 0;
    font-size: 14px;
    color: var(--color-muted);
    overflow-wrap: anywhere;
}

.module-item-locked {
    background-color: #f7f9f8;
}

.module-view-button {
    min-height: 44px;
    margin-top: 10px;
    padding: 8px 18px;
}

.module-view-button:disabled,
.doc-download-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.module-panel {
    margin-top: 8px;
    padding: 10px 12px;
    background-color: var(--color-page);
    border-radius: var(--radius-field);
}

.module-panel .module-desc {
    margin: 0;
}

.module-docs {
    margin-top: 14px;
}

.module-docs-title {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-dark);
}

.doc-item-locked {
    background-color: #f7f9f8;
}

button.doc-download-button {
    width: 100%;
    font-family: inherit;
    border: 0;
    cursor: pointer;
}

/* ---------- ผลลัพธ์ในกล่อง SweetAlert2 / กล่องสำรอง ---------- */

.result-list {
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
    font-size: 15px;
}

.result-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--color-line);
    overflow-wrap: anywhere;
}

.result-item:last-child {
    border-bottom: 0;
}

.result-ok { color: var(--color-success); }
.result-fail { color: var(--color-error); }

.dialog-text {
    white-space: pre-line;
}

@media (min-width: 640px) {
    button.doc-download-button {
        width: auto;
    }

    .doc-slot-file {
        flex-wrap: nowrap;
    }
}

/* ============================= */
/* PHASE 3.2: เช็กชื่อรายวัน */
/* ============================= */

.attendance-list {
    display: grid;
    gap: 14px;
}

.attendance-day {
    padding: 16px;
    background-color: var(--color-card);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
}

.attendance-checked {
    border-color: var(--color-accent);
}

.attendance-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.attendance-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    font-size: 17px;
}

.attendance-window {
    margin: 8px 0 12px;
    color: var(--color-muted);
}

.attendance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.attendance-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.attendance-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.attendance-preview {
    margin-bottom: 12px;
}

.attendance-preview-img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    object-fit: contain;
}

.attendance-proof {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
}

.attendance-thumb {
    width: 120px;
    height: 120px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    object-fit: cover;
    background-color: var(--color-page);
}

.attendance-proof-info p {
    margin: 0 0 6px;
}

.attendance-done {
    font-weight: 600;
    color: var(--color-accent-dark);
}

/* ---------- Admin ---------- */

.att-days {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.att-day {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    background-color: var(--color-card);
}

.att-day-selected {
    border-color: var(--color-accent);
    background-color: var(--color-success-bg);
}

.att-day-main {
    flex: 1 1 240px;
}

.att-day-main p {
    margin: 0 0 4px;
}

.att-day-date {
    font-weight: 600;
}

.att-window-form,
.att-detail,
.att-summary-box {
    margin-top: 18px;
}

.att-filter {
    max-width: 260px;
    margin-bottom: 12px;
}

.att-note {
    margin: 4px 0 0;
    font-size: 13px;
    white-space: pre-wrap;
}

.att-decision {
    font-weight: 600;
}

.att-photo-box {
    max-width: 640px;
}

.att-photo-large {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    margin: 12px auto;
    object-fit: contain;
}

@media (max-width: 600px) {
    .attendance-actions .button,
    .attendance-actions .attendance-pick {
        flex: 1 1 100%;
    }

    .attendance-thumb {
        width: 96px;
        height: 96px;
    }
}

/* ============================= */
/* HOME (หน้าแรก) — ปรับ UI ใหม่ */
/* เพิ่มต่อท้ายเท่านั้น ใช้ prefix .home- ทั้งหมด ไม่แก้ class เดิม ไม่กระทบหน้าอื่น */
/* Mobile-first: 640px / 768px / 960px / 1280px */
/* ============================= */

.home-page {
    --home-green: #0b6e4f;
    --home-green-dark: #084f39;
    --home-green-deep: #06392a;
    --home-mint: #e4f4ed;
    --home-mint-strong: #c9ebdc;
    --home-amber: #f2b441;
    --home-bg: #f7faf8;
    --home-ink: #1c2b2a;
    --home-muted: #55635f;
    --home-line: #dde5e2;
    --home-radius: 20px;
    --home-shadow-sm: 0 1px 2px rgba(16, 40, 33, 0.06), 0 4px 14px rgba(16, 40, 33, 0.05);
    --home-shadow-lg: 0 18px 44px rgba(11, 110, 79, 0.16);
    --home-ease: cubic-bezier(0.22, 1, 0.36, 1);

    background-color: var(--home-bg);
    color: var(--home-ink);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.home-page main {
    display: block;
}

.home-icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.home-icon {
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.home-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.home-skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 100;
    padding: 10px 16px;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--home-green-dark);
    border-radius: 10px;
    text-decoration: none;
}

.home-skip-link:focus {
    top: 12px;
}

.home-page a:focus-visible,
.home-page button:focus-visible {
    outline: 3px solid rgba(11, 110, 79, 0.45);
    outline-offset: 3px;
}

.home-shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Header ---------- */

.home-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(221, 229, 226, 0.8);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
}

.home-header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-height: 64px;
}

.home-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--home-ink);
    text-decoration: none;
}

.home-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    font-size: 20px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--home-green) 0%, #19a274 100%);
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(11, 110, 79, 0.28);
}

.home-brand-text {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.home-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.home-nav-link,
.home-nav-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--home-ease), box-shadow 0.2s ease;
}

.home-nav-link {
    color: var(--home-ink);
}

.home-nav-link:hover {
    color: var(--home-green-dark);
    background-color: var(--home-mint);
}

.home-nav-cta {
    padding: 0 16px;
    color: #ffffff;
    background-color: var(--home-green);
    box-shadow: 0 6px 16px rgba(11, 110, 79, 0.25);
}

.home-nav-cta:hover {
    background-color: var(--home-green-dark);
    transform: translateY(-1px);
}

/* ---------- Buttons ---------- */

.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 24px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.25s var(--home-ease), box-shadow 0.25s ease;
}

.home-btn-icon {
    font-size: 18px;
    transition: transform 0.25s var(--home-ease);
}

.home-btn-primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--home-green) 0%, #12936a 100%);
    box-shadow: 0 10px 24px rgba(11, 110, 79, 0.3);
}

.home-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(11, 110, 79, 0.36);
}

.home-btn-primary:hover .home-btn-icon {
    transform: translateX(4px);
}

.home-btn-ghost {
    color: var(--home-ink);
    background-color: #ffffff;
    border-color: var(--home-line);
}

.home-btn-ghost:hover {
    border-color: var(--home-green);
    color: var(--home-green-dark);
}

.home-btn-soft {
    min-height: 46px;
    padding: 0 18px;
    font-size: 15px;
    color: var(--home-green-dark);
    background-color: #ffffff;
    border-color: var(--home-line);
}

.home-btn-soft:hover {
    border-color: var(--home-green);
}

.home-btn-light {
    color: var(--home-green-deep);
    background-color: #ffffff;
}

.home-btn-light:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.home-btn-outline-light {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.55);
}

.home-btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: #ffffff;
}

/* ---------- Hero ---------- */

.home-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 44px 0 56px 0;
}

.home-hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, #ffffff 0%, var(--home-bg) 100%);
}

.home-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
    animation: home-float 14s ease-in-out infinite;
}

.home-blob-1 {
    top: -120px;
    right: -100px;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, #8fdcbd 0%, rgba(143, 220, 189, 0) 70%);
}

.home-blob-2 {
    bottom: -140px;
    left: -120px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, #ffe2a8 0%, rgba(255, 226, 168, 0) 70%);
    animation-delay: -6s;
}

.home-grid-pattern {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(11, 110, 79, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 110, 79, 0.06) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at 70% 30%, #000 0%, transparent 65%);
    mask-image: radial-gradient(ellipse at 70% 30%, #000 0%, transparent 65%);
}

.home-hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    align-items: center;
}

.home-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px 0;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--home-green-dark);
    background-color: var(--home-mint);
    border: 1px solid var(--home-mint-strong);
    border-radius: 999px;
}



.home-hero-title {
    margin: 0 0 16px 0;
    font-size: clamp(30px, 7.4vw, 52px);
    font-weight: 700;
    line-height: 1.32;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.home-hero-highlight {
    color: var(--home-green);
    background-image: linear-gradient(transparent 72%, rgba(242, 180, 65, 0.4) 72%);
}

.home-hero-text {
    margin: 0 0 28px 0;
    max-width: 560px;
    font-size: 17px;
    line-height: 1.75;
    color: var(--home-muted);
    text-wrap: pretty;
}

.home-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-hero-actions .home-btn {
    width: 100%;
}

.home-hero-note {
    margin: 16px 0 0 0;
    font-size: 15px;
    color: var(--home-muted);
}

.home-hero-note a {
    font-weight: 600;
    color: var(--home-green);
}

.home-hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin: 24px 0 0 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
    color: var(--home-muted);
}

.home-hero-points li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.home-hero-points .home-icon {
    padding: 3px;
    width: 20px;
    height: 20px;
    color: var(--home-green);
    background-color: var(--home-mint);
    border-radius: 50%;
    stroke-width: 3;
}

/* Hero visual (ตกแต่งเท่านั้น) */

.home-hero-visual {
    position: relative;
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 8px;
}

.home-ticket {
    position: relative;
    padding: 24px;
    color: #ffffff;
    background:
        radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.18) 0%, transparent 45%),
        linear-gradient(150deg, var(--home-green) 0%, var(--home-green-deep) 100%);
    border-radius: 24px;
    box-shadow: var(--home-shadow-lg);
    transform: rotate(-2deg);
    animation: home-bob 7s ease-in-out infinite;
}

.home-ticket-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.home-ticket-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 22px;
    background-color: rgba(255, 255, 255, 0.16);
    border-radius: 14px;
}

.home-ticket-label {
    margin: 0;
    font-size: 13px;
    opacity: 0.8;
}

.home-ticket-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.home-ticket-number {
    margin: 20px 0 0 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 3px;
}

.home-ticket-divider {
    margin: 18px -24px;
    border-top: 2px dashed rgba(255, 255, 255, 0.28);
}

.home-ticket-steps {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.home-ticket-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.7;
}

.home-ticket-steps li span {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
}

.home-ticket-steps li.is-done {
    opacity: 1;
}

.home-ticket-steps li.is-done span {
    background-color: var(--home-amber);
    border-color: var(--home-amber);
}

.home-float {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--home-ink);
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--home-line);
    border-radius: 14px;
    box-shadow: var(--home-shadow-sm);
    animation: home-bob 6s ease-in-out infinite;
}

.home-float .home-icon {
    font-size: 16px;
    color: var(--home-green);
}

.home-float-1 {
    top: 0;
    right: 0;
    animation-delay: -2s;
}

.home-float-2 {
    bottom: 4px;
    left: 0;
    animation-delay: -4s;
}

.home-float-2 .home-icon {
    padding: 2px;
    width: 18px;
    height: 18px;
    color: #ffffff;
    background-color: var(--home-green);
    border-radius: 50%;
    stroke-width: 3;
}

/* ---------- Sections ---------- */

.home-section {
    padding: 56px 0;
    scroll-margin-top: 72px;
}

.home-section-tint {
    background:
        linear-gradient(180deg, rgba(228, 244, 237, 0.6) 0%, rgba(228, 244, 237, 0.15) 100%);
    border-top: 1px solid var(--home-line);
    border-bottom: 1px solid var(--home-line);
}

.home-section-head {
    max-width: 640px;
    margin: 0 0 28px 0;
}

.home-kicker {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--home-green);
}

.home-section-title {
    margin: 0 0 8px 0;
    font-size: clamp(24px, 5vw, 34px);
    line-height: 1.35;
    text-wrap: balance;
}



/* ---------- Training cards ---------- */

.home-training-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.home-training-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 22px;
    background-color: #ffffff;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius);
    box-shadow: var(--home-shadow-sm);
    overflow: hidden;
    animation: home-fade-up 0.6s var(--home-ease) both;
    animation-delay: calc(var(--i, 0) * 70ms);
    transition: transform 0.3s var(--home-ease), box-shadow 0.3s ease, border-color 0.3s ease;
}

.home-training-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--home-green) 0%, #22b07f 60%, var(--home-amber) 100%);
    transform: scaleX(0.25);
    transform-origin: left;
    transition: transform 0.4s var(--home-ease);
}

.home-training-card:hover {
    transform: translateY(-4px);
    border-color: var(--home-mint-strong);
    box-shadow: var(--home-shadow-lg);
}

.home-training-card:hover::before {
    transform: scaleX(1);
}

.home-training-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.home-training-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    font-size: 22px;
    color: var(--home-green);
    background-color: var(--home-mint);
    border-radius: 14px;
    transition: transform 0.3s var(--home-ease), background-color 0.3s ease, color 0.3s ease;
}

.home-training-card:hover .home-training-icon {
    color: #ffffff;
    background-color: var(--home-green);
    transform: rotate(-6deg) scale(1.05);
}

.home-training-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--home-green-dark);
    background-color: var(--home-mint);
    border-radius: 999px;
    white-space: nowrap;
}

.home-training-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: var(--home-green);
    border-radius: 50%;
}

.home-training-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-training-meta {
    display: grid;
    gap: 10px;
    margin: auto 0 0 0;
    padding-top: 16px;
    border-top: 1px dashed var(--home-line);
}

.home-training-meta-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    font-size: 14px;
    color: var(--home-muted);
}

.home-training-meta-icon {
    margin-top: 3px;
    font-size: 16px;
    color: var(--home-green);
}

.home-training-meta-value {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Skeleton (กำลังโหลด) */

.home-skeleton-card {
    display: grid;
    gap: 12px;
    padding: 22px;
    background-color: #ffffff;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius);
}

.home-skeleton-card span {
    display: block;
    height: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, #edf2f0 25%, #f7faf9 50%, #edf2f0 75%);
    background-size: 200% 100%;
    animation: home-shimmer 1.4s ease-in-out infinite;
}

.home-skeleton-card span:nth-child(1) { width: 46px; height: 46px; border-radius: 14px; margin-bottom: 4px; }
.home-skeleton-card span:nth-child(2) { width: 85%; height: 18px; }
.home-skeleton-card span:nth-child(3) { width: 60%; margin-top: 12px; }
.home-skeleton-card span:nth-child(4) { width: 45%; }

/* Empty / Error */

.home-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 44px 20px;
    text-align: center;
    background-color: #ffffff;
    border: 1px dashed var(--home-mint-strong);
    border-radius: var(--home-radius);
    animation: home-fade-up 0.5s var(--home-ease) both;
}

.home-state-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    font-size: 28px;
    color: var(--home-green);
    background-color: var(--home-mint);
    border-radius: 20px;
}

.home-state-title {
    margin: 0 0 6px 0;
    font-size: 18px;
}

.home-state-text {
    max-width: 420px;
    margin: 0;
    color: var(--home-muted);
}

.home-state-error {
    background-color: #fff7f6;
    border: 1px solid #f3c7c2;
}

.home-state-error .home-state-icon {
    color: #b42318;
    background-color: #fdecea;
}

.home-state-error .home-btn {
    margin-top: 20px;
}

/* ---------- Steps ---------- */

.home-steps {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.home-step {
    position: relative;
    min-width: 0;
    padding-left: 60px;
}

/* เส้นเชื่อมแนวตั้ง (มือถือ) */
.home-step::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: -14px;
    left: 21px;
    width: 2px;
    background: repeating-linear-gradient(180deg, var(--home-mint-strong) 0 6px, transparent 6px 12px);
}

.home-step:first-child::before {
    top: 22px;
}

.home-step:last-child::before {
    bottom: auto;
    height: 22px;
}

.home-step-num {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 16px;
    font-weight: 700;
    color: var(--home-muted);
    background-color: #ffffff;
    border: 2px solid var(--home-line);
    border-radius: 50%;
}

.home-step.is-active .home-step-num {
    color: #ffffff;
    background-color: var(--home-green);
    border-color: var(--home-green);
    box-shadow: 0 0 0 6px rgba(11, 110, 79, 0.14);
}

.home-step-card {
    position: static;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 18px 18px 20px 18px;
    color: inherit;
    text-decoration: none;
    background-color: #ffffff;
    border: 1px solid var(--home-line);
    border-radius: 18px;
    transition: transform 0.3s var(--home-ease), box-shadow 0.3s ease, border-color 0.3s ease;
}

a.home-step-card {
    border-color: var(--home-mint-strong);
    box-shadow: var(--home-shadow-sm);
}

a.home-step-card:hover {
    transform: translateY(-4px);
    border-color: var(--home-green);
    box-shadow: var(--home-shadow-lg);
}

.home-step-card.is-disabled {
    background-color: rgba(255, 255, 255, 0.6);
    border-style: dashed;
}

.home-step-card.is-disabled:hover {
    transform: translateY(-2px);
    background-color: #ffffff;
}

.home-step-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    font-size: 22px;
    color: var(--home-muted);
    background-color: #f0f4f2;
    border-radius: 14px;
    transition: transform 0.3s var(--home-ease);
}

.home-step.is-active .home-step-icon {
    color: var(--home-green);
    background-color: var(--home-mint);
}

.home-step-card:hover .home-step-icon {
    transform: scale(1.08) rotate(-4deg);
}

.home-step-title {
    margin: 0 0 4px 0;
    font-size: 17px;
    line-height: 1.4;
}

.home-step-text {
    margin: 0 0 14px 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--home-muted);
}

.home-step-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: auto;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--home-muted);
    background-color: #f0f4f2;
    border-radius: 999px;
}

.home-step-tag-active {
    color: var(--home-green-dark);
    background-color: var(--home-mint);
}

.home-step-tag-active .home-icon {
    transition: transform 0.25s var(--home-ease);
}

a.home-step-card:hover .home-step-tag-active .home-icon {
    transform: translateX(3px);
}

/* ---------- CTA + Footer ---------- */

.home-cta {
    padding: 56px 0;
}

.home-cta-box {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 24px;
    padding: 32px 24px;
    color: #ffffff;
    background:
        radial-gradient(circle at 90% 10%, rgba(242, 180, 65, 0.35) 0%, transparent 40%),
        linear-gradient(135deg, var(--home-green) 0%, var(--home-green-deep) 100%);
    border-radius: 28px;
    box-shadow: var(--home-shadow-lg);
}

.home-cta-title {
    margin: 0 0 6px 0;
    font-size: clamp(22px, 4.6vw, 30px);
    line-height: 1.35;
    text-wrap: balance;
}

.home-cta-text {
    margin: 0;
    opacity: 0.9;
}

.home-cta-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-footer {
    padding: 24px 0 32px 0;
    font-size: 14px;
    color: var(--home-muted);
    text-align: center;
    border-top: 1px solid var(--home-line);
}

.home-footer p {
    margin: 0;
}

/* ---------- Animations ---------- */

.home-reveal {
    animation: home-fade-up 0.7s var(--home-ease) both;
    animation-delay: calc(var(--d, 0) * 80ms);
}

/* ลำดับ Animation ของหน้าแรก (เดิมกำหนดด้วย style="--d: N" ใน HTML ซึ่ง CSP style-src บล็อก) */
.home-hero-title.home-reveal { --d: 1; }
.home-hero-text.home-reveal { --d: 2; }
.home-hero-actions.home-reveal,
.home-hero-visual.home-reveal { --d: 3; }

@keyframes home-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes home-float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-24px, 18px); }
}

@keyframes home-bob {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -8px; }
}

@keyframes home-pulse {
    0% { box-shadow: 0 0 0 0 rgba(11, 110, 79, 0.45); }
    80%, 100% { box-shadow: 0 0 0 8px rgba(11, 110, 79, 0); }
}

@keyframes home-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 379px) {
    .home-brand-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }
}

@media (min-width: 640px) {
    .home-shell,
    .home-header-inner {
        padding-left: 24px;
        padding-right: 24px;
    }

    .home-brand-text {
        font-size: 17px;
    }

    .home-nav {
        gap: 8px;
    }

    .home-nav-link,
    .home-nav-cta {
        padding: 0 18px;
        font-size: 15px;
    }

    .home-hero-actions,
    .home-cta-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .home-hero-actions .home-btn {
        width: auto;
    }

    .home-training-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    .home-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .home-step {
        padding-left: 0;
        padding-top: 0;
    }

    .home-step::before {
        display: none;
    }

    .home-step-num {
        top: 16px;
        left: auto;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .home-step-card {
        position: relative;
    }

    .home-step {
        position: relative;
    }

    .home-cta-box {
        padding: 40px;
    }
}

@media (min-width: 768px) {
    .home-hero {
        padding: 64px 0 72px 0;
    }

    .home-section,
    .home-cta {
        padding: 72px 0;
    }

    .home-hero-text {
        font-size: 18px;
    }
}

@media (min-width: 960px) {
    .home-hero-inner {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
        gap: 48px;
    }

    .home-hero-visual {
        margin-right: 0;
    }

    .home-training-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Timeline แนวนอนพร้อมเส้นเชื่อม */
    .home-steps {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 16px;
        padding-top: 64px;
    }

    .home-steps::before {
        content: '';
        position: absolute;
        top: 21px;
        left: 10%;
        right: 10%;
        height: 2px;
        background: repeating-linear-gradient(90deg, var(--home-mint-strong) 0 8px, transparent 8px 16px);
    }

    .home-steps::after {
        content: '';
        position: absolute;
        top: 21px;
        left: 10%;
        width: 20%;
        height: 2px;
        background: linear-gradient(90deg, var(--home-green), var(--home-mint-strong));
    }

    .home-step-num {
        top: -64px;
        left: 50%;
        right: auto;
        width: 44px;
        height: 44px;
        font-size: 16px;
        transform: translateX(-50%);
    }

    .home-step-card {
        position: static;
        text-align: left;
    }

    .home-cta-box {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        padding: 48px 56px;
    }
}

@media (min-width: 1280px) {
    .home-hero {
        padding: 88px 0 96px 0;
    }

    .home-hero-inner {
        gap: 72px;
    }

    .home-training-grid {
        gap: 24px;
    }

    .home-steps {
        gap: 20px;
    }

    .home-step-card {
        padding: 22px 20px 24px 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-page *,
    .home-page *::before,
    .home-page *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .home-ticket {
        transform: none;
    }
}

/* ============================= */
/* AUTH PAGES: Login + Signup (Modern Premium) */
/* เพิ่มต่อท้ายเท่านั้น ใช้ prefix .auth- ทุก class ไม่กระทบหน้าอื่น | Mobile-first: 640px / 960px / 1280px */
/* ============================= */

.auth-body {
    --auth-accent: var(--color-accent);
    --auth-accent-dark: var(--color-accent-dark);
    --auth-mint: #e4f4ed;
    --auth-deep: #06392a;
    --auth-ring: rgba(11, 110, 79, 0.18);
    min-height: 100vh;
    background-color: var(--color-page);
    background-image:
        radial-gradient(circle at 12% 8%, rgba(11, 110, 79, 0.10) 0, transparent 38%),
        radial-gradient(circle at 92% 92%, rgba(26, 163, 122, 0.10) 0, transparent 40%);
    background-attachment: fixed;
    overflow-x: hidden;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

/* ---------- ฝั่ง Branding ---------- */

.auth-aside {
    display: none;
}

.auth-aside-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
}

.auth-aside-body {
    max-width: 460px;
}


.auth-aside-title {
    margin: 0 0 14px 0;
    font-size: 34px;
    line-height: 1.35;
    font-weight: 700;
    color: #ffffff;
    text-wrap: balance;
}

.auth-aside-text {
    margin: 0 0 32px 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.78);
    text-wrap: pretty;
}

.auth-feature-list,
.auth-steps {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-feature,
.auth-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.92);
    background-color: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    backdrop-filter: blur(6px);
}

.auth-step strong {
    color: #ffffff;
}

.auth-feature-icon,
.auth-step-number {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
}

.auth-feature-icon svg {
    width: 20px;
    height: 20px;
}

.auth-step-number {
    font-weight: 700;
    border-radius: 999px;
}

.auth-aside-foot {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

/* ---------- Brand / Logo ---------- */

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--color-ink);
    text-decoration: none;
}

.auth-brand-light {
    color: #ffffff;
}

.auth-brand-mark {
    width: 40px;
    height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    background: linear-gradient(135deg, var(--auth-accent) 0%, #1aa37a 100%);
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(11, 110, 79, 0.28);
}

.auth-brand-light .auth-brand-mark {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.auth-brand-mark svg {
    width: 22px;
    height: 22px;
}

.auth-brand:focus-visible {
    outline: 3px solid var(--auth-ring);
    outline-offset: 4px;
    border-radius: 12px;
}

.auth-brand-mobile {
    margin-bottom: 24px;
}

/* ---------- ฝั่ง Form ---------- */

.auth-main {
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 28px 20px;
    background-color: var(--color-card);
    border: 1px solid rgba(213, 220, 218, 0.8);
    border-radius: 20px;
    box-shadow:
        0 1px 2px rgba(28, 43, 42, 0.04),
        0 18px 48px -12px rgba(28, 43, 42, 0.16);
    container-type: inline-size;
    animation: auth-rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.auth-card-wide {
    max-width: 560px;
}

.auth-card-header {
    margin-bottom: 8px;
}

.auth-title {
    margin: 0 0 6px 0;
    font-size: 26px;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.auth-subtitle {
    margin: 0;
    font-size: 15px;
}

.auth-form {
    margin-top: 8px;
}

.auth-group {
    min-width: 0;
}

.auth-label {
    margin: 18px 0 8px 0;
    font-size: 14px;
    color: var(--color-ink);
}

.auth-grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 14px;
}

@container (min-width: 480px) {
    .auth-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---------- ช่องกรอก + Icon ---------- */

.auth-field {
    position: relative;
}

.auth-field-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    color: #8a9896;
    transform: translateY(-50%);
    pointer-events: none;
    transition: color 0.2s ease;
}

.auth-input {
    min-height: 50px;
    padding: 12px 14px 12px 44px;
    background-color: #fbfcfc;
    border: 1px solid var(--color-line);
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-input::placeholder {
    color: #9aa6a4;
}

.auth-input:hover {
    border-color: #b9c4c1;
}

.auth-input:focus {
    outline: none;
    background-color: #ffffff;
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 4px var(--auth-ring);
}

.auth-field:focus-within .auth-field-icon {
    color: var(--auth-accent);
}

.auth-field-password .auth-input {
    padding-right: 52px;
}

/* ซ่อนปุ่มลูกตาของ Edge/IE เพื่อไม่ให้ซ้อนกับปุ่มของเรา */
.auth-input::-ms-reveal,
.auth-input::-ms-clear {
    display: none;
}

/* ---------- ปุ่มลูกตา ---------- */

.auth-toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    color: #6b7a78;
    background: transparent;
    border: 0;
    border-radius: 10px;
    transform: translateY(-50%);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.auth-toggle:hover {
    color: var(--auth-accent);
    background-color: var(--auth-mint);
}

.auth-toggle:focus-visible {
    outline: 3px solid var(--auth-ring);
    outline-offset: 0;
    color: var(--auth-accent);
}

.auth-toggle svg {
    width: 20px;
    height: 20px;
}

.auth-toggle .auth-toggle-hide,
.auth-toggle[aria-pressed="true"] .auth-toggle-show {
    display: none;
}

.auth-toggle[aria-pressed="true"] .auth-toggle-hide {
    display: block;
}

.auth-card .field-hint {
    margin-top: 6px;
    font-size: 12.5px;
}

/* ---------- ปุ่มส่งฟอร์ม + Loading ---------- */

.auth-submit {
    position: relative;
    min-height: 52px;
    margin-top: 26px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--auth-accent) 0%, #108a62 100%);
    border-radius: 12px;
    box-shadow: 0 10px 22px -8px rgba(11, 110, 79, 0.55);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.auth-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--auth-accent-dark) 0%, var(--auth-accent) 100%);
    box-shadow: 0 14px 28px -10px rgba(11, 110, 79, 0.6);
    transform: translateY(-1px);
}

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

.auth-submit:disabled {
    opacity: 0.85;
    box-shadow: none;
}

/* Spinner แสดงเฉพาะตอน JS เดิมตั้ง disabled ระหว่างส่งข้อมูล */
.auth-submit:disabled::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

/* ---------- ข้อความแจ้งเตือน ---------- */

.auth-card .message {
    margin-top: 16px;
    padding: 12px 14px;
    font-size: 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    animation: auth-fade 0.25s ease both;
}

.auth-card .message-error {
    border-color: #f5c2bd;
}

.auth-card .message-success {
    border-color: #b7e2cf;
}

/* ---------- ลิงก์ด้านล่าง ---------- */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 4px 0;
    font-size: 13px;
    color: #9aa6a4;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--color-line);
}

.auth-card .auth-switch a {
    text-decoration: none;
    border-radius: 4px;
}

.auth-card .auth-switch a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-card .auth-switch a:focus-visible {
    outline: 3px solid var(--auth-ring);
    outline-offset: 2px;
}

.auth-back {
    margin-top: 10px;
}

.auth-card .auth-back a {
    font-weight: 400;
    color: var(--color-muted);
}

/* ---------- ลืมรหัสผ่าน (ลิงก์ใต้ช่องรหัสผ่าน + ฟอร์มใน SweetAlert2) ---------- */

.auth-forgot {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 12px;
}

.auth-forgot-link {
    padding: 6px 2px;
    min-height: 36px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent);
    background: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}

.auth-forgot-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-forgot-link:focus-visible {
    outline: 3px solid var(--auth-ring);
    outline-offset: 2px;
}

.form-dialog-popup .forgot-form {
    text-align: left;
}

.form-dialog-popup .forgot-note {
    margin: 0 0 12px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #8a5a00;
    background-color: #fff3d6;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.form-dialog-popup .forgot-field {
    margin-bottom: 12px;
}

.form-dialog-popup .forgot-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}

.form-dialog-popup .forgot-field .field-input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 16px;
}

.form-dialog-popup .forgot-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

@media (max-width: 520px) {
    .form-dialog-popup .forgot-row {
        grid-template-columns: 1fr;
    }
}

/* 1-12-69: ลืมรหัสผ่านแบบ 2 ขั้น — ตัวใหญ่ อ่านง่าย (ผู้สูงอายุ) */
.form-dialog-popup .forgot-big .forgot-field label {
    font-size: 16px;
    line-height: 1.5;
}

.form-dialog-popup .forgot-big .field-input {
    min-height: 52px;
    font-size: 18px;
}

.form-dialog-popup .forgot-account {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 14px;
    padding: 12px 14px;
    text-align: center;
    background-color: #e4f4ed;
    border: 1px solid #b7dfcc;
    border-radius: 12px;
}

.form-dialog-popup .forgot-account-label {
    font-size: 14px;
    color: #42504e;
}

.form-dialog-popup .forgot-account-name {
    font-size: 22px;
    line-height: 1.35;
    color: #0b6e4f;
    overflow-wrap: anywhere;
}

.form-dialog-popup .forgot-pass {
    position: relative;
}

.form-dialog-popup .forgot-pass .field-input {
    padding-right: 54px;
}

.form-dialog-popup .forgot-eye {
    position: absolute;
    top: 50%;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    color: #5d6b69;
    background: transparent;
    border: 0;
    border-radius: 8px;
    transform: translateY(-50%);
    cursor: pointer;
}

.form-dialog-popup .forgot-eye[aria-pressed="true"] {
    color: #0b6e4f;
}

/* ---------- Animation ---------- */

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
    .auth-main {
        padding: 40px 24px;
    }

    .auth-card {
        padding: 36px 36px 32px 36px;
    }

    .auth-title {
        font-size: 28px;
    }
}

@media (min-width: 960px) {
    .auth-shell {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    }

    .auth-shell-signup {
        grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    }

    .auth-aside {
        position: relative;
        display: block;
        padding: 40px 44px;
        overflow: hidden;
        background:
            linear-gradient(160deg, #0b6e4f 0%, #084f39 55%, var(--auth-deep) 100%);
    }

    /* ลายตกแต่งแบบ Abstract: วงแสง + ตาราง (CSS ล้วน ไม่โหลดรูป) */
    .auth-aside::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
        background-size: 44px 44px;
        mask-image: radial-gradient(circle at 30% 30%, #000 0, transparent 70%);
        -webkit-mask-image: radial-gradient(circle at 30% 30%, #000 0, transparent 70%);
    }

    .auth-aside::after {
        content: "";
        position: absolute;
        right: -120px;
        bottom: -120px;
        width: 380px;
        height: 380px;
        background: radial-gradient(circle, rgba(26, 163, 122, 0.55) 0, rgba(26, 163, 122, 0) 70%);
        border-radius: 50%;
    }

    .auth-brand-mobile {
        display: none;
    }

    .auth-main {
        padding: 48px 40px;
    }
}

@media (min-width: 1280px) {
    .auth-aside {
        padding: 56px 64px;
    }

    .auth-aside-title {
        font-size: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card,
    .auth-card .message {
        animation: none;
    }

    .auth-input,
    .auth-toggle,
    .auth-submit,
    .auth-field-icon {
        transition: none;
    }

    .auth-submit:disabled::before {
        animation-duration: 1.6s;
    }
}


/* ============================= */
/* ตัวเลือกวันที่ภาษาไทย (ปี พ.ศ.) — ใช้ร่วมทุกหน้า (ค่าที่ส่ง Backend ยังเป็น ISO ค.ศ.) */
/* ============================= */

.field-input.thai-date-input {
    cursor: pointer;
    caret-color: transparent;
    text-overflow: ellipsis;
}

.field-input.thai-date-input[aria-expanded="true"] {
    border-color: var(--color-accent);
}

.thai-dp-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: transparent;
}

.thai-dp-backdrop.is-dim {
    background: rgba(18, 28, 27, 0.45);
}

.thai-dp {
    position: fixed;
    z-index: 3001;
    width: 304px;
    max-width: calc(100vw - 16px);
    padding: 12px;
    background: var(--color-card);
    color: var(--color-ink);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-card);
    box-shadow: 0 12px 32px rgba(18, 28, 27, 0.22);
    font-size: 15px;
    line-height: 1.4;
    outline: none;
}

.thai-dp-head {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 84px 36px;
    gap: 6px;
    align-items: center;
    margin-bottom: 10px;
}

.thai-dp-nav {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--color-ink);
    background: #fff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    cursor: pointer;
}

.thai-dp-nav:hover:not(:disabled),
.thai-dp-action:hover:not(:disabled) {
    background: var(--color-success-bg);
    border-color: var(--color-accent);
}

.thai-dp-nav:disabled,
.thai-dp-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.thai-dp-select {
    min-width: 0;
    min-height: 36px;
    padding: 4px 6px;
    font: inherit;
    color: var(--color-ink);
    background: #fff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
}

.thai-dp-week,
.thai-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.thai-dp-weekday {
    padding: 4px 0;
    text-align: center;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-muted);
}

.thai-dp-day {
    min-height: 36px;
    padding: 0;
    font: inherit;
    color: var(--color-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-field);
    cursor: pointer;
}

.thai-dp-day:hover:not(:disabled) {
    background: var(--color-success-bg);
}

.thai-dp-day.is-today {
    border-color: var(--color-accent);
}

.thai-dp-day.is-selected {
    color: #fff;
    background: var(--color-accent);
    font-weight: 700;
}

.thai-dp-day:disabled {
    color: #a7b1af;
    text-decoration: line-through;
    cursor: not-allowed;
}

.thai-dp-day:focus-visible,
.thai-dp-nav:focus-visible,
.thai-dp-select:focus-visible,
.thai-dp-action:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

.thai-dp-foot {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-line);
}

.thai-dp-action {
    flex: 1 1 0;
    min-height: 36px;
    padding: 4px 8px;
    font: inherit;
    font-size: 14px;
    color: var(--color-ink);
    background: #fff;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-field);
    cursor: pointer;
}

/* มือถือ: แสดงเป็นแผงเลื่อนจากด้านล่าง ปุ่มใหญ่ขึ้นให้กดง่าย */
@media (max-width: 560px) {
    .thai-dp.is-sheet {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: auto;
        max-width: none;
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
        border-radius: var(--radius-card) var(--radius-card) 0 0;
    }

    .thai-dp.is-sheet .thai-dp-head {
        grid-template-columns: 44px minmax(0, 1fr) 96px 44px;
    }

    .thai-dp.is-sheet .thai-dp-nav,
    .thai-dp.is-sheet .thai-dp-select,
    .thai-dp.is-sheet .thai-dp-action {
        min-height: 44px;
    }

    .thai-dp.is-sheet .thai-dp-day {
        min-height: 44px;
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .thai-dp.is-sheet {
        animation: thai-dp-rise 0.16s ease-out;
    }

    @keyframes thai-dp-rise {
        from { transform: translateY(16px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
}
/* รอบ 1 (29-11-69): ย่อรูปหลักฐานลงทะเบียนเข้าเรียนให้เล็กลง */
.attendance-preview-img {
    max-height: 220px;
}

.attendance-thumb {
    width: 84px;
    height: 84px;
}

@media (max-width: 639px) {
    .attendance-thumb {
        width: 72px;
        height: 72px;
    }
}

/* ===== 29-11-69: ผลการอบรม/เกียรติบัตรในกล่องข้อมูลเทียบโอน ===== */
.pf-result { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #dfe7e3; }
.pf-result-status { font-weight: 700; }
.pf-result-passed { color: #0b6e4f; }
.pf-result-below { color: #b3541e; }
.pf-result-hold { color: #8a6d00; }
.pf-result-failed { color: #b42318; }
.pf-result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pf-result-actions .button { flex: 1 1 200px; text-align: center; text-decoration: none; }

/* ============================= */
/* 1-12-69: ชื่อมหาวิทยาลัยตัวเล็กใต้ "RAS Connect" (หน้าแรก home-brand / ล็อกอิน-สมัคร auth-brand) */
/* ============================= */

.brand-stack {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    line-height: 1.15;
}

.brand-sub {
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--color-muted);
}

.home-brand-sub {
    color: var(--color-accent);
    opacity: 0.85;
}

.auth-brand-light .auth-brand-sub {
    color: rgba(255, 255, 255, 0.78);
}

.auth-brand-mobile .auth-brand-sub {
    color: var(--color-accent);
}

@media (max-width: 379px) {
    .brand-sub {
        font-size: 9.5px;
        letter-spacing: 0.08em;
    }

    /* จอแคบมาก: หน้าแรกซ่อนชื่อแบรนด์ไว้แล้ว (เหลือแต่โลโก้) ให้ซ่อนชื่อมหาวิทยาลัยด้วย */
    .home-brand-sub {
        display: none;
    }
}

/* จอมือถือ: ตัวเล็กลงและชิดขึ้น ไม่ให้ชนเมนู "เข้าสู่ระบบ / สมัครสมาชิก" */
@media (max-width: 639px) {
    .home-brand-sub {
        font-size: 9px;
        letter-spacing: 0.02em;
    }
}

@media (min-width: 640px) {
    .brand-sub {
        font-size: 11px;
    }
}
