﻿/* กัน flash หลัง login */
html.postlogin body {
    overflow: hidden;
}

#BootSplashFull {
    display: none;
}

.main-shell {
    display: block;
}

html.postlogin .main-shell {
    display: none !important;
}

html.postlogin #BootSplashFull {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    align-items: center;
    justify-content: center;
    background: var(--boot-splash-background-color);
}

.boot-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--boot-spinner-border-color);
    border-top-color: var(--boot-spinner-active-border-color);
    border-radius: 50%;
    animation: boot-spin 1s linear infinite;
}

@keyframes boot-spin {
    to {
        transform: rotate(360deg);
    }
}

/*แถบ Error ของ Blazor ด้านล่าง*/
#blazor-error-ui {
    color-scheme: light only;
    background: var(--blazor-error-background-color);
    bottom: 0;
    box-shadow: var(--blazor-error-box-shadow);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

body {
    font-family: "Anuphan", sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 12px;
    color: var(--rz-primary);
}

.primary-color {
    color: var(--rz-primary) !important;
}

.content {
    padding-top: 1.1rem;
}

.content-card {
    padding: var(--content-card-padding) !important; /* กำหนดระยะ padding ของ card */
    margin: var(--content-card-margin); /* กำหนดระยะ margin ของ card */
    background-color: var(--content-card-background-color) !important; /* กำหนดสี backgrouund ของ card */
    border: var(--content-card-border); /* ปรับสี border */
    border-radius: var(--content-card-border-radius) !important; /* ปรับความโค้งมนของขอบ card */
    box-shadow: var(--content-card-box-shadow) !important; /* กำหนดเงาให้ card */
}

.content-space {
    margin: 0.5rem 0rem 0.5rem 0rem;
}

.content-button-bar {
    min-width: 7.1875rem !important;
}

.layout-header {
    border-width: 0px;
    border-block: none;
    box-shadow: none !important;
}

.layout-logo-image-container {
    height: 70px;
    width: 300px;
    display: flex;
    align-items: center;
}

img.layout-logo-image {
    height: 80px;
    padding: 0.75rem 0;
}

.layout-user-container {
    height: 70px;
    width: 100vw;
    display: flex;
    justify-content: right;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

.layout-footer {
    font-size: 12px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 1rem;
}

.layout-footer-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.layout-footer-right {
    margin-left: auto;
}

.hamburger-button {
    margin: 10px 0px;
    padding: 20px;
    border: none;
    color: var(--hamburger-button-color) !important;
    background-color: transparent !important;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 0.25rem solid transparent;
    border-top-color: var(--rz-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.image-loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.circle-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    text-align: center;
    border-radius: 50%;
    border: var(--circle-icon-border);
    box-shadow: var(--circle-icon-box-shadow);
    color: var(--circle-icon-color);
    background-color: var(--circle-icon-background-color);
}

    .circle-icon i {
        font-size: 20px;
        width: auto;
        height: auto;
    }

.change-password-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100px;
    height: 100px;
    text-align: center;
    border-radius: 50%;
    border: var(--change-password-icon-border);
    box-shadow: var(--change-password-icon-box-shadow);
    color: var(--change-password-icon-color);
    background-color: var(--change-password-icon-background-color);
}

    .change-password-icon i {
        font-size: 50px;
        width: auto;
        height: auto;
    }

.icon-info {
    color: var(--icon-info);
}

.icon-warning {
    color: var(--icon-warning);
}

.icon-error {
    color: var(--icon-error);
}

.notification-wrapper {
    position: relative;
    display: inline-block;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--noti-badge-background-color);
    color: var(--noti-badge-color);
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    min-width: 18px;
    text-align: center;
}

.rz-dialog {
    background-color: var(--dialog-background-color) !important; /* กำหนดสี background ของ dialog */
    border: var(--dialog-border); /* กำหนดสี border ของ dialog */
    border-radius: var(--dialog-border-radius) !important; /* ปรับความโค้งมนของขอบ dialog */
    box-shadow: var(--dialog-box-shadow) !important; /* กำหนดเงาให้ dialog */
    overflow: hidden; /* ป้องกันการ overflow ของ dialog */
}

.login-page-background {
    background-image: url('/images/Medlog/bg_under_fp.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    min-height: 100vh; /* ให้เต็มหน้าจอ */
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 1rem;
}

.login-card {
    padding: var(--content-card-padding) !important; /* กำหนดระยะ padding ของ card */
    margin: var(--content-card-margin); /* กำหนดระยะ margin ของ card */
    background-color: var(--content-card-background-color) !important; /* กำหนดสี backgrouund ของ card */
    border-radius: var(--content-card-border-radius) !important; /* ปรับความโค้งมนของขอบ card */
    box-shadow: var(--content-card-box-shadow) !important; /* กำหนดเงาให้ card */
}

/* Device Secret : วางปุ่ม refresh เป็น suffix ภายในกรอบ textbox
   ใช้ absolute + translateY(-50%) แทนการเลื่อนด้วย translateX เพราะ translateX
   จะขึ้นกับความกว้างของตัวปุ่มเอง ทำให้ตำแหน่งเพี้ยนเมื่อ font/ขนาดไอคอนเปลี่ยน */
.device-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.device-container .device-secret {
    width: 150px;
    padding-right: 2.25rem !important; /* เว้นที่ให้ปุ่ม refresh ไม่ทับตัวเลข secret */
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    text-align: center;
}

.device-container .device-button {
    position: absolute;
    top: 50%;
    right: 0.25rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    background: none;
    border-radius: 50%;
    color: inherit;
    opacity: 0.65;
    cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.device-container .device-button:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

.device-container .device-button:focus-visible {
    opacity: 1;
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.device-container .device-button i {
    line-height: 1;
    transition: transform 0.3s ease;
}

.device-container .device-button:active i {
    transform: rotate(180deg);
}

.field-fullwidth {
    display: flex;
    width: 100%;
}

.validate-message {
    color: var(--validate-color1);
    font-size: 12px;
    padding-top: 5px;
    padding-left: 5px;
    min-height: 25px;
    display: block;
}

/*.readonly-textbox {
    color: var(--readonly-textbox-color);
    background-color: var(--readonly-textbox-background-color);
    border: var(--readonly-textbox-border);
    cursor: not-allowed;
}*/

.readonly-textbox {
    color: red !important;
    background-color: transparent !important;
    border: none !important;
    cursor: not-allowed;
}

.column-inactive {
    color: var(--column-inactive-color);
}

/* Sidebar : ความกว้างตอนกาง (Radzen พับด้วยการ set width เป็น 0 เอง ห้ามเขียนทับ width ตรง ๆ) */
.rz-layout {
    --rz-sidebar-width: 300px;
}

/* Mobile: Sidebar drawer จากซ้าย + Backdrop */
@media (max-width: 767.98px) {
    /* แคบลงให้เหลือพื้นที่เนื้อหา โดยเปลี่ยนแค่ค่าตัวแปร เพื่อให้ .rz-sidebar-collapsed ยังทำงานได้ */
    .rz-layout {
        --rz-sidebar-width: 280px;
    }

    .rz-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100dvh !important;
        z-index: 1050 !important;
        overflow-y: auto;
        box-shadow: 4px 0 16px rgba(0,0,0,0.18) !important;
        /* Radzen animate ด้วย width/opacity ไม่ใช่ transform */
        transition: width 0.25s ease, opacity 0.25s ease;
    }

    /* ตอนพับต้องไม่กินคลิก ไม่งั้นจะบังปุ่ม hamburger ทั้งที่มองไม่เห็น (opacity:0 ยังรับ pointer events) */
    .rz-sidebar.rz-sidebar-collapsed {
        pointer-events: none;
    }

    .mobile-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1049;
    }

    /* โลโก้กว้างจริงแค่ ~172px แต่ container ตรึงไว้ 300px ทำให้เหลือที่ว่างเปล่า 128px
       บนจอ 360px จึงไม่เหลือพื้นที่ให้ชื่อผู้ Login จนถูกบีบตัดบรรทัดไปทับโลโก้ */
    .layout-logo-image-container {
        width: auto;
    }

    img.layout-logo-image {
        height: 40px;
        padding: 0;
    }

    /* ลด padding เพื่อคืนพื้นที่ให้ชื่อผู้ Login */
    .hamburger-button {
        padding: 12px;
    }

    /* จำกัดความกว้างชื่อ ส่วนที่เกินตัดด้วย ellipsis (ชื่อเต็มดูได้ใน ProfilePopup) */
    .profile-username {
        max-width: 96px;
        font-size: 0.85rem;
    }

    .rz-header {
        background-color: #E5D08B !important;
    }
}

@media (min-width: 768px) {
    .mobile-sidebar-backdrop {
        display: none;
    }
}

/* Form */
.input-group {
    position: relative;
    margin-bottom: 25px;
}

    .input-group label {
        display: block;
        margin-bottom: 8px;
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--login-text-color);
        transition: color var(--login-transition-speed);
    }

    .input-group input {
        width: 100%;
        padding: 14px 16px;
        border: 1px solid var(--login-input-border-color);
        border-radius: 10px;
        background-color: var(--login-input-background-color);
        font-size: 1rem;
        transition: all var(--login-transition-speed);
    }

        .input-group input:focus {
            outline: none;
            border-color: var(--login-primary-color);
            background-color: var(--rz-input-focus-background-color);
            box-shadow: var(--login-input-focus-box-shadow);
        }

            .input-group input:focus + .input-highlight {
                width: 100%;
            }

.input-highlight {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background-color: var(--login-primary-color);
    transition: width 0.4s ease;
    border-radius: 0 0 10px 10px;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--login-text-light-color);
    cursor: pointer;
    user-select: none;
}

    .remember-me input {
        accent-color: var(--login-primary-color);
        width: 16px;
        height: 16px;
    }

.forgot-password {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: var(--transparent-background-color);
    color: var(--login-secondary-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--login-transition-speed);
}

.back-to-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: var(--transparent-background-color);
    color: var(--login-secondary-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--login-transition-speed);
}

    .back-to-login:hover {
        color: var(--login-primary-color);
        text-decoration: underline;
    }

    .back-to-login:disabled {
        color: var(--login-text-light-color);
        cursor: default;
        text-decoration: none;
    }

/* Login Button */
.login-btn {
    position: relative;
    width: 100%;
    height: 50px;
    padding: 16px;
    background: var(--login-primary-gradient);
    color: var(--rz-on-secondary);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: transform var(--login-transition-speed), box-shadow var(--login-transition-speed);
    box-shadow: var(--login-button-box-shadow);
}

    .login-btn:hover {
        transform: translateY(-2px);
        box-shadow: var(--login-button-hover-box-shadow);
    }

    .login-btn:active {
        transform: translateY(0);
    }

.login-btn-loading {
    cursor: default;
    opacity: 0.95;
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: var(--login-button-shine-background);
    transform: skewX(-25deg);
    animation: login-shine 3s infinite;
}

@keyframes login-shine {
    100% {
        left: 200%;
    }
}

.profile-card {
    width: 100%;
    min-width: 390px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--profile-card-background-color);
    border: 1px solid var(--profile-card-border-color);
    border-radius: 18px;
    box-shadow: var(--profile-card-box-shadow);
}

.profile-hero {
    position: relative;
    min-height: 136px;
    padding: 25px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    isolation: isolate;
    overflow: hidden;
    color: var(--profile-hero-text-color);
    background: var(--profile-hero-background);
}

.profile-hero-decoration {
    position: absolute;
    z-index: -1;
    width: 330px;
    height: 150px;
    right: -88px;
    bottom: -92px;
    border-radius: 50%;
    border: 22px solid var(--profile-hero-decoration-border-color);
    transform: rotate(-9deg);
}

    .profile-hero-decoration::after {
        content: "";
        position: absolute;
        width: 290px;
        height: 120px;
        top: -42px;
        left: -44px;
        border-radius: 50%;
        border: 15px solid var(--profile-hero-decoration-after-border-color);
    }

.profile-avatar {
    flex: 0 0 auto;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--profile-avatar-text-color);
    background: var(--profile-avatar-background);
    border: 4px solid var(--profile-avatar-border-color);
    box-shadow: var(--profile-avatar-box-shadow);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0;
}

.profile-identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-name {
    color: var(--profile-name-color);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0;
}

.profile-email {
    max-width: 260px;
    overflow: hidden;
    color: var(--profile-email-color);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-details {
    padding: 6px 24px;
    background: var(--profile-details-background);
}

.profile-detail-row {
    min-height: 88px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--profile-detail-row-border-bottom-color);
}

.profile-detail-row-last {
    border-bottom: 0;
}

.detail-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--detail-icon-color);
    background: var(--detail-icon-background);
    border: 1px solid var(--detail-icon-border);
    box-shadow: var(--detail-icon-box-shadow);
    font-size: 1.45rem;
}

.detail-content {
    min-width: 0;
    padding: 15px 0;
}

.detail-label {
    margin-bottom: 4px;
    color: var(--detail-label-color);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.detail-value {
    overflow-wrap: anywhere;
    color: var(--detail-value-color);
    font-size: 0.96rem;
    font-weight: 500;
    line-height: 1.4;
}

.detail-value-id {
    font-size: 0.86rem;
    letter-spacing: 0.01em;
}

.profile-menu-anchor {
    position: relative;
    overflow: visible;
}

/* ชื่อผู้ Login ต้องอยู่บรรทัดเดียวเสมอ ถ้าปล่อยให้ตัดบรรทัดจะดัน header สูงขึ้นและทับโลโก้
   ไม่กำหนด max-width ที่นี่ เพื่อให้จอกว้างยังแสดงชื่อเต็ม (จอแคบไปคุมใน media query) */
.profile-username {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.profile-popup {
    position: absolute;
    top: calc(100% + 13px);
    right: 0;
    overflow: hidden;
    width: 380px;
    height: auto;
    border: var(--rz-panel-border);
    background-color: var(--rz-panel-background-color);
    box-shadow: var(--rz-panel-shadow);
    /* border-radius: var(--rz-border-radius); */
    border-radius: 15px;
    z-index: 10000;
}

.profile-popup-visible {
    display: block;
}

.profile-actions {
    padding: 16px 24px 18px;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 12px;
    background: var(--profile-actions-background);
    border-top: 1px solid var(--profile-actions-border-top-color);
}

    .profile-actions .profile-button {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        border-radius: 8px;
        font-weight: 700;
        box-shadow: none;
    }

    .profile-actions .profile-button-manage,
    .profile-actions .profile-button-manage.rz-button {
        color: var(--profile-manage-button-color) !important;
        background: var(--profile-manage-button-background) !important;
        border: 1px solid var(--profile-manage-button-border) !important;
    }

        .profile-actions .profile-button-manage:hover,
        .profile-actions .profile-button-manage.rz-button:hover {
            color: var(--profile-manage-button-hover-color) !important;
            background: var(--profile-manage-button-hover-background) !important;
            border-color: var(--profile-manage-button-hover-border-color) !important;
        }

    .profile-actions .profile-button-logout,
    .profile-actions .profile-button-logout.rz-button {
        color: var(--profile-logout-button-text-color) !important;
        background: var(--profile-logout-button-background) !important;
        border: 1px solid var(--profile-logout-button-border) !important;
        box-shadow: var(--profile-logout-button-box-shadow) !important;
    }

        .profile-actions .profile-button-logout:hover,
        .profile-actions .profile-button-logout.rz-button:hover {
            background: var(--profile-logout-button-hover-background) !important;
            border-color: var(--profile-logout-button-hover-border-color) !important;
            color: var(--profile-logout-button-text-color) !important;
        }

    /* Ensure Radzen internal button text/icon inherit our theme colors, including on hover */
    .profile-actions .profile-button-manage .rz-button-text,
    .profile-actions .profile-button-manage .rz-button-icon-left,
    .profile-actions .profile-button-manage .rz-button-icon-right {
        color: var(--profile-manage-button-color) !important;
    }

    .profile-actions .profile-button-manage:hover .rz-button-text,
    .profile-actions .profile-button-manage:hover .rz-button-icon-left,
    .profile-actions .profile-button-manage:hover .rz-button-icon-right {
        color: var(--profile-manage-button-hover-color) !important;
    }

    .profile-actions .profile-button-logout .rz-button-text,
    .profile-actions .profile-button-logout .rz-button-icon-left,
    .profile-actions .profile-button-logout .rz-button-icon-right,
    .profile-actions .profile-button-logout:hover .rz-button-text,
    .profile-actions .profile-button-logout:hover .rz-button-icon-left,
    .profile-actions .profile-button-logout:hover .rz-button-icon-right {
        color: var(--profile-logout-button-text-color) !important;
    }

@media (max-width: 520px) {
    .profile-card {
        min-width: 0;
    }

    .profile-hero {
        min-height: 118px;
        padding: 20px;
        gap: 15px;
    }

    .profile-avatar {
        width: 66px;
        height: 66px;
        font-size: 1.25rem;
    }

    .profile-name {
        font-size: 1.15rem;
    }

    .profile-details {
        padding-inline: 18px;
    }

    .profile-actions {
        padding-inline: 18px;
        grid-template-columns: 1fr;
    }
}
