/* login.css — standalone lightweight, ไม่พึ่ง template bundle เดิม (ตาม decision เรื่อง first-load เร็ว) */

@font-face {
    font-family: "ChulabhornLikit";
    src: url("../fonts/chulabhornlikittext-regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "ChulabhornLikit";
    src: url("../fonts/chulabhornlikittext-medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "ChulabhornLikit";
    src: url("../fonts/chulabhornlikittext-bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    --edoc-bg: #07234d;
    --edoc-blue: #3b7ddd;
    --edoc-red: #e6564f;
    --edoc-orange: #f2a154;
    --form-text: #1a1a1a;
    --form-muted: #5a5a5a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "ChulabhornLikit", system-ui, "Segoe UI", sans-serif;
    background: var(--edoc-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #e0dfd7;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 32px 28px;
    color: var(--form-text);
    box-shadow: none;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.login-brand img.logo {
    width: 56px;
    height: auto;
    border-radius: 0;
}
.login-brand .title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
}
.login-brand .title small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--form-muted);
}

.form-group {
    margin-bottom: 16px;
}
label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--form-muted);
}

.input-wrap {
    position: relative;
}

.input-group {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
}

.input-group .form-control {
    flex: 1 1 auto;
    min-width: 0;
    width: 1%;
    height: 44px;
    padding: 0 12px;
    border-radius: 8px 0 0 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-right: 0;
    background: #fff;
    color: var(--form-text);
    font-size: 14px;
    font-family: inherit;
}

.input-group-text {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: #ecebe4;
    color: var(--form-muted);
    font-size: 13px;
    white-space: nowrap;
}

.input-group:focus-within .form-control,
.input-group:focus-within .input-group-text {
    border-color: var(--edoc-blue);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-check-input {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 0;
}
.form-check-label {
    font-size: 13px;
    color: var(--form-text);
    white-space: nowrap;
}

.form-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--form-muted);
    text-align: center;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #fff;
    color: var(--form-text);
    font-size: 14px;
    font-family: inherit;
}
input:focus {
    outline: none;
    border-color: var(--edoc-blue);
}

.btn-eye {
    position: absolute;
    right: 6px;
    top: 6px;
    height: 32px;
    width: 32px;
    border: none;
    background: transparent;
    color: var(--form-muted);
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--edoc-blue);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-primary:hover:not(:disabled) {
    background: #2f6bc4;
}

.btn-google {
    width: 100%;
    height: 44px;
    margin-top: 10px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    background: #fff;
    color: var(--form-text);
    font-size: 14px;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
}
.btn-google:hover {
    background: #f5f5f5;
}

.btn-dev {
    width: 100%;
    height: 40px;
    border: 1px dashed rgba(59, 125, 221, 0.6);
    border-radius: 8px;
    background: rgba(59, 125, 221, 0.08);
    color: var(--edoc-blue);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.btn-dev:hover {
    background: rgba(59, 125, 221, 0.15);
}

.error-box {
    background: #fce8e7;
    border: 1px solid rgba(230, 86, 79, 0.35);
    color: #5a1612;
    font-size: 13px;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

.success-box {
    background: #e6f5ec;
    border: 1px solid rgba(45, 150, 90, 0.35);
    color: #0f4d30;
    font-size: 13px;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

/* รายการ error หลายข้อจาก PasswordPolicy — แสดงพร้อมกันทุกข้อในกล่องเดียว */
.hint-list {
    margin: 6px 0 0;
    padding-left: 18px;
}
.hint-list li {
    margin-bottom: 2px;
}

/* ลิงก์รอง เช่น "ลืมรหัสผ่าน?" / "กลับไปหน้าเข้าสู่ระบบ" */
.link-muted {
    display: inline-block;
    font-size: 12px;
    color: var(--form-muted);
    text-decoration: none;
}
.link-muted:hover {
    color: var(--edoc-blue);
    text-decoration: underline;
}
.link-row {
    margin-top: 10px;
    text-align: center;
}

/* ตัวนับความยาวรหัสผ่าน (assets/js/reset-password.js) */
.pw-counter {
    font-size: 12px;
    color: var(--form-muted);
    margin-top: 6px;
    display: block;
}
.pw-counter.ok {
    color: #1f7a4d;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--form-muted);
}

/* overlay busy บนการ์ด login/otp ระหว่างรอ htmx request */
#login-card-body,
#verify-otp-card-body,
#forgot-card-body,
#reset-card-body {
    position: relative;
}

.login-busy {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(224, 223, 215, 0.92);
    color: var(--edoc-blue);
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    z-index: 2;
    pointer-events: all;
}

#login-card-body.htmx-request .login-busy,
#verify-otp-card-body.htmx-request .login-busy,
#forgot-card-body.htmx-request .login-busy,
#reset-card-body.htmx-request .login-busy {
    display: flex;
}

#login-card-body.htmx-request .error-box,
#verify-otp-card-body.htmx-request .error-box,
#forgot-card-body.htmx-request .error-box,
#reset-card-body.htmx-request .error-box {
    display: none;
}

.htmx-request .btn-primary-label {
    display: none;
}
.htmx-request .btn-primary-spinner {
    display: inline !important;
    text-align: center;
}
.btn-primary-spinner {
    display: none;
}
