@import url("https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap");

:root {
    --brand: #465fff;
    --brand-soft: #eef2ff;
    --ink: #111827;
    --muted: #667085;
    --line: #e4e7ec;
    --panel: #ffffff;
    --bg: #f7f8fb;
    --danger: #d92d20;
    --success: #039855;
    --warning: #dc6803;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Sarabun", "TH Sarabun New", Tahoma, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

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

input,
textarea,
button {
    font: inherit;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: #fff;
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 34px;
}

.brand img {
    width: 42px;
    height: 42px;
}

.admin-nav {
    display: grid;
    gap: 8px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #475467;
    border-radius: var(--radius);
    transition: 0.16s ease;
}

.admin-nav a:hover,
.admin-nav a.active {
    color: var(--brand);
    background: var(--brand-soft);
}

.admin-main {
    min-width: 0;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.admin-topbar h1 {
    margin: 0;
    font-size: 26px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.admin-content {
    padding: 28px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #344054;
    cursor: pointer;
    white-space: nowrap;
}

.btn.primary {
    color: #fff;
    border-color: var(--brand);
    background: var(--brand);
}

.btn.ghost {
    background: #fff;
}

.btn.danger {
    color: #fff;
    border-color: var(--danger);
    background: var(--danger);
}

.btn.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 14px;
}

.btn.wide {
    width: 100%;
}

.flash {
    margin: 18px 28px 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
}

.flash.success {
    color: #05603a;
    border-color: #a6f4c5;
    background: #ecfdf3;
}

.flash.danger {
    color: #b42318;
    border-color: #fecdca;
    background: #fef3f2;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.metric-card,
.project-card,
.table-card,
.form-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.section-head,
.detail-head,
.table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-head h2,
.detail-head h2,
.table-head h3 {
    margin: 0;
}

.section-head p,
.detail-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 18px;
}

.project-card {
    overflow: hidden;
}

.poster-frame {
    aspect-ratio: 16 / 9;
    background: #f2f4f7;
}

.poster-frame img,
.poster-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-card-body {
    padding: 16px;
}

.project-card-top,
.card-stats,
.card-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

.inline-edit input[type="text"] {
    min-height: 36px;
    width: min(360px, 100%);
    padding: 7px 10px;
    border: 1px solid #d0d5dd;
    border-radius: var(--radius);
}

.project-card-top {
    justify-content: space-between;
}

.project-card h3 {
    margin: 12px 0 6px;
    font-size: 20px;
}

.project-card p {
    margin: 0;
    color: var(--muted);
}

.card-stats {
    margin: 14px 0;
    color: var(--muted);
    font-size: 14px;
}

.status,
.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.status.success,
.badge.success {
    color: #067647;
    background: #dcfae6;
}

.status.warning,
.badge.warning {
    color: #b54708;
    background: #fef0c7;
}

.status.muted,
.badge.muted {
    color: #475467;
    background: #f2f4f7;
}

.date {
    color: var(--muted);
    font-size: 14px;
}

.link-box input,
.generated-link input,
label input,
label textarea,
.release-box input[type="datetime-local"] {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
}

.link-box {
    margin-bottom: 14px;
}

.form-panel {
    display: block;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 20px;
}

.form-section {
    padding: 20px;
}

.form-section h2 {
    margin: 0 0 18px;
}

.form-stack,
.form-section {
    display: grid;
    gap: 16px;
}

label span,
.generated-link span {
    display: block;
    margin-bottom: 6px;
    color: #344054;
    font-weight: 600;
}

textarea {
    resize: vertical;
}

.poster-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f2f4f7;
}

.switch-row,
.release-box,
.generated-link {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fcfcfd;
}

.switch,
.radio-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch input,
.radio-line input {
    width: auto;
}

.release-box {
    display: grid;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-card {
    padding: 18px;
    margin-bottom: 20px;
}

.responsive-table {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

td small {
    display: block;
    max-width: 420px;
    color: var(--muted);
    word-break: break-word;
}

.empty-state,
.empty-cell {
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.muted-link {
    color: var(--muted);
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
    gap: 18px;
}

.settings-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px;
}

.settings-list dt {
    color: var(--muted);
}

.settings-list dd {
    margin: 0;
    word-break: break-word;
}

.help-text {
    color: var(--muted);
    line-height: 1.7;
}

.help-text code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #f2f4f7;
}

.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #f7f8fb 0%, #eef2ff 100%);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(430px, 100%);
    padding: 30px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.08);
}

.login-logo {
    width: 180px;
    max-width: 100%;
    margin-bottom: 18px;
}

.login-card h1 {
    margin: 0 0 20px;
}

.back-link {
    display: block;
    margin-top: 18px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

    .admin-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid,
    .form-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .admin-topbar,
    .section-head,
    .detail-head {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-content,
    .admin-topbar {
        padding: 18px;
    }

    .flash {
        margin: 14px 18px 0;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .admin-nav {
        grid-template-columns: 1fr;
    }
}
