/*
 * ไฟล์:
 * /public_html/portal/assets/app.css
 *
 * หน้าที่:
 * - เก็บ UI กลางของระบบ
 * - เก็บสี ฟอนต์ ไอคอน และ Components
 * - ใช้ร่วมกันระหว่าง Login, Admin และ Partner
 */


/* =========================================================
   ฟอนต์ระบบ
   ========================================================= */

@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("fonts/Sarabun-ExtraBold.ttf") format("truetype");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Font Awesome 6 Free";
    src: url("fonts/fa-solid-900.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: block;
}


/* =========================================================
   ตัวแปรสีและขนาดกลาง
   ========================================================= */

:root {
    color-scheme: dark;

    --font-body:
        "Sarabun",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --font-data:
        "Inter",
        "Sarabun",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --bg: #09111f;
    --header: #091426;

    --surface: #111b2e;
    --surface-2: #17243a;
    --surface-control: #0d1728;

    --text: #edf3fc;
    --muted: #9baac0;

    --line: #2b3d59;
    --line-hover: #405878;

    --primary: #4f8fe8;
    --primary-dark: #316cc4;
    --primary-light: #8fc2ff;
    --primary-soft: #172f51;

    --success: #4ade80;
    --success-soft: #123722;

    --warning: #facc15;
    --warning-soft: #3b2c0d;

    --danger: #fb7185;
    --danger-soft: #421a24;

    --purple: #a78bfa;

    --radius-card: 18px;
    --radius-control: 12px;

    --shadow-card:
        0 14px 32px
        rgba(0, 0, 0, 0.24);
}


/* =========================================================
   Reset
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main,
header,
footer,
nav,
section,
article,
aside {
    display: block;
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
figure {
    margin-top: 0;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    max-width: 100%;
    color: inherit;
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

input,
select,
textarea {
    border-radius: 0;
}

textarea {
    overflow: auto;
}

table {
    border-spacing: 0;
}

[hidden] {
    display: none !important;
}

[disabled] {
    cursor: not-allowed;
}

::selection {
    color: #ffffff;
    background: color-mix(
        in srgb,
        var(--primary) 64%,
        transparent
    );
}

:focus-visible {
    outline: 3px solid color-mix(
        in srgb,
        var(--primary) 30%,
        transparent
    );
    outline-offset: 2px;
}


/* =========================================================
   ไอคอน
   ========================================================= */

.icon {
    display: inline-block;
    width: 1em;
    flex: 0 0 auto;
    font-family: "Font Awesome 6 Free";
    font-style: normal;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

.icon-bars::before {
    content: "\f0c9";
}

.icon-arrow-left::before {
    content: "\f060";
}

.icon-arrow-right::before {
    content: "\f061";
}

.icon-arrow-up::before {
    content: "\f062";
}

.icon-arrow-down::before {
    content: "\f063";
}

.icon-chevron-left::before {
    content: "\f053";
}

.icon-chevron-right::before {
    content: "\f054";
}

.icon-chevron-down::before {
    content: "\f078";
}

.icon-chevron-up::before {
    content: "\f077";
}

.icon-house::before {
    content: "\f015";
}

.icon-ellipsis::before {
    content: "\f141";
}

.icon-plus::before {
    content: "\f067";
}

.icon-xmark::before {
    content: "\f00d";
}

.icon-check::before {
    content: "\f00c";
}

.icon-pen::before {
    content: "\f304";
}

.icon-trash::before {
    content: "\f1f8";
}

.icon-save::before {
    content: "\f0c7";
}

.icon-copy::before {
    content: "\f0c5";
}

.icon-download::before {
    content: "\f019";
}

.icon-upload::before {
    content: "\f093";
}

.icon-print::before {
    content: "\f02f";
}

.icon-refresh::before {
    content: "\f2f1";
}

.icon-search::before {
    content: "\f002";
}

.icon-filter::before {
    content: "\f0b0";
}

.icon-sort::before {
    content: "\f0dc";
}

.icon-gear::before {
    content: "\f013";
}

.icon-user::before {
    content: "\f007";
}

.icon-users::before {
    content: "\f0c0";
}

.icon-user-plus::before {
    content: "\f234";
}

.icon-lock::before {
    content: "\f023";
}

.icon-login::before {
    content: "\f2f6";
}

.icon-circle-exclamation::before {
    content: "\f06a";
}

.icon-logout::before {
    content: "\f2f5";
}

.icon-eye::before {
    content: "\f06e";
}

.icon-eye-slash::before {
    content: "\f070";
}

.icon-clipboard-list::before {
    content: "\f46d";
}

.icon-file-lines::before {
    content: "\f15c";
}

.icon-file::before {
    content: "\f15b";
}

.icon-file-pdf::before {
    content: "\f1c1";
}

.icon-paperclip::before {
    content: "\f0c6";
}

.icon-calendar::before {
    content: "\f133";
}

.icon-clock::before {
    content: "\f017";
}

.icon-building::before {
    content: "\f1ad";
}

.icon-money::before {
    content: "\f51e";
}

.icon-receipt::before {
    content: "\f543";
}


/* =========================================================
   หน้า Login
   ========================================================= */

.login-body {
    min-height: 100svh;
    min-height: 100dvh;
    color: var(--text);
    background:
        radial-gradient(
            circle at 50% 4%,
            rgba(92, 156, 236, .12),
            transparent 34%
        ),
        radial-gradient(
            circle at 18% 18%,
            color-mix(
                in srgb,
                var(--primary) 14%,
                transparent
            ),
            transparent 34%
        ),
        radial-gradient(
            circle at 84% 22%,
            color-mix(
                in srgb,
                var(--purple) 9%,
                transparent
            ),
            transparent 32%
        ),
        linear-gradient(
            180deg,
            var(--header),
            var(--bg)
        );
}

.login-page {
    min-height: 100svh;
    min-height: 100dvh;
    display: grid;
    justify-items: center;
    align-content: start;
    padding:
        max(
            clamp(46px, 8svh, 86px),
            env(safe-area-inset-top)
        )
        max(14px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom))
        max(14px, env(safe-area-inset-left));
}

.login-panel {
    width: min(100%, 440px);
    display: grid;
    gap: 18px;
}

.login-brand {
    position: relative;
    isolation: isolate;
    text-align: center;
}

.login-company {
    margin: 0;
    color: transparent;
    background:
        linear-gradient(
            180deg,
            #ffffff 0%,
            #dbe9ff 45%,
            #9dc5ff 100%
        );
    background-clip: text;
    -webkit-background-clip: text;
    font-family: var(--font-body);
    font-size: clamp(36px, 8.8vw, 46px);
    font-weight: 900;
    line-height: 1.02;
    letter-spacing: -0.045em;
    text-wrap: balance;
}

.login-system-name {
    margin: 11px 0 0;
    color: #9fbde8;
    font-family: var(--font-data);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .24em;
    text-transform: uppercase;
}

.login-divider {
    width: 124px;
    height: 2px;
    margin: 18px auto 0;
    border-radius: 999px;
    background:
        linear-gradient(
            90deg,
            transparent,
            #3f78c7,
            #8fc5ff,
            #3f78c7,
            transparent
        );
}

.login-card {
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: var(--radius-card);
    background:
        linear-gradient(
            180deg,
            rgba(22, 37, 61, .9),
            rgba(15, 27, 46, .97)
        );
    box-shadow:
        0 20px 50px rgba(0, 0, 0, .28),
        inset 0 1px 0 rgba(255, 255, 255, .03);
    backdrop-filter: blur(18px);
}

.login-heading {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding: 11px 13px;
    border: 1px solid color-mix(
        in srgb,
        var(--danger) 42%,
        var(--line)
    );
    border-radius: var(--radius-control);
    color: #fecdd3;
    background: color-mix(
        in srgb,
        var(--danger-soft) 78%,
        var(--surface) 22%
    );
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

.login-alert .icon {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--danger);
    font-size: 15px;
}

.login-form,
.login-field {
    display: grid;
}

.login-form {
    gap: 11px;
}

.login-field {
    min-width: 0;
    gap: 5px;
}

.login-label {
    padding-left: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}

.login-input-wrap {
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 12px;
    z-index: 1;
    width: 18px;
    color: var(--primary-light);
    font-size: 14px;
    pointer-events: none;
}

.login-input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    outline: 0;
    color: var(--text);
    background: var(--surface-control);
    font-size: 15px;
    font-weight: 700;
}

.login-input:hover {
    border-color: var(--line-hover);
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(
        in srgb,
        var(--primary) 16%,
        transparent
    );
}

.login-submit {
    width: 100%;
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    padding: 0 16px;
    border: 1px solid rgba(143, 194, 255, .18);
    border-radius: var(--radius-control);
    color: #eaf3ff;
    background:
        linear-gradient(
            180deg,
            #314b73,
            #273c5d
        );
    font-size: 15px;
    font-weight: 900;
}

.login-footer {
    margin: 14px 0 0;
    color: var(--muted);
    font-family: var(--font-data);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}


/* =========================================================
   UI กลาง
   ========================================================= */

.ui-page {
    width: min(100%, 980px);
    margin: 0 auto;
    padding:
        max(12px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        max(28px, env(safe-area-inset-bottom))
        max(10px, env(safe-area-inset-left));
}

.ui-header {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background:
        radial-gradient(
            circle at 88% 8%,
            rgba(79, 143, 232, .26),
            transparent 40%
        ),
        linear-gradient(
            135deg,
            var(--header),
            #0b1b37 62%,
            #316fc7
        );
    box-shadow: var(--shadow-card);
}

.ui-header::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background:
        linear-gradient(
            180deg,
            var(--primary-light),
            var(--primary-dark)
        );
}

.ui-header > * {
    position: relative;
    z-index: 1;
}

.ui-header-identity {
    min-width: 0;
}

.ui-header-title {
    margin: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 24px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.025em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ui-header-meta {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-top: 8px;
    overflow: hidden;
    color: #edf3fc;
    font-family: var(--font-data);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
}

.ui-user-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.ui-user-name .icon {
    color: var(--primary-light);
    font-size: 14px;
}

/* ปุ่ม Sign out */
.ui-logout-form {
    min-width: max-content;
}

.ui-logout-form .ui-button {
    width: auto;
    min-width: 78px;
    min-height: 32px;
    height: 32px;
    padding: 0 8px;
    gap: 5px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 800;
}

.ui-logout-form .icon {
    font-size: 12px;
}

.ui-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.ui-card > .ui-header-meta {
    margin-top: 0;
}

.ui-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    color: var(--text);
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.ui-button.is-soft {
    border-color: color-mix(
        in srgb,
        var(--primary) 36%,
        var(--line)
    );
    color: var(--text);
    background: var(--primary-soft);
}

.ui-status {
    min-height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-family: var(--font-data);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
}

.ui-status.is-info {
    color: var(--primary-light);
    background: var(--primary-soft);
}

.ui-empty {
    padding: 18px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-card);
    color: var(--muted);
    background: var(--surface);
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.table-wrap {
    width: 100%;
    margin-top: 12px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.table-wrap table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

.table-wrap th,
.table-wrap td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.table-wrap th {
    color: var(--muted);
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 900;
}

.table-wrap td {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.table-wrap tbody tr:last-child td {
    border-bottom: 0;
}


/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 640px) {
    .ui-header {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
    }

    .ui-header-title {
        font-size: 21px;
    }

    .login-card {
        padding: 18px;
    }
}