/* ==========================================================================
   STYLE.CSS: LIQUID GLASS (CLEAN GLASSMORPHISM) - OPTIMIZED FOR 3-SEC USE
   มาตรฐานสัดส่วนสี: 60% Dark Slate | 30% Frosted Glass | 10% Accents
   ========================================================================== */

:root {
  /* 60% สีกรมท่าดำสนิท (ถนอมจอ OLED + ไม่กินพลังงาน) */
  --bg-core: #0b0f17;
  --bg-gradient: radial-gradient(circle at 50% 0%, #1e293b 0%, #0b0f17 75%);

  /* 30% กระจกแก้วคลีน สบายตา (Optimized Clean Glass) */
  --glass-surface: rgba(255, 255, 255, 0.05);
  --glass-surface-active: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-focus: rgba(255, 255, 255, 0.35);

  /* สีตัวอักษรมาตรฐานความคมชัดสากล (High Contrast Reading) */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* 10% สัญญาณการเงินระดับสากล (Financial Status Colors) */
  --income-emerald: #10b981;   /* เขียวมรกต: รายรับ / เงินงอกเงย */
  --expense-coral: #f43f5e;    /* คอรัลทับทิม: รายจ่าย (มองง่าย ไม่น่ากลัวเหมือนแดงเลือดหมู) */
  --transfer-cyan: #06b6d4;    /* ฟ้าไซยาน: โอนย้าย/เงินลงทุน (พอร์ตหุ้น) */
  --family-violet: #8b5cf6;    /* ม่วงคราม: สัญลักษณ์กองกลางครอบครัว */
}

/* ตั้งค่ามาตรฐาน: ไม่ให้ซูมผิดจังหวะ และปิดเอฟเฟกต์สีเทาเวลาแตะบน iOS */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* System Font Stack สากลของ Apple/Google: คมชัด โหลดทันที ฟรีลิขสิทธิ์ 100% */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", 
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background: var(--bg-core);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
}

/* กรอบคุมขนาดแอป: สวยบน iPhone และล็อกความกว้างพอดีสายตาบน iPad/Mac/PC */
.app-container {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  /* เว้นระยะขอบปลอดภัยสำหรับ iPhone รอยบาก และ Dynamic Island */
  padding-top: env(safe-area-inset-top, 16px);
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* --------------------------------------------------------------------------
   ส่วนหัว: แถบสวิตช์และปุ่มตั้งค่า (Liquid Glass Header)
   -------------------------------------------------------------------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
}

.mode-switch {
  flex: 1;
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 4px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mode-btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ปุ่มโหมดส่วนตัวเมื่อถูกเลือก */
.mode-btn.active-personal {
  background: var(--glass-surface-active);
  color: #ffffff;
  border: 1px solid var(--glass-border-focus);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ปุ่มโหมดกองกลางเมื่อถูกเลือก */
.mode-btn.active-family {
  background: rgba(139, 92, 246, 0.25);
  color: #e9d5ff;
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.15);
}

/* ปุ่มกลมสำหรับฟันเฟืองตั้งค่า */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.1s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--glass-surface-active);
}

/* --------------------------------------------------------------------------
   แผงแสดงตัวเลขรายรับ-รายจ่าย (High Clarity Display)
   -------------------------------------------------------------------------- */
.display-box {
  text-align: center;
  margin: 18px 0 14px 0;
  padding: 0 20px;
}

.display-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.display-amount {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: #ffffff;
  line-height: 1.1;
  text-shadow: 0 2px 20px rgba(255, 255, 255, 0.1);
}

/* --------------------------------------------------------------------------
   แผงหมวดหมู่อีโมจิ (Liquid Glass Category Pills)
   -------------------------------------------------------------------------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 0 18px;
  margin-bottom: 16px;
}

.cat-item {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}

.cat-item:active {
  transform: scale(0.95);
}

.cat-item.selected {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}

.cat-icon {
  font-size: 26px;
  display: block;
  margin-bottom: 4px;
}

.cat-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.cat-item.selected .cat-name {
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   แป้นพิมพ์ตัวเลขด่วน 3 วินาที (Tactile Numpad)
   -------------------------------------------------------------------------- */
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 18px;
  margin-top: auto;
  margin-bottom: 12px;
}

.num-btn {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  color: #ffffff;
  font-size: 26px;
  font-weight: 600;
  padding: 15px;
  border-radius: 16px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.1s ease;
}

.num-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.96);
}

/* ปุ่มบันทึกด่วน: เด่นชัด จบใน 3 วินาที */
.save-btn {
  grid-column: span 3;
  background: var(--income-emerald);
  color: #064e3b;
  color: #ffffff;
  border: none;
  font-size: 18px;
  font-weight: 700;
  padding: 16px;
  border-radius: 16px;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.35);
  transition: transform 0.1s ease;
}

.save-btn:active {
  transform: scale(0.98);
}

/* --------------------------------------------------------------------------
   แถบเมนูด้านล่าง 5 ปุ่ม (Liquid Glass Bottom Navigation)
   -------------------------------------------------------------------------- */
#content-frame {
  flex: 1;
  padding-bottom: 90px; /* เว้นระยะด้านล่างไม่ให้เนื้อหาถูกแถบเมนูบัง */
  overflow-y: auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  height: calc(65px + env(safe-area-inset-bottom, 10px));
  padding-bottom: env(safe-area-inset-bottom, 10px);
  background: rgba(11, 15, 23, 0.82);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  transition: all 0.2s ease;
}

.nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
  transition: transform 0.15s ease;
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

/* ปุ่มที่กำลังเลือกอยู่ */
.nav-item.active {
  color: #ffffff;
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
}

/* ปุ่มพิเศษตรงกลาง (Hero Action Button) สำหรับบันทึกด่วน */
.nav-item.nav-hero {
  position: relative;
  top: -12px;
}

.hero-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
  margin-bottom: 2px;
  transition: transform 0.15s ease;
}

.nav-item.nav-hero:active .hero-circle {
  transform: scale(0.92);
}

/* ป้ายสถานะสีในรายการบันทึก (Financial Badges) */
.badge-income { color: var(--income-emerald); font-weight: 600; }
.badge-expense { color: var(--expense-coral); font-weight: 600; }
.badge-invest { color: var(--transfer-cyan); font-weight: 600; }
