/* dmf.ac.th admin CMS — served as a file so the page needs no inline <style>. */

:root {
    --brand: #0f3a5f;
    --brand-light: #2b6f8f;
    --ink: #1d2733;
    --ink-muted: #667789;
    --line: #dce4ed;
    --surface: #fff;
    --ground: #f6f8fb;
    --ok: #1f7a4d;
    --warn: #9a6a00;
    --danger: #a33131;
}

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

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Arial, Helvetica, sans-serif;
    line-height: 1.6;
}

a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }

input, textarea, select {
    box-sizing: border-box; width: 100%;
    border: 1px solid #c9d3df; border-radius: 6px;
    padding: 10px; font: inherit; background: #fff;
}
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 0; }
legend { font-weight: 700; color: #344255; padding: 0 6px; }
code { background: #eef3f8; border-radius: 4px; padding: 1px 5px; font-size: 13px; }

/* Login screen ------------------------------------------------------------
   Everything is drawn with gradients and inline SVG data URIs: the page is
   served under `default-src 'self'; img-src 'self' data:` so no webfont,
   icon set or external image may be requested here. */

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(1100px 620px at 12% -12%, rgba(43, 111, 143, .60), transparent 62%),
        radial-gradient(900px 520px at 88% 112%, rgba(200, 162, 74, .30), transparent 60%),
        linear-gradient(155deg, #0a2942 0%, #0f3a5f 46%, #14506f 100%);
}

/* Faint dot grid over the gradient, so the backdrop keeps some texture at
   large viewport sizes without shipping a background photograph. */
.login-page::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1.4' fill='%23ffffff' fill-opacity='.10'/%3E%3C/svg%3E");
}

.login-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 20px;
}

.login-card {
    width: min(940px, 100%);
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(340px, 1fr);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 20px;
    box-shadow: 0 40px 90px -30px rgba(3, 17, 30, .68), 0 2px 10px rgba(3, 17, 30, .22);
    animation: login-rise .45s ease-out both;
}

@keyframes login-rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}

/* Brand panel ------------------------------------------------------------ */

.login-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 40px 38px;
    color: #fff;
    background:
        radial-gradient(520px 320px at 88% -6%, rgba(200, 162, 74, .38), transparent 64%),
        radial-gradient(430px 430px at -8% 104%, rgba(43, 111, 143, .62), transparent 62%),
        linear-gradient(165deg, #14456e, #0a2942);
}

.login-brand::after {
    content: "";
    position: absolute;
    right: -96px;
    bottom: -120px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 0 0 34px rgba(255, 255, 255, .05);
    pointer-events: none;
}

.login-brand > * { position: relative; z-index: 1; }

.login-logo {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    width: fit-content;
    color: #fff;
    text-decoration: none;
    border-radius: 16px;
}

.login-logo:focus-visible { outline: 3px solid rgba(200, 162, 74, .85); outline-offset: 4px; }

/* Kept to roughly 2.5x the wordmark size so the lockup reads as one unit. */
.login-mark {
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(150deg, #ffffff, #dfeaf3);
    color: var(--brand);
    box-shadow: 0 9px 20px -8px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .8);
}

.login-mark svg { width: 22px; height: 22px; display: block; }

.login-logo b { display: block; font-size: 16px; letter-spacing: .04em; }
.login-logo small { display: block; font-size: 12px; color: rgba(255, 255, 255, .68); }

.login-brand-copy { margin-top: 8px; }

.login-kicker {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #e6c887;
}

.login-brand h1 {
    margin: 0;
    max-width: 18ch;
    font-size: 28px;
    line-height: 1.32;
    letter-spacing: -.2px;
}

.login-lead {
    margin: 12px 0 0;
    max-width: 36ch;
    color: rgba(255, 255, 255, .78);
    font-size: 15px;
}

.login-points {
    list-style: none;
    margin: auto 0 0;
    padding: 0;
    display: grid;
    gap: 11px;
}

.login-points li {
    position: relative;
    padding-left: 31px;
    color: rgba(255, 255, 255, .90);
    font-size: 14.5px;
}

.login-points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(200, 162, 74, .55);
    background: rgba(200, 162, 74, .26) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f2dfae' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}

.login-brand-foot {
    margin: 0;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .62);
    font-size: 12.5px;
    letter-spacing: .04em;
}

/* Form panel ------------------------------------------------------------- */

/* The brand column spreads its content over the full height, so the form is
   centred against it rather than hanging from the top edge. */
.login-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 44px 42px;
    background: var(--surface);
}

.login-eyebrow {
    margin: 0 0 9px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .16em;
    color: var(--brand-light);
}

.login-form h2 {
    margin: 0 0 6px;
    font-size: 27px;
    line-height: 1.3;
    color: var(--ink);
}

.login-sub {
    margin: 0 0 24px;
    color: var(--ink-muted);
    font-size: 14.5px;
}

.login-field { margin-bottom: 16px; }

.login-field label {
    display: block;
    margin: 0 0 7px;
    font-size: 14px;
    font-weight: 700;
    color: #33445a;
}

.login-input { position: relative; }

/* The leading icon is decorative, so it lives in CSS rather than the markup. */
.login-input::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 50%;
    width: 19px;
    height: 19px;
    transform: translateY(-50%);
    opacity: .52;
    background: center / contain no-repeat;
    pointer-events: none;
}

.login-input.is-user::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f3a5f' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}

.login-input.is-lock::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f3a5f' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
}

.login-input input {
    height: 50px;
    padding: 10px 14px 10px 45px;
    border: 1px solid #ccd8e4;
    border-radius: 11px;
    background: #f8fafc;
    font-weight: 600;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.login-input.is-lock input { padding-right: 52px; }
.login-input input::placeholder { color: #9aa9b9; font-weight: 500; }
.login-input input:hover { border-color: #aec0d1; }

.login-input input:focus {
    outline: none;
    border-color: var(--brand-light);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(43, 111, 143, .16);
}

/* Chrome paints its own autofill background; repaint it to match the field. */
.login-input input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #f8fafc inset;
    -webkit-text-fill-color: var(--ink);
}

/* Revealed by login.js — without scripting the field simply stays masked. */
.login-toggle {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
}

.login-toggle::before {
    content: "";
    width: 20px;
    height: 20px;
    opacity: .55;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23334f6b' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.login-toggle[aria-pressed="true"]::before {
    opacity: .85;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23334f6b' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.6 6.2A9.9 9.9 0 0 1 12 6c6.4 0 10 6 10 6a17 17 0 0 1-3.2 3.9M6.6 6.7A17 17 0 0 0 2 12s3.6 6 10 6a9.7 9.7 0 0 0 4.3-1M3 3l18 18M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E");
}

.login-toggle:hover { background: #eaf1f7; }
.login-toggle:focus-visible { outline: 3px solid rgba(43, 111, 143, .35); outline-offset: 1px; }

/* `display` here would otherwise beat the user-agent rule for [hidden]. */
.login-hint[hidden], .login-toggle[hidden] { display: none; }

.login-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
    color: #7d5600;
    font-size: 13px;
    font-weight: 700;
}

.login-hint::before {
    content: "";
    flex: none;
    width: 17px;
    height: 17px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a6a00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 8 8h-4v5H8v-5H4l8-8Z'/%3E%3Crect x='8' y='19' width='8' height='3' rx='1'/%3E%3C/svg%3E");
}

.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid #f2c6c6;
    border-left: 4px solid var(--danger);
    border-radius: 11px;
    background: #fdf0f0;
    color: #8a2323;
    font-size: 14px;
    font-weight: 700;
}

.login-alert::before {
    content: "";
    flex: none;
    width: 19px;
    height: 19px;
    margin-top: 1px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a33131' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
}

/* An expired form is recoverable, not a failure — amber rather than red. */
.login-alert.is-notice {
    border-color: #f0dcae;
    border-left-color: var(--warn);
    background: #fdf6e6;
    color: #7d5600;
}

.login-alert.is-notice::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a6a00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5h.01'/%3E%3C/svg%3E");
}

/* Standalone message page (see LoginController::renderNotice). */
.login-notice {
    width: min(480px, 100%);
    padding: 36px 34px;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: 0 40px 90px -30px rgba(3, 17, 30, .68);
    text-align: center;
}

.login-notice h1 { margin: 0 0 10px; font-size: 23px; color: var(--brand); }
.login-notice p { margin: 0 0 22px; color: var(--ink-muted); }
.login-notice .login-back { justify-content: center; }

/* Deliberately not sharing `.button`: this control owns its own size, radius
   and gradient, and `.button` is defined later in this file. */
.login-submit {
    width: 100%;
    height: 52px;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-light), var(--brand));
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .2px;
    cursor: pointer;
    box-shadow: 0 14px 28px -14px rgba(15, 58, 95, .95);
    transition: transform .12s ease, box-shadow .18s ease, filter .18s ease;
}

.login-submit::after {
    content: "";
    width: 18px;
    height: 18px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
}

.login-submit:hover { filter: brightness(1.07); box-shadow: 0 18px 32px -14px rgba(15, 58, 95, 1); }
.login-submit:active { transform: translateY(1px); }
.login-submit:focus-visible { outline: 3px solid rgba(200, 162, 74, .8); outline-offset: 2px; }
.login-submit[disabled] { opacity: .72; cursor: progress; filter: none; }

.login-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.login-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--brand-light);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.login-back::before {
    content: "";
    width: 16px;
    height: 16px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b6f8f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 18l-6-6 6-6'/%3E%3C/svg%3E");
}

.login-back:hover { color: var(--brand); text-decoration: underline; }

.login-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.login-note::before {
    content: "";
    flex: none;
    width: 15px;
    height: 15px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667789' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
    .login-card { animation: none; }
    .login-submit, .login-input input { transition: none; }
}

.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }

aside { background: var(--brand); color: #fff; padding: 24px 18px; }
nav { display: grid; gap: 6px; margin-top: 24px; }
nav a, .brand { display: block; text-decoration: none; border-radius: 6px; padding: 10px 12px; }
.brand { font-weight: 700; font-size: 20px; background: var(--brand-light); }
nav a:hover, nav a:focus { background: #1b527c; }
nav a[aria-current="page"] { background: #1b527c; box-shadow: inset 3px 0 0 #c8a24a; }
.logout { margin-top: 28px; }

main { padding: 28px; max-width: 1180px; }

.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { margin: 0; padding: 12px 16px; border-radius: 6px; border-left: 4px solid; font-weight: 600; }
.flash-success { background: #e8f6ee; border-color: var(--ok); color: #14522f; }
.flash-error { background: #fdecec; border-color: var(--danger); color: #7d2020; }
.flash-info { background: #eaf2f8; border-color: var(--brand-light); color: #17415e; }

.hero, .toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.hero { background: var(--surface); border-left: 5px solid var(--brand-light); padding: 22px; border-radius: 8px; }
.hero p, .toolbar p { margin: 0 0 6px; color: var(--ink-muted); font-size: 13px; text-transform: uppercase; }
.hero h1, .toolbar h1 { margin: 0; font-size: 28px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.module-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(19, 35, 51, .04); }
.module-card { display: grid; gap: 8px; text-decoration: none; padding: 18px; }
.module-card span, .muted { color: var(--ink-muted); }
.panel { padding: 18px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 19px; color: var(--brand); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; color: #344255; margin-bottom: 12px; }
label.tight { margin-bottom: 6px; font-size: 13px; font-weight: 600; }
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.wide { grid-column: 1 / -1; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.button {
    border: 0; border-radius: 6px; background: var(--brand-light); color: #fff;
    padding: 10px 14px; font: inherit; font-weight: 700; cursor: pointer;
    text-decoration: none; display: inline-block; white-space: nowrap;
}
.button:hover { background: var(--brand); }
.button.secondary { background: #dfeaf2; color: #163247; }
.button.compact { padding: 7px 10px; font-size: 14px; }
.button.danger { background: var(--danger); }
.actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e5ecf3; text-align: left; padding: 12px; vertical-align: top; }
td span { display: block; color: var(--ink-muted); margin-top: 4px; font-size: 13px; }
td.break { word-break: break-all; font-size: 13px; }
.status { display: inline-block; border-radius: 999px; background: #e7f1f6; color: #16415f; padding: 4px 8px; font-size: 13px; }
.status-published { background: #e8f6ee; color: #14522f; }
.status-draft { background: #fdf3e0; color: var(--warn); }
.status-archived { background: #eceff3; color: #4a5665; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--ground); }
.media-thumb { aspect-ratio: 4 / 3; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; overflow: hidden; margin-bottom: 10px; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-ext { font-weight: 700; color: var(--brand-light); font-size: 22px; }
.media-id { margin: 0; font-size: 13px; }
.media-name { margin: 2px 0 4px; font-size: 13px; word-break: break-all; }
.media-item p.muted { margin: 0 0 8px; font-size: 12px; }
.media-item form { margin-bottom: 8px; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
    min-width: 38px; text-align: center; padding: 7px 11px;
    border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none;
}
.pagination span[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

@media (max-width: 900px) {
    .shell { display: block; }
    .split, .form-grid { grid-template-columns: 1fr; }
    main { padding: 18px; }
    .hero, .toolbar { display: grid; align-items: start; }
    /* Stacked: the brand panel becomes a banner, so the parts that only exist
       to fill a tall column (feature list, footer line) are dropped. */
    .login-card { grid-template-columns: 1fr; }
    .login-brand {
        gap: 18px;
        padding: 28px 26px;
    }
    .login-brand::after { display: none; }
    .login-brand-copy { margin-top: 0; }
    .login-brand h1 { font-size: 26px; max-width: none; }
    .login-lead { max-width: none; }
    .login-points, .login-brand-foot { display: none; }
    .login-form { padding: 30px 26px; }
}

@media (max-width: 520px) {
    .login-shell { padding: 14px; }
    .login-card { border-radius: 16px; }
    .login-brand { padding: 22px 20px; gap: 14px; }
    .login-mark { width: 38px; height: 38px; border-radius: 12px; }
    .login-mark svg { width: 20px; height: 20px; }
    .login-brand h1 { font-size: 22px; }
    .login-lead { font-size: 14px; }
    .login-form { padding: 24px 20px; }
    .login-form h2 { font-size: 23px; }
    .login-foot { justify-content: flex-start; gap: 10px; }
}
