/* ==========================================================================
   รายงานแผน-ผลการผลิตพันธุ์พืชและปัจจัยการผลิต | หน้ารวมรายงาน (Guest Hub)
   กรมวิชาการเกษตร กองยุทธศาสตร์และแผนงาน กลุ่มติดตามและประเมินผล

   สไตล์ชีตนี้เขียนขึ้นแทน Tailwind Play CDN (cdn.tailwindcss.com)
   ซึ่งคอมไพล์ CSS ในเบราว์เซอร์ทุกครั้งที่โหลดหน้า และไม่รองรับ production
   ผลลัพธ์ทางสายตาคงเดิมทั้งหมด
   ========================================================================== */

/* --------------------------------------------------------------------------
   1) Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* palette (คงค่าสีเดิมจาก Tailwind emerald / teal / slate / gray) */
  --c-emerald-50: #ecfdf5;
  --c-emerald-100: #d1fae5;
  --c-emerald-200: #a7f3d0;
  --c-emerald-400: #34d399;
  --c-emerald-500: #10b981;
  --c-emerald-600: #059669;
  --c-emerald-700: #047857;
  --c-emerald-800: #065f46;
  --c-emerald-900: #064e3b;
  --c-emerald-950: #022c22;
  --c-teal-500: #14b8a6;
  --c-teal-800: #115e59;
  --c-slate-100: #f1f5f9;
  --c-slate-200: #e2e8f0;
  --c-slate-300: #cbd5e1;
  --c-slate-400: #94a3b8;
  --c-slate-500: #64748b;
  --c-slate-800: #1e293b;
  --c-gray-200: #e5e7eb;
  --c-gray-600: #4b5563;

  /* พื้นหลังไล่สี: ค่าเดิมเป็น rgba() ทับสีขาว จึงยุบเป็นสีทึบเทียบเท่า
     เพื่อตัดงาน alpha compositing ออก */
  --bg-top: #f2faf5;
  --bg-bottom: #eef7fc;

  --shell-max: 1800px;
  --radius-md: 0.375rem;
  --radius-lg: 1rem;

  --ease-out-quint: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   2) Reset / base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background-color: var(--bg-bottom);
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--c-slate-300) var(--c-slate-100);
}

body {
  min-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: "Prompt", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--c-slate-800);
  background-image: linear-gradient(to bottom, var(--bg-top) 0%, var(--bg-bottom) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h3,
p {
  margin: 0;
  font: inherit;
}

img,
svg {
  display: block;
}

a {
  text-decoration: none;
  color: inherit;
}

/* scrollbar (WebKit/Blink) */
html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html::-webkit-scrollbar-track {
  background: var(--c-slate-100);
}
html::-webkit-scrollbar-thumb {
  background: var(--c-slate-300);
  border-radius: 4px;
}
html::-webkit-scrollbar-thumb:hover {
  background: var(--c-slate-400);
}

/* ให้เห็น focus ชัดเจนเมื่อใช้คีย์บอร์ด (WCAG 2.4.7) */
:focus-visible {
  outline: 2px solid var(--c-emerald-600);
  outline-offset: 2px;
}

/* คลังไอคอน SVG (ไม่แสดงผล ใช้อ้างอิงผ่าน <use> เท่านั้น) */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3) Layout shell
   -------------------------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 640px) {
  .shell {
    padding-inline: 1.5rem;
  }
}
@media (min-width: 1024px) {
  .shell {
    padding-inline: 2.5rem;
  }
}
@media (min-width: 1280px) {
  .shell {
    padding-inline: 3rem;
  }
}

/* --------------------------------------------------------------------------
   4) Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  color: #fff;
  background-image: linear-gradient(
    to right,
    var(--c-emerald-800) 0%,
    var(--c-teal-800) 50%,
    var(--c-emerald-950) 100%
  );
  box-shadow: var(--shadow-lg);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
}

@media (min-width: 640px) {
  .site-header__bar {
    height: 5rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand__logo {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: contain;
}

@media (min-width: 640px) {
  .brand__logo {
    width: 2.5rem;
    height: 2.5rem;
  }
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand__title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.025em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  overflow: hidden;
}

@media (min-width: 640px) {
  .brand__title {
    font-size: 1.125rem;
  }
}
@media (min-width: 1024px) {
  .brand__title {
    font-size: 1.25rem;
  }
}

.brand__subtitle {
  display: block;
  font-size: 10px;
  font-weight: 300;
  color: rgba(167, 243, 208, 0.8);
}

@media (min-width: 640px) {
  .brand__subtitle {
    font-size: 0.75rem;
    line-height: 1rem;
  }
}

/* ป้ายบอกโหมดผู้ใช้ */
.mode-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  padding: 0.375rem 0.875rem;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 9999px;
  background-color: rgba(6, 78, 59, 0.5);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  color: rgba(255, 255, 255, 0.9);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mode-badge:hover {
  background-color: rgba(6, 78, 59, 0.8);
  color: #fff;
}

@media (min-width: 640px) {
  .mode-badge {
    font-size: 0.875rem;
  }
}

.mode-badge__dot {
  position: relative;
  display: flex;
  width: 0.625rem;
  height: 0.625rem;
  flex: none;
}

.mode-badge__dot::before,
.mode-badge__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background-color: var(--c-emerald-400);
}

.mode-badge__dot::before {
  opacity: 0.75;
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* --------------------------------------------------------------------------
   5) Main + card grid
   -------------------------------------------------------------------------- */
.site-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding-block: 2rem;
  animation: fade-in-up 0.6s var(--ease-out-quint) both;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  .card-grid {
    gap: 2rem;
  }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 24rem;
  overflow: hidden;
  background-color: #fff;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s var(--ease-out-quint), box-shadow 0.4s var(--ease-out-quint);
}

@media (min-width: 1024px) {
  .card {
    max-width: none;
  }
}

.card:hover {
  transform: translateY(-0.375rem);
  box-shadow: var(--shadow-xl);
}

/* แถบสีด้านบนการ์ด */
.card::before {
  content: "";
  display: block;
  flex: none;
  height: 0.375rem;
  background-image: linear-gradient(to right, var(--c-emerald-500), var(--c-teal-500));
}

.card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
}

@media (min-width: 640px) {
  .card__body {
    padding: 2rem;
  }
}

.card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(209, 250, 229, 0.5);
  border-radius: var(--radius-lg);
  background-color: var(--c-emerald-50);
  color: var(--c-emerald-600);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.card__icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.card:hover .card__icon {
  background-color: var(--c-emerald-600);
  border-color: var(--c-emerald-600);
  color: #fff;
}

.card__title {
  margin-bottom: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--c-slate-800);
  transition: color 0.2s ease;
}

@media (min-width: 640px) {
  .card__title {
    font-size: 1.25rem;
  }
}

.card:hover .card__title {
  color: var(--c-emerald-700);
}

.card__text {
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 300;
  line-height: 1.625;
  color: var(--c-slate-500);
}

.card__footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--c-slate-100);
}

.card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-emerald-600);
  border-radius: var(--radius-md);
  transition: color 0.2s ease;
}

/* ขยายพื้นที่คลิกให้ครอบทั้งการ์ด */
.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
}

.card:hover .card__link {
  color: var(--c-emerald-700);
}

.card__link svg {
  width: 0.875rem;
  height: 0.875rem;
  transition: transform 0.3s ease;
}

.card:hover .card__link svg {
  transform: translateX(0.375rem);
}

/* --------------------------------------------------------------------------
   6) Footer
   -------------------------------------------------------------------------- */
.site-footer {
  width: 100%;
  padding-block: 1rem;
  border-top: 1px solid var(--c-gray-200);
  background-color: #fff;
}

.site-footer p {
  padding-inline: 1rem;
  font-size: 0.875rem;
  line-height: 1.625;
  text-align: center;
  color: var(--c-gray-600);
}

/* --------------------------------------------------------------------------
   7) Animations
   -------------------------------------------------------------------------- */
@keyframes fade-in-up {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  10% {
    opacity: 0.1;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes ping {
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card:hover {
    transform: none;
  }
}
