@import url("https://fonts.googleapis.com/css2?family=LINE+Seed+Sans+TH:wght@400;600;700;800&family=Mali:wght@500;600;700&family=Noto+Sans+Thai:wght@400;600;700;800&family=Prompt:wght@400;600;700&display=swap");

@font-face {
  font-family: "TorsilpLamun";
  src: url("../fonts/TorsilpLamun.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #243047;
  --muted: #7b8190;
  --line: rgba(255, 255, 255, 0.65);
  --panel: rgba(255, 255, 255, 0.72);
  --bg: #fff7fb;
  --primary-pink: #ff8fc7;
  --purple: #a78bfa;
  --blue: #60a5fa;
  --mint: #5eead4;
  --yellow: #fde68a;
  --red: #fb7185;
  --radius: 28px;
  --shadow: 0 18px 45px rgba(119, 91, 255, 0.16);
  --shadow-strong: 0 24px 60px rgba(119, 91, 255, 0.22);
}

* {
  box-sizing: border-box;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blobMove {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  33% {
    transform: translate3d(22px, -18px, 0) scale(1.05);
  }
  66% {
    transform: translate3d(-18px, 20px, 0) scale(0.96);
  }
}

@keyframes softFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "LINE Seed Sans TH", "Noto Sans Thai", "Prompt", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 143, 199, 0.28), transparent 32%),
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.28), transparent 30%),
    linear-gradient(135deg, #fff7fb 0%, #eef7ff 50%, #f4f0ff 100%);
  overflow-x: hidden;
  font-size: 19px;
  letter-spacing: 0;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.56;
  animation: blobMove 13s ease-in-out infinite;
  pointer-events: none;
}

body::before {
  left: 44%;
  top: 8%;
  background: rgba(167, 139, 250, 0.24);
}

body::after {
  right: 5%;
  bottom: 7%;
  background: rgba(94, 234, 212, 0.22);
  animation-delay: -5s;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.k-card,
.login-panel,
.panel,
.doc-card,
.stat-card,
.status-box,
.audit-item {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.k-card:hover,
.panel:hover,
.doc-card:hover,
.stat-card:hover,
.status-box:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-strong);
}

.fade-up,
.login-panel,
.workspace,
.panel,
.stat-card,
.doc-card,
.audit-item {
  animation: fadeUp 0.55s ease both;
}

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

.login-panel {
  position: relative;
  width: min(520px, 100%);
  display: grid;
  gap: 22px;
  padding: 36px;
  overflow: hidden;
}

.login-panel::before {
  content: "K-Seoul Office";
  position: absolute;
  right: 22px;
  top: 18px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #8b5cf6;
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 800;
}

.brand-mark {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary-pink), var(--purple), var(--blue));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(167, 139, 250, 0.3);
}

.brand-mark.small {
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.school-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.login-logo {
  width: 104px;
  height: 104px;
  padding: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow: 0 18px 40px rgba(96, 165, 250, 0.18);
  animation: softFloat 4.5s ease-in-out infinite;
}

.school-logo.small {
  width: 48px;
  height: 48px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: "Mali", "LINE Seed Sans TH", "Noto Sans Thai", sans-serif;
}

h1 {
  font-size: clamp(38px, 6vw, 58px);
  line-height: 1;
}

h2 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.1;
}

h3 {
  font-size: 27px;
}

h4 {
  font-size: 21px;
}

.school-name {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.25;
  color: #4f46e5;
}

.eyebrow {
  color: #7c3aed;
  font-size: 15px;
  font-weight: 800;
}

.muted,
.hint,
.form-message,
.field-hint {
  color: var(--muted);
}

.stack,
.form-panel {
  display: grid;
  gap: 15px;
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: #39435f;
  font-weight: 800;
}

.field-hint {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(175, 188, 215, 0.42);
  border-radius: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(167, 139, 250, 0.82);
  box-shadow: 0 0 0 5px rgba(167, 139, 250, 0.16);
}

textarea {
  resize: vertical;
}

.primary-btn,
.ghost-btn,
.small-btn,
.k-button-primary {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 800;
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.primary-btn,
.k-button-primary {
  color: #fff;
  background: linear-gradient(135deg, #ff8fc7, #a78bfa, #60a5fa);
  box-shadow: 0 12px 28px rgba(167, 139, 250, 0.32);
}

.ghost-btn,
.small-btn {
  color: #39435f;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.78);
}

.primary-btn:hover,
.ghost-btn:hover,
.small-btn:hover,
.k-button-primary:hover,
.nav-list button:hover {
  transform: translateY(-3px) scale(1.01);
  filter: saturate(1.06);
}

.small-btn {
  min-height: 34px;
  padding: 5px 12px;
}

.danger-btn {
  color: #be3455;
  background: rgba(255, 228, 236, 0.9);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 22px;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(22px);
  border-right: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 12px 0 40px rgba(96, 165, 250, 0.12);
}

.app-title {
  display: flex;
  gap: 13px;
  align-items: center;
}

.app-title strong {
  display: block;
  font-family: "Mali", "LINE Seed Sans TH", sans-serif;
  font-size: 24px;
}

.app-title span {
  display: block;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.3;
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-list button {
  position: relative;
  min-height: 48px;
  text-align: left;
  border: 0;
  border-radius: 18px;
  padding: 11px 14px 11px 18px;
  color: #35405f;
  background: transparent;
  font-weight: 800;
  overflow: hidden;
  transition: transform 0.22s ease, background-color 0.22s ease, color 0.22s ease;
}

.nav-list button::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 4px;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary-pink), var(--blue));
  transform: translateY(-50%);
  transition: height 0.22s ease;
}

.nav-list button.active {
  color: #4f46e5;
  background: linear-gradient(135deg, rgba(255, 143, 199, 0.18), rgba(96, 165, 250, 0.18));
}

.nav-list button.active::after {
  height: 28px;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.mode-badge,
.status-pill,
.doc-type,
.k-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.mode-badge {
  color: #059669;
  background: rgba(209, 250, 229, 0.76);
}

.workspace {
  min-width: 0;
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar > div:first-child {
  display: grid;
  gap: 5px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.alert {
  margin-bottom: 16px;
  padding: 13px 16px;
  color: #03624c;
  background: rgba(209, 250, 229, 0.82);
  border: 1px solid rgba(94, 234, 212, 0.5);
  border-radius: 18px;
}

.alert.error {
  color: #be3455;
  background: rgba(255, 228, 236, 0.86);
  border-color: rgba(255, 143, 199, 0.42);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(150px, auto);
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  min-height: 150px;
  padding: 22px;
  overflow: hidden;
}

.stat-card::before {
  position: absolute;
  right: 18px;
  top: 14px;
  font-size: 34px;
  opacity: 0.92;
}

.stat-card span {
  color: var(--muted);
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 18px;
  font-size: 52px;
  line-height: 1;
}

.accent-blue {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.23), rgba(255, 255, 255, 0.72));
}

.accent-blue::before {
  content: "📘";
}

.accent-green {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.24), rgba(255, 255, 255, 0.72));
}

.accent-green::before {
  content: "📝";
}

.accent-orange {
  background: linear-gradient(135deg, rgba(253, 230, 138, 0.42), rgba(255, 255, 255, 0.72));
}

.accent-orange::before {
  content: "📤";
}

.accent-pink {
  background: linear-gradient(135deg, rgba(255, 143, 199, 0.26), rgba(255, 255, 255, 0.72));
}

.accent-pink::before {
  content: "📎";
}

.split-layout,
.form-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.08fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 22px;
}

.form-panel {
  position: relative;
}

.form-panel::before {
  content: "✏️";
  position: absolute;
  right: 20px;
  top: 18px;
  font-size: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.doc-list,
.status-grid {
  display: grid;
  gap: 12px;
}

.doc-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 15px;
}

.doc-card h4 {
  margin-top: 6px;
}

.doc-card p {
  color: var(--muted);
  font-size: 15px;
}

.doc-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-type {
  color: #5b4fc7;
  background: rgba(237, 233, 254, 0.82);
}

.status-pending {
  color: #b45309;
  background: rgba(254, 243, 199, 0.9);
}

.status-approved,
.status-delivered {
  color: #047857;
  background: rgba(209, 250, 229, 0.9);
}

.status-returned,
.status-cancelled {
  color: #be3455;
  background: rgba(255, 228, 236, 0.9);
}

.status-sent {
  color: #2563eb;
  background: rgba(219, 234, 254, 0.92);
}

.status-select,
.compact-select {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
}

.status-select {
  width: 160px;
}

.compact-select {
  width: min(270px, 100%);
}

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

.status-box {
  padding: 16px;
}

.status-box span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.status-box strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.empty-state {
  min-height: 88px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(167, 139, 250, 0.36);
  border-radius: 22px;
}

.empty-state::before {
  content: "✨";
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
}

.checklist {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 20px;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.checklist input {
  width: auto;
  min-height: 0;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filter-submit {
  align-self: end;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  display: grid;
  gap: 5px;
  padding: 14px;
}

.audit-item span {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  }

  .nav-list {
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .sidebar-footer {
    grid-template-columns: 1fr auto auto;
  }

  .split-layout,
  .form-grid,
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    font-size: 17px;
  }

  .workspace,
  .sidebar,
  .login-panel {
    padding: 18px;
  }

  .login-actions,
  .topbar,
  .doc-card,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .split-layout,
  .form-grid,
  .two-col,
  .status-grid,
  .search-row,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .doc-meta {
    justify-content: flex-start;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    font-family: "TorsilpLamun", "TH Sarabun New", serif;
    background: #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
