@charset "UTF-8";

/*
 * PB Knowledge Portal UI layer
 * Bootstrap can be vendored at ../vendor/bootstrap/bootstrap.min.css and
 * imported before this file. This layer intentionally owns the portal's
 * visual identity and works without a network connection.
 */

:root {
  color-scheme: light;
  --purple-950: #24103f;
  --purple-900: #35135c;
  --purple-800: #4b1f78;
  --purple-700: #642d91;
  --purple-600: #7b3fb2;
  --purple-100: #f1e8f8;
  --purple-50: #faf7fc;
  --gray-950: #17141b;
  --gray-800: #353039;
  --gray-700: #514b56;
  --gray-600: #716b76;
  --gray-300: #d8d3dc;
  --gray-200: #e9e5ec;
  --gray-100: #f4f2f5;
  --gray-50: #faf9fb;
  --white: #fff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #067647;
  --success-bg: #ecfdf3;
  --shadow-sm: 0 1px 2px rgb(25 10 38 / 6%), 0 6px 18px rgb(25 10 38 / 5%);
  --shadow-lg: 0 18px 55px rgb(45 20 66 / 13%);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --container: 1180px;
  --transition: 160ms ease;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  font-synthesis: none;
}

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

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--gray-800);
  background:
    radial-gradient(circle at 92% 2%, rgb(123 63 178 / 7%), transparent 30rem),
    linear-gradient(180deg, var(--white), var(--gray-50));
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-700); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--purple-900); }
button, input, select, textarea { font: inherit; }
button, .btn { -webkit-tap-highlight-color: transparent; }
.btn { min-height: 44px; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--gray-950); line-height: 1.25; letter-spacing: -.025em; }
h1 { margin-bottom: .65rem; font-size: clamp(1.75rem, 3vw, 2.65rem); }
h2 { margin-bottom: .75rem; font-size: clamp(1.25rem, 2vw, 1.65rem); }
h3 { margin-bottom: .5rem; font-size: 1.08rem; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .8rem max(1rem, calc((100vw - var(--container)) / 2));
  border-bottom: 1px solid rgb(75 31 120 / 10%);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 2px 14px rgb(30 14 44 / 4%);
  backdrop-filter: blur(14px);
}

.brand { color: var(--purple-900); font-size: 1.2rem; font-weight: 850; letter-spacing: -.025em; white-space: nowrap; }
.brand span { color: var(--purple-600); font-weight: 650; }
.topbar nav { display: flex; align-items: center; gap: .35rem; }
.topbar nav > a, .topbar .link {
  padding: .48rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: .94rem;
  font-weight: 600;
}
.topbar nav > a:hover, .topbar .link:hover { color: var(--purple-800); background: var(--purple-50); }
.user { margin-left: .4rem; padding-left: .85rem; border-left: 1px solid var(--gray-200); color: var(--gray-600); font-size: .9rem; }

.container { width: min(calc(100% - 2rem), var(--container)); margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem) 0; flex: 1; }
footer { padding: 1.2rem 1rem; border-top: 1px solid var(--gray-200); color: var(--gray-600); background: var(--white); text-align: center; font-size: .82rem; }

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(2.2rem, 6vw, 4.8rem);
  border: 1px solid rgb(100 45 145 / 10%);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--purple-950), var(--purple-800) 68%, #8249ae);
  box-shadow: var(--shadow-lg);
  color: rgb(255 255 255 / 78%);
  text-align: center;
}
.hero::after { content: ""; position: absolute; right: -7rem; bottom: -11rem; width: 26rem; height: 26rem; border: 5rem solid rgb(255 255 255 / 5%); border-radius: 50%; pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: var(--white); font-size: clamp(2rem, 4.5vw, 3.5rem); }
.hero p { margin-bottom: 1.6rem; }
.eyebrow { display: inline-block; margin-bottom: .65rem; color: var(--purple-600); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: #dcc0ef; }

.searchbox { width: min(100%, 760px); margin: 0 auto; display: flex; gap: .55rem; padding: .5rem; border-radius: var(--radius); background: var(--white); box-shadow: 0 14px 30px rgb(15 5 28 / 25%); text-align: left; }
.searchbox input { flex: 1 1 14rem; min-width: 0; border: 0; background: transparent; }
.searchbox input:focus { outline: 0; }
.searchbox.compact { width: 100%; margin: 0 0 1.6rem; border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); }
.searchbox.compact select, .searchbox.compact input[type="number"] { flex: 0 1 160px; }

.chips { margin-top: 1.4rem; display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.chips a { min-height: 44px; display: inline-flex; align-items: center; padding: .35rem .75rem; border: 1px solid rgb(255 255 255 / 18%); border-radius: 999px; color: rgb(255 255 255 / 88%); background: rgb(255 255 255 / 8%); font-size: .8rem; }
.chips a:hover { color: var(--white); background: rgb(255 255 255 / 16%); }
.weekly-menu { margin-top: 1.5rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; text-align: left; }
.weekly-menu a { min-width: 0; min-height: 72px; display: grid; align-content: center; gap: .15rem; padding: .65rem .75rem; border: 1px solid rgb(255 255 255 / 18%); border-radius: 12px; color: rgb(255 255 255 / 90%); background: rgb(255 255 255 / 8%); }
.weekly-menu a:hover { color: var(--white); border-color: rgb(255 255 255 / 35%); background: rgb(255 255 255 / 16%); transform: translateY(-1px); }
.weekly-menu span { overflow: hidden; font-size: .82rem; font-weight: 650; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.metric { width: max-content; max-width: 100%; margin: 1.5rem auto 3.5rem; display: flex; align-items: baseline; gap: .55rem; color: var(--gray-600); }
.metric strong { color: var(--purple-700); font-size: 2rem; }
.section-head, .page-head.page-head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.card, .result, .panel, .detail, .stat, .auth-card, .table-wrap { border: 1px solid var(--gray-200); background: var(--white); box-shadow: var(--shadow-sm); }
.card { display: block; min-width: 0; overflow: hidden; padding: 0; border-radius: var(--radius); color: inherit; transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); }
.card-content { padding: 1.25rem; }
.card-preview { width: 100%; aspect-ratio: 16 / 9; display: block; object-fit: cover; border-bottom: 1px solid var(--gray-200); background: var(--gray-100); }
.card:hover { transform: translateY(-3px); border-color: #c9afd9; box-shadow: 0 12px 26px rgb(52 23 73 / 10%); }
.card p, .result p { color: var(--gray-700); display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.card small, .result small, td small { display: block; color: var(--gray-600); }

.badge { display: inline-flex; align-items: center; padding: .22rem .55rem; border-radius: 999px; color: var(--purple-800); background: var(--purple-100); font-size: .72rem; font-weight: 750; text-transform: capitalize; }
.badge.expired { color: var(--danger); background: var(--danger-bg); }
.badge.published { color: var(--success); background: var(--success-bg); }
.badge.draft { color: #854a0e; background: #fff8e8; }

.page-head { margin-bottom: 1.5rem; }
.page-head p { color: var(--gray-600); }
.breadcrumbs { margin-bottom: 1rem; color: var(--gray-600); font-size: .85rem; }
.detail { max-width: 900px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem); border-radius: var(--radius-lg); }
.detail-meta { display: flex; gap: .4rem; margin-bottom: 1rem; }
.answer { margin: 1.8rem 0; padding: 1.2rem 1.35rem; border-left: 4px solid var(--purple-600); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--purple-50); color: var(--gray-950); white-space: pre-line; }
.slide-preview { margin: 1.4rem 0; overflow: hidden; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); }
.slide-preview img { width: 100%; display: block; object-fit: contain; background: var(--white); }
.slide-preview figcaption { padding: .7rem 1rem; color: var(--gray-600); font-size: .82rem; text-align: center; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; padding: 1rem 0; border-block: 1px solid var(--gray-200); }
dt { color: var(--gray-600); font-size: .85rem; font-weight: 650; }
dd { margin: 0; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.feedback { margin-top: 2rem; padding-top: 1.3rem; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; border-top: 1px solid var(--gray-200); }
.feedback span { margin-right: auto; font-weight: 650; }
.feedback button { min-height: 44px; padding: .4rem .7rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); color: var(--gray-700); background: var(--white); cursor: pointer; }
.feedback button:hover { border-color: var(--purple-600); color: var(--purple-700); }

.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: .58rem 1rem; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 700; line-height: 1.2; transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition); }
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: var(--white); background: var(--purple-700); box-shadow: 0 6px 16px rgb(100 45 145 / 22%); }
.btn.primary:hover { color: var(--white); background: var(--purple-800); }
.btn.ghost { border-color: var(--gray-300); color: var(--purple-800); background: var(--white); }
.btn.ghost:hover { border-color: var(--purple-600); background: var(--purple-50); }
.btn.danger { color: var(--danger); border-color: #fda29b; background: var(--white); }
.btn.danger:hover { color: var(--white); border-color: var(--danger); background: var(--danger); }
.btn.full { width: 100%; }
.link { border: 0; background: none; cursor: pointer; }
.inline { display: inline; margin: 0; }

.results { display: grid; gap: .8rem; }
.result { display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding: 1.25rem 1.4rem; border-radius: var(--radius); }
.result-content { min-width: 0; flex: 1; }
.result-preview-link { flex: 0 0 200px; overflow: hidden; border: 1px solid var(--gray-200); border-radius: 10px; background: var(--gray-100); }
.result-preview { width: 100%; aspect-ratio: 16 / 9; display: block; object-fit: cover; }
.result h2 { margin: .55rem 0 .35rem; font-size: 1.18rem; }
.result p { margin-bottom: .55rem; }
.empty { padding: clamp(2rem, 6vw, 5rem); border: 1px dashed var(--gray-300); border-radius: var(--radius-lg); background: var(--white); text-align: center; }
.empty-icon { width: 54px; height: 54px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; color: var(--purple-700); background: var(--purple-100); font-size: 1.5rem; font-weight: 800; }
.muted { color: var(--gray-600); }

.auth { min-height: min(650px, calc(100vh - 180px)); display: grid; place-items: center; }
.auth-card { width: min(100%, 440px); padding: clamp(1.6rem, 5vw, 2.5rem); border-radius: var(--radius-lg); text-align: center; }
.auth-card.wide { width: min(100%, 760px); }
.logo-mark { width: 64px; height: 64px; margin: 0 auto 1.2rem; display: grid; place-items: center; border-radius: 18px; color: var(--white); background: linear-gradient(135deg, var(--purple-900), var(--purple-600)); box-shadow: 0 12px 24px rgb(75 31 120 / 24%); font-size: 1.25rem; font-weight: 850; }
.auth-card form, .form { text-align: left; }
.auth-card > small { display: block; margin-top: 1.35rem; color: var(--gray-600); }

label { display: grid; gap: .4rem; margin-bottom: 1rem; color: var(--gray-700); font-size: .88rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: .62rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); color: var(--gray-950); background: var(--white); outline: 0; transition: border-color var(--transition), box-shadow var(--transition); }
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--purple-600); box-shadow: 0 0 0 3px rgb(123 63 178 / 12%); }
input::placeholder, textarea::placeholder { color: #99939d; }
input[type="file"] { padding: .48rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { margin-bottom: 1.5rem; padding: 1.4rem; border-radius: var(--radius); }
.alert { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid; border-radius: var(--radius-sm); font-size: .9rem; }
.alert.error { border-color: #fecdca; color: var(--danger); background: var(--danger-bg); }
.alert.success { border-color: #abefc6; color: var(--success); background: var(--success-bg); }

.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: clamp(1.5rem, 4vw, 3rem); }
.admin-layout > section { min-width: 0; }
.admin-nav { position: sticky; top: 92px; display: grid; gap: .3rem; padding: .8rem; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow-sm); }
.admin-nav strong { padding: .55rem .65rem; color: var(--gray-600); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.admin-nav a { padding: .58rem .7rem; border-radius: var(--radius-sm); color: var(--gray-700); font-size: .9rem; font-weight: 620; }
.admin-nav a:hover { color: var(--purple-800); background: var(--purple-50); }
.stat-grid { margin-bottom: 1.5rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.stat { padding: 1.2rem; border-radius: var(--radius); }
.stat strong { display: block; color: var(--purple-800); font-size: 1.85rem; line-height: 1.1; }
.stat span { color: var(--gray-600); font-size: .86rem; }

.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .85rem 1rem; border-bottom: 1px solid var(--gray-200); text-align: left; vertical-align: middle; }
th { color: var(--gray-600); background: var(--gray-50); font-size: .75rem; font-weight: 750; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--purple-50); }

.copy.copied { border-color: var(--success); color: var(--success); background: var(--success-bg); box-shadow: none; }

@media (max-width: 860px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { position: static; display: flex; overflow-x: auto; white-space: nowrap; }
  .admin-nav strong { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .searchbox.compact { flex-wrap: wrap; }
  .searchbox.compact input:first-child { flex-basis: calc(100% - 7rem); }
  .weekly-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .weekly-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { min-height: 60px; flex-wrap: wrap; gap: .45rem; }
  .topbar nav { width: 100%; flex-wrap: wrap; overflow: visible; order: 2; padding-bottom: .1rem; }
  .topbar nav > a, .topbar .link { min-height: 44px; display: inline-flex; align-items: center; }
  .topbar .user { margin-left: auto; }
  .container { width: min(calc(100% - 1.25rem), var(--container)); padding: 1.5rem 0 2.5rem; }
  .hero { padding: 2rem 1rem; border-radius: var(--radius); }
  .searchbox { flex-direction: column; border-radius: 12px; }
  .searchbox input { flex-basis: auto; min-height: 46px; }
  .searchbox.compact input:first-child, .searchbox.compact select, .searchbox.compact input[type="number"] { flex-basis: auto; }
  .cards, .grid.two, .grid.three, .stat-grid { grid-template-columns: 1fr; }
  .admin-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; white-space: normal; }
  .admin-nav a { min-height: 44px; display: flex; align-items: center; }
  .metric { margin-bottom: 2.5rem; }
  .result { align-items: flex-start; flex-direction: column; gap: .8rem; }
  .result-preview-link { width: 100%; flex-basis: auto; }
  .result .actions { width: 100%; }
  .result .actions .btn { flex: 1; }
  .detail { padding: 1.25rem; border-radius: var(--radius); }
  dl { grid-template-columns: 1fr; gap: .1rem; }
  dd { margin-bottom: .55rem; }
  .page-head.page-head-row { align-items: flex-start; }
  .page-head.page-head-row .btn { flex-shrink: 0; }
  .table-wrap table { min-width: 680px; }
  th, td { padding: .7rem .75rem; }
}

@media (max-width: 420px) {
  .weekly-menu { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
