Files
Bkk1234 cd5cb5dd08 feat(admin): gate the backoffice behind a name and password
- ui/auth.js: name/password check, session kept in sessionStorage (new tab asks again),
  5 wrong attempts lock the form for 30s
- admin view renders a login card until authenticated; adds an explicit logout button
- SW precache includes auth.js, version bumped to 2026.11.19.3 (meta + sw.js in sync)
- docs: AGENTS.md notes the gate is client-side; real protection is the server ADMIN_TOKEN
2026-11-19 11:28:20 +07:00

371 lines
7.7 KiB
CSS

/* ==========================================================================
admin.css — หน้าจัดการข้อมูล (หลังบ้าน)
========================================================================== */
.admin-head {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: var(--space-4);
padding-bottom: var(--space-5);
border-bottom: 1px solid var(--border);
}
.admin-head__title {
font-size: clamp(1.35rem, 1.15rem + 0.9vw, 1.75rem);
}
.admin-head__sub {
margin-top: 6px;
color: var(--muted-foreground);
font-size: 14.5px;
max-width: 52ch;
}
.admin-head__actions {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
}
.panel {
margin-top: var(--space-6);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--surface);
overflow: hidden;
}
.panel__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
padding: var(--space-4) var(--space-5);
background: var(--surface-2);
border-bottom: 1px solid var(--border);
}
.panel__title {
font-size: 1rem;
font-weight: 700;
color: var(--brand-900);
}
.panel__body {
padding: var(--space-5);
}
/* ------------------------------------------------------------- auth */
.auth-wrap {
display: grid;
place-items: center;
min-height: min(72vh, 720px);
padding-block: var(--space-6);
}
.auth-card {
width: min(430px, 100%);
padding: var(--space-8) var(--space-6) var(--space-6);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
background: linear-gradient(180deg, #fff 0%, var(--brand-50) 100%);
box-shadow: var(--shadow-md);
text-align: center;
}
.auth-card__icon {
display: inline-grid;
place-items: center;
width: 52px;
height: 52px;
border-radius: 16px;
background: #fff;
border: 1px solid var(--brand-200);
color: var(--brand-700);
margin-bottom: var(--space-4);
}
.auth-card__icon svg {
width: 26px;
height: 26px;
}
.auth-card__title {
font-size: 1.35rem;
}
.auth-card__sub {
margin-top: 6px;
font-size: 14.5px;
color: var(--muted-foreground);
}
.auth-card form {
margin-top: var(--space-5);
text-align: start;
}
.auth-card .field + .field {
margin-top: var(--space-4);
}
.auth-card .field__error {
margin-top: var(--space-2);
min-height: 0;
}
.auth-card__submit {
width: 100%;
margin-top: var(--space-4);
}
.auth-card .admin-hint {
text-align: center;
}
/* ------------------------------------------------------------- fields */
.field {
display: flex;
flex-direction: column;
gap: 6px;
}
.field + .field {
margin-top: var(--space-4);
}
.field__label {
font-size: 14px;
font-weight: 500;
color: var(--brand-800);
}
.field__hint {
font-size: 12.5px;
color: var(--muted-foreground);
}
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field textarea,
.field select {
width: 100%;
min-height: 44px;
padding: 10px 14px;
border: 1px solid var(--border-strong);
border-radius: var(--radius-md);
background: #fff;
font-size: 15px;
transition:
border-color 150ms var(--ease),
box-shadow 150ms var(--ease);
}
.field textarea {
min-height: 84px;
resize: vertical;
line-height: 1.55;
}
.field input:hover,
.field textarea:hover {
border-color: var(--brand-300);
}
.field input:focus,
.field textarea:focus {
outline: none;
border-color: var(--brand-500);
box-shadow: 0 0 0 4px rgba(196, 112, 60, 0.15);
}
.field--error input,
.field--error textarea {
border-color: #b3391f;
box-shadow: 0 0 0 4px rgba(179, 57, 31, 0.12);
}
.field__error {
font-size: 12.5px;
color: #8f2c19;
font-weight: 500;
}
.field__error:empty {
display: none;
}
/* ------------------------------------------------------------- rows */
.admin-list {
display: flex;
flex-direction: column;
gap: var(--space-4);
}
.admin-item {
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: var(--surface);
padding: var(--space-4);
}
.admin-item__head {
display: flex;
align-items: center;
gap: var(--space-3);
padding-bottom: var(--space-3);
border-bottom: 1px solid var(--brand-50);
margin-bottom: var(--space-4);
}
.admin-item__index {
flex: none;
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 9px;
background: var(--brand-100);
color: var(--brand-800);
font-size: 13px;
font-weight: 700;
}
.admin-item__label {
flex: 1 1 auto;
min-width: 0;
font-weight: 500;
color: var(--brand-900);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.admin-item__tools {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.admin-item__tools .btn {
min-height: 36px;
padding: 6px 10px;
font-size: 13px;
border-radius: var(--radius-sm);
}
.admin-item__tools .btn svg {
width: 16px;
height: 16px;
}
.admin-grid-2 {
display: grid;
gap: var(--space-4);
margin-top: var(--space-4);
}
.admin-item .admin-grid-2:first-of-type {
margin-top: 0;
}
.admin-item .field + .field {
margin-top: var(--space-4);
}
/* ------------------------------------------------------------- publish */
.publish-status {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 14px;
padding: 12px 16px;
border-radius: var(--radius-md);
background: var(--brand-50);
border: 1px solid var(--brand-200);
color: var(--brand-800);
font-size: 14px;
}
.publish-status__dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--brand-500);
}
.publish-status[data-state="ok"] .publish-status__dot {
background: #2f7a44;
}
.publish-status[data-state="warn"] {
background: #fdf3e7;
border-color: #f0cfa8;
color: #7c4a13;
}
.publish-status[data-state="error"] {
background: #fdf1ee;
border-color: #e7c4bb;
color: #8f2c19;
}
.admin-hint {
margin-top: var(--space-3);
font-size: 13px;
color: var(--muted-foreground);
}
.admin-hint code {
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12.5px;
background: var(--surface-2);
border: 1px solid var(--border);
border-radius: 6px;
padding: 1px 6px;
}
.dirty-bar {
position: sticky;
bottom: 12px;
margin-top: var(--space-5);
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
padding: 12px 16px;
border-radius: var(--radius-lg);
background: rgba(61, 36, 26, 0.96);
color: #fff;
box-shadow: var(--shadow-lg);
}
.dirty-bar[hidden] {
display: none;
}
.dirty-bar__text {
font-size: 14px;
}
.dirty-bar__actions {
display: flex;
gap: 8px;
}
.dirty-bar .btn--ghost {
background: transparent;
border-color: rgba(255, 255, 255, 0.35);
color: #fff;
}
.dirty-bar .btn--ghost:hover {
background: rgba(255, 255, 255, 0.12);
}
.dirty-bar .btn--primary {
background: #fff;
color: var(--brand-800);
}
.dirty-bar .btn--primary:hover {
background: var(--brand-100);
}
/* ------------------------------------------------------------- dialog */
.dialog {
width: min(560px, calc(100vw - 32px));
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 0;
color: var(--foreground);
box-shadow: var(--shadow-lg);
}
.dialog::backdrop {
background: rgba(36, 26, 21, 0.45);
backdrop-filter: blur(2px);
}
.dialog__head {
padding: var(--space-5);
border-bottom: 1px solid var(--border);
}
.dialog__title {
font-size: 1.05rem;
}
.dialog__body {
padding: var(--space-5);
}
.dialog__foot {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: var(--space-2);
padding: var(--space-4) var(--space-5);
border-top: 1px solid var(--border);
background: var(--surface-2);
}
@media (min-width: 760px) {
.admin-grid-2 {
grid-template-columns: 1fr 1fr;
gap: var(--space-4) var(--space-5);
}
}