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

:root {
  --bg-app: #0b1526;
  --bg-stage: #070e1a;
  --primary-navy: #0e2a47;
  --primary-blue: #0077b6;
  --primary-cyan: #00b4d8;
  --water-light: #e0f2fe;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --card-bg: rgba(255, 255, 255, 0.98);
  --card-border: rgba(226, 232, 240, 0.9);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 6px 10px -6px rgba(0, 0, 0, 0.08);
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --font-title: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-dark);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ==========================================================================
   Top App Bar (Controls & Actions)
   ========================================================================== */
.app-topbar {
  height: 60px;
  background: linear-gradient(90deg, #07172c 0%, #0d2a4a 50%, #081a33 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  color: #fff;
  flex-shrink: 0;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 119, 182, 0.3);
}

.app-title-group h1 {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #f8fafc;
  line-height: 1.2;
}

.app-title-group p {
  font-size: 12px;
  color: #93c5fd;
  font-weight: 400;
}

.app-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.month-picker-wrap label {
  font-size: 12px;
  color: #bae6fd;
  font-family: var(--font-title);
}

.month-select {
  background: transparent;
  color: #ffffff;
  border: none;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  padding-right: 8px;
}

.month-select option {
  background: #0f2744;
  color: #ffffff;
}

/* Action Buttons */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
}

.btn-copy {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-copy:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* ==========================================================================
   16:9 Presentation Stage Viewport
   ========================================================================== */
.presentation-viewport {
  flex: 1;
  width: 100%;
  height: calc(100vh - 120px);
  background: var(--bg-stage);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Fixed 1920x1080 Canvas, scaled dynamically via JS */
#slideCanvas {
  width: 1920px;
  height: 1080px;
  background: #f8fafc;
  position: absolute;
  transform-origin: center center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Slide Container */
.slide-page {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  padding: 28px 44px 20px 44px;
  background: radial-gradient(circle at 90% 10%, rgba(224, 242, 254, 0.45) 0%, rgba(248, 250, 252, 1) 70%);
  position: relative;
}

.slide-page.active {
  display: flex;
}

/* Slide Header (16:9 internal) */
.slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.slide-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slide-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 119, 182, 0.2));
}

.slide-title-wrap h2 {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
  color: #0c2d48;
  line-height: 1.2;
}

.slide-title-wrap .sub-org {
  font-size: 14px;
  font-weight: 500;
  color: #0077b6;
  margin-top: 2px;
}

.slide-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-month {
  background: linear-gradient(135deg, #0e2a47 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 6px 16px;
  border-radius: 30px;
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(14, 42, 71, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-slide-num {
  background: #e2e8f0;
  color: #334155;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 30px;
}

/* ==========================================================================
   Slide Content Grid & Cards
   ========================================================================== */
.slide-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* Hero KPI Row (5 Blocks for Slide 1) */
.kpi-row-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.kpi-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: #0284c7;
}

.kpi-card.kpi-accent-blue::before { background: #0284c7; }
.kpi-card.kpi-accent-cyan::before { background: #06b6d4; }
.kpi-card.kpi-accent-emerald::before { background: #10b981; }
.kpi-card.kpi-accent-indigo::before { background: #6366f1; }
.kpi-card.kpi-accent-amber::before { background: #f59e0b; }

.kpi-card .card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-title);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kpi-card .card-value-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.kpi-card .card-value {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: #0c2d48;
  line-height: 1.1;
}

.kpi-card .card-unit {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.kpi-card .card-subtext {
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
  line-height: 1.35;
}

/* Comparison Badges (MoM & YoY) */
.comparison-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
}

.cmp-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-title);
}

.cmp-badge.up-pos {
  background: #dcfce7;
  color: #15803d;
}

.cmp-badge.down-pos {
  background: #dbeafe;
  color: #1d4ed8;
}

.cmp-badge.up-neg {
  background: #fee2e2;
  color: #b91c1c;
}

.cmp-badge.down-neg {
  background: #dcfce7;
  color: #15803d;
}

.cmp-badge.neutral {
  background: #f1f5f9;
  color: #475569;
}

.cmp-label-small {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 500;
}

/* Missing Data Badge */
.no-data-text {
  color: #ef4444;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-title);
}

/* Split Main Layout (Grid 60/40 or 50/50) */
.slide-grid-60-40 {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.slide-grid-50-50 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

/* Card Containers */
.content-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.content-box-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  color: #0c2d48;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Fit to Block Chart Wrapper */
.chart-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Table Design */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.cmp-table th {
  background: #f1f5f9;
  color: #334155;
  font-family: var(--font-title);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #cbd5e1;
}

.cmp-table th:last-child,
.cmp-table td:last-child {
  text-align: right;
}

.cmp-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
}

.cmp-table tr:hover td {
  background: #f8fafc;
}

.cmp-table .num-bold {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 13px;
}

/* Phase Cards (Slide 2) */
.phases-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}

.phase-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phase-card-header {
  background: linear-gradient(135deg, #0e2a47 0%, #1e3a8a 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-title);
}

.phase-card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.phase-share-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.phase-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.phase-metric-block {
  display: flex;
  flex-direction: column;
  padding-bottom: 6px;
  border-bottom: 1px dashed #e2e8f0;
}

.phase-metric-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.phase-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.phase-metric-head .lbl {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
}

.phase-metric-head .val {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

/* Chemical Cards (Slide 3) */
.chem-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}

.chem-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chem-card .chem-name {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  color: #0e2a47;
  margin-bottom: 10px;
}

.chem-stat-group {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chem-stat {
  flex: 1;
}

.chem-stat .val-big {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  color: #0284c7;
}

.chem-stat .unit {
  font-size: 11px;
  color: #64748b;
}

/* Slide 3: 3-Chart Chemical Layout */
.chem-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.chem-chart-box {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.chem-chart-title {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  color: #0e2a47;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Slide 3: Stock Inventory Display */
.stock-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  justify-content: space-around;
}

.stock-item-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
}

.stock-item-card:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 119, 182, 0.1);
  border-color: #93c5fd;
}

.stock-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0284c7;
}

.stock-icon-wrap svg {
  width: 32px;
  height: 32px;
}

.stock-details {
  flex: 1;
}

.stock-details .lbl {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
  font-family: var(--font-title);
  margin-bottom: 2px;
}

.stock-details .val-big {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  color: #0c2d48;
  line-height: 1;
}

.stock-details .unit {
  font-size: 13px;
  color: #64748b;
  font-weight: normal;
  margin-left: 4px;
}

/* Energy & SEC Highlight (Slide 4) */
.sec-hero-card {
  background: linear-gradient(135deg, #071e3d 0%, #1a365d 60%, #0077b6 100%);
  color: #ffffff;
  border-radius: 12px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 20px rgba(7, 30, 61, 0.25);
  margin-bottom: 12px;
}

.sec-left h3 {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 600;
  color: #bae6fd;
  margin-bottom: 2px;
}

.sec-left p {
  font-size: 12px;
  color: #e0f2fe;
}

.sec-center {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sec-number {
  font-family: var(--font-title);
  font-size: 48px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: -1px;
}

.sec-unit {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 500;
  color: #e0f2fe;
}

.sec-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
}

/* Slide Footer Inside 16:9 Slide */
.slide-footer-internal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 11.5px;
  color: #64748b;
  margin-top: auto;
  flex-shrink: 0;
}

/* ==========================================================================
   Bottom Navigation Bar
   ========================================================================== */
.app-bottombar {
  height: 60px;
  background: #081528;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 18px;
  border-radius: 20px;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.nav-tab-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.nav-arrow-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 18px;
  border-radius: 8px;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-arrow-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.nav-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Toast Notifications */
.toast-notice {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 30px;
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  border: 1px solid #334155;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-notice .icon {
  font-size: 18px;
  color: #10b981;
}
