/* ===== BAAC Dashboard - Chibi Theme (LIVELY EDITION) ===== */
:root {
  --green-dark: #2D5F2D;
  --green-mid: #3F8B3F;
  --green-light: #A8D5A8;
  --gold: #D4AF37;
  --gold-light: #F4D77A;
  --cream: #FFF8E7;
  --red: #E55B5B;
  --orange: #F2A33A;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sarabun', 'Prompt', -apple-system, sans-serif;
  background: linear-gradient(135deg, #f5f9f0 0%, #fff8e7 100%);
  color: #2a2a2a;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.hero-bg {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center 60%;
  display: block;
  animation: kenBurns 20s ease-in-out infinite alternate;
}
@keyframes kenBurns {
  0%   { transform: scale(1) translateX(0); }
  100% { transform: scale(1.08) translateX(-1%); }
}

.hero-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(to right, rgba(255,248,231,0.85), transparent 60%);
}

.hero-left h1 {
  font-size: 28px;
  color: var(--green-dark);
  text-shadow: 2px 2px 0 rgba(255,255,255,0.8);
  margin-bottom: 4px;
  animation: slideInLeft 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.hero-sub {
  font-size: 14px;
  color: #555;
  background: rgba(255,255,255,0.7);
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  animation: slideInLeft 0.8s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  background: var(--cream);
  border-bottom: 2px dashed var(--green-light);
  position: sticky;
  top: 0;
  z-index: 10;
  animation: slideInDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tab {
  background: white;
  border: 2px solid var(--green-light);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.tab::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}
.tab:hover {
  background: var(--green-light);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 4px 12px rgba(45,95,45,0.2);
}
.tab:hover::before {
  width: 200px;
  height: 200px;
}
.tab:active {
  transform: translateY(-1px) scale(0.98);
}
.tab.active {
  background: var(--green-dark);
  color: white;
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(45,95,45,0.4);
  animation: tabPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes tabPop {
  0%   { transform: scale(0.9); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===== Content ===== */
.content {
  padding: 24px 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.tab-pane {
  display: none;
  animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tab-pane.active { display: block; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Cards ===== */
.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--green-light);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  animation: cardSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(15px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* Stagger animation - แต่ละการ์ดเลื่อนเข้าทีละใบ */
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }
.kpi-card:nth-child(6) { animation-delay: 0.3s; }

.kpi-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}
/* แสงวิ่งตอน hover */
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.15), transparent);
  transition: left 0.6s;
}
.kpi-card:hover::after {
  left: 100%;
}

.kpi-card.status-exceed { border-left-color: var(--green-mid); }
.kpi-card.status-pass { border-left-color: var(--green-mid); }
.kpi-card.status-warn { border-left-color: var(--orange); }
.kpi-card.status-risk { border-left-color: var(--red); }
.kpi-card.status-neutral { border-left-color: #ccc; }

/* การ์ด exceed มีแสงระยิบระยับ */
.kpi-card.status-exceed {
  background: linear-gradient(135deg, white 0%, #fafff0 100%);
  animation: cardSlideIn 0.6s both, exceedGlow 2.5s ease-in-out infinite 1s;
}
@keyframes exceedGlow {
  0%, 100% { box-shadow: var(--shadow); }
  50%      { box-shadow: 0 0 20px rgba(212, 175, 55, 0.4); }
}

/* การ์ด risk เตือนภัย - กระพริบแถบซ้าย */
.kpi-card.status-risk {
  animation: cardSlideIn 0.6s both, riskPulse 1.5s ease-in-out infinite 1s;
}
@keyframes riskPulse {
  0%, 100% { border-left-color: var(--red); }
  50%      { border-left-color: #ff8a8a; box-shadow: 0 4px 12px rgba(229, 91, 91, 0.3); }
}

.kpi-name {
  font-size: 15px;
  color: #555;
  margin-bottom: 8px;
  font-weight: 500;
}
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 4px;
  animation: countUp 1s ease-out;
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}
.kpi-value .unit {
  font-size: 16px;
  color: #888;
  font-weight: 400;
  margin-left: 4px;
}
.kpi-target {
  font-size: 13px;
  color: #777;
  margin-bottom: 8px;
}
.kpi-note {
  font-size: 13px;
  color: #666;
  background: var(--cream);
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-block;
  margin-top: 6px;
}

/* ===== Progress Bar ===== */
.progress {
  background: #eee;
  border-radius: 12px;
  overflow: hidden;
  height: 18px;
  margin: 8px 0;
  position: relative;
}
.progress-bar {
  height: 100%;
  border-radius: 12px;
  background: var(--green-mid);
  position: relative;
  min-width: 0;
  animation: progressFill 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  background-size: 200% 100%;
  transition: width 0.6s ease-out;
}
@keyframes progressFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.progress-bar { transform-origin: left center; }
/* แถบขยับไปมา (shimmer) */
.progress-bar.exceed {
  background: linear-gradient(90deg, var(--green-mid), var(--gold), var(--green-mid));
  background-size: 200% 100%;
  animation: progressFill 1.2s cubic-bezier(0.4, 0, 0.2, 1), shimmer 2s linear infinite 1.2s;
}
.progress-bar.warn {
  background: linear-gradient(90deg, var(--orange), var(--gold-light), var(--orange));
  background-size: 200% 100%;
  animation: progressFill 1.2s cubic-bezier(0.4, 0, 0.2, 1), shimmer 3s linear infinite 1.2s;
}
.progress-bar.risk {
  background: linear-gradient(90deg, var(--red), #ff8a8a, var(--red));
  background-size: 200% 100%;
  animation: progressFill 1.2s cubic-bezier(0.4, 0, 0.2, 1), shimmer 1.5s linear infinite 1.2s;
}
.progress-bar.neutral { background: #ccc; }
@keyframes shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.progress-label {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: white;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

/* ===== Status Badge ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}
.badge-exceed, .badge-pass {
  background: var(--green-mid);
  color: white;
  animation: badgeShine 2s ease-in-out infinite;
}
@keyframes badgeShine {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(63, 139, 63, 0.4); }
  50%      { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(63, 139, 63, 0); }
}
.badge-warn {
  background: var(--orange);
  color: white;
  animation: badgeShine 2s ease-in-out infinite;
}
.badge-risk {
  background: var(--red);
  color: white;
  animation: badgeWiggle 0.6s ease-in-out infinite;
}
@keyframes badgeWiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-5deg); }
  75%      { transform: rotate(5deg); }
}
.badge-neutral { background: #999; color: white; }

/* ===== Deadline Table ===== */
.deadline-item {
  background: white;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border-left: 5px solid;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: cardSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.deadline-item:nth-child(1) { animation-delay: 0.05s; }
.deadline-item:nth-child(2) { animation-delay: 0.12s; }
.deadline-item:nth-child(3) { animation-delay: 0.19s; }
.deadline-item:nth-child(4) { animation-delay: 0.26s; }
.deadline-item:nth-child(5) { animation-delay: 0.33s; }
.deadline-item:nth-child(6) { animation-delay: 0.4s; }
.deadline-item:hover {
  transform: translateX(6px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.deadline-item.status-pass { border-color: var(--green-mid); }
.deadline-item.status-warn { border-color: var(--orange); }
.deadline-item.status-risk {
  border-color: var(--red);
  animation: cardSlideIn 0.6s both, riskPulse 1.5s ease-in-out infinite 1s;
}
.deadline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.deadline-month {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-dark);
}
.deadline-date {
  font-size: 13px;
  color: #666;
  background: var(--cream);
  padding: 3px 8px;
  border-radius: 8px;
}
.deadline-days {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}
.deadline-percent {
  font-size: 22px;
  font-weight: 700;
}
.deadline-money {
  font-size: 13px;
  color: #666;
  margin-top: 6px;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 18px;
  color: var(--green-dark);
  margin: 18px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--green-light);
  position: relative;
  animation: fadeInUp 0.6s ease-out;
}
.section-title::before {
  content: '📌';
  margin-right: 6px;
  display: inline-block;
  animation: titleBounce 2s ease-in-out infinite;
}
@keyframes titleBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-3px) rotate(-10deg); }
}

/* ===== Risk Filter UI ===== */
.risk-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.risk-stat {
  background: white;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid;
  cursor: pointer;
  transition: all 0.3s;
}
.risk-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.risk-stat.active { transform: scale(1.05); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.risk-stat.level-risk { border-color: var(--red); }
.risk-stat.level-warn { border-color: var(--orange); }
.risk-stat.level-pass { border-color: var(--green-mid); }
.risk-stat.level-neutral { border-color: #999; }
.risk-stat .count {
  font-size: 32px;
  font-weight: 800;
  display: block;
  margin-bottom: 4px;
}
.risk-stat.level-risk .count { color: var(--red); }
.risk-stat.level-warn .count { color: var(--orange); }
.risk-stat.level-pass .count { color: var(--green-mid); }
.risk-stat.level-neutral .count { color: #999; }
.risk-stat .label {
  font-size: 13px;
  color: #555;
  font-weight: 600;
}

.risk-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--cream);
  border-radius: 12px;
}
.filter-btn {
  background: white;
  border: 2px solid #ddd;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.filter-btn:hover { background: #f5f5f5; }
.filter-btn.active { background: var(--green-dark); color: white; border-color: var(--gold); }

.risk-group {
  margin-bottom: 20px;
}
.risk-group-title {
  font-size: 15px;
  color: var(--green-dark);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--cream);
  border-radius: 8px;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.risk-group-title.level-risk { border-color: var(--red); }
.risk-group-title.level-warn { border-color: var(--orange); }
.risk-group-title.level-pass { border-color: var(--green-mid); }
.risk-group-title.level-neutral { border-color: #999; }
.risk-group-title .count-badge {
  background: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  margin-left: auto;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px 20px;
  color: #777;
  font-size: 13px;
  background: var(--cream);
  margin-top: 32px;
  border-top: 2px dashed var(--green-light);
}
.footer code {
  background: white;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--green-dark);
  font-weight: 600;
}

/* ===== Floating decoration - เมฆลอย ===== */
body::before, body::after {
  content: '☁️';
  position: fixed;
  font-size: 40px;
  opacity: 0.15;
  pointer-events: none;
  z-index: -1;
}
body::before {
  top: 30%;
  left: 5%;
  animation: floatCloud1 18s ease-in-out infinite;
}
body::after {
  top: 60%;
  right: 8%;
  animation: floatCloud2 22s ease-in-out infinite;
}
@keyframes floatCloud1 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50%      { transform: translateX(50px) translateY(-20px); }
}
@keyframes floatCloud2 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50%      { transform: translateX(-40px) translateY(15px); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hero-content { padding: 12px; }
  .hero-left h1 { font-size: 20px; }
  .hero-avatar { width: 80px; height: 80px; }
  .hero-mascot { width: 64px; height: 64px; }
  .kpi-value { font-size: 26px; }
  .tab { font-size: 12px; padding: 6px 10px; }
  body::before, body::after { font-size: 30px; }
}
