/* Target Path: style.css */
/* เขียนโค้ดจาก agent version: .agents-3.13 */

:root {
  --pastel-yellow: #fef08a;
  --pastel-yellow-dark: #facc15;
  --pastel-bg: #fffdf0;
  --card-bg: #ffffff;
  --text-main: #475569;
  --text-dark: #1e293b;
  --accent-pink: #f472b6;
  --accent-green: #4ade80;
  --accent-blue: #60a5fa;
  --accent-red: #f87171;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Sarabun", "Mitr", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  outline: none !important;
}

button:focus,
button:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

body {
  background-color: #f1f5f9; /* เปลี่ยนพื้นหลังรอบนอกบน PC ให้เป็นสีเทาอ่อน สบายตา */
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

/* Mobile Frame Container (Clean Modern App Card บน PC) */
.mobile-frame {
  width: 100%;
  max-width: 430px;
  height: 92vh;
  max-height: 880px;
  background: var(--pastel-bg);
  border-radius: 28px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ปรับแต่งสำหรับมือถือจริง (Mobile Real Viewport) */
@media (max-width: 449px) {
  body {
    background-color: var(--pastel-bg);
  }
  .mobile-frame {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

/* ซ่อน Fake Status Bar ออกถาวรทุกอุปกรณ์ */
.top-status-bar {
  display: none !important;
}

.app-header {
  background: var(--pastel-yellow);
  padding: 18px 16px 16px 16px;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

.user-profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Mitr", sans-serif;
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--text-dark);
}

.scan-btn-top {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e2e8f0;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s;
}

.scan-btn-top:hover {
  background: #ffffff;
}

.balance-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 15px rgba(234, 179, 8, 0.15);
}

.balance-title {
  font-size: 0.85rem;
  color: #64748b;
  display: flex;
  justify-content: space-between;
}

.balance-amount {
  font-family: "Mitr", sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 4px 0;
}

.progress-bar-bg {
  height: 10px;
  background: #f1f5f9;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
}

.daily-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  text-align: center;
}

.summary-box span {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
}

.summary-box strong {
  font-size: 0.95rem;
  font-family: "Mitr", sans-serif;
}

/* Horizontal Scroll Tabs (จัดระเบียบปุ่มให้พอดีไม่ล้นตัดขอบ) */
.scroll-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 4px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.scroll-tabs::-webkit-scrollbar {
  display: none;
}

.tab-chip {
  flex: 1;
  padding: 6px 8px;
  background: #ffffff;
  border-radius: 20px;
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--text-main);
  border: 1px solid #f1f5f9;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tab-chip.active {
  background: var(--pastel-yellow-dark);
  color: var(--text-dark);
  font-weight: 600;
  border-color: #eab308;
}

.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px calc(85px + env(safe-area-inset-bottom, 0px)) 16px;
}

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

.section-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Wallets Grid */
.wallet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.wallet-item-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  border: 1px solid #fef08a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.shimmer {
  background: linear-gradient(90deg, #fef08a 25%, #fef9c3 50%, #fef08a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 72px;
  border: 1px solid #fef08a;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.wallet-item-card i {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.wallet-item-card .name {
  font-size: 0.75rem;
  color: #64748b;
}

.wallet-item-card .val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.cat-item {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid #f1f5f9;
  cursor: pointer;
}

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

.cat-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
}

.cat-label {
  font-size: 0.75rem;
  color: var(--text-dark);
  text-align: center;
}

/* Bottom Bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(65px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-left: 10px;
  padding-right: 10px;
  z-index: 100;
}

.nav-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #94a3b8;
  font-size: 0.7rem;
  background: none;
  border: none;
  cursor: pointer;
  width: 20%;
}

.nav-button i {
  font-size: 1.25rem;
  margin-bottom: 2px;
}
.nav-button.active {
  color: #ca8a04;
  font-weight: 600;
}

.add-main-btn {
  width: 52px;
  height: 52px;
  background: var(--pastel-yellow-dark);
  border-radius: 50%;
  border: 4px solid #ffffff;
  color: var(--text-dark);
  font-size: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 12px rgba(202, 138, 4, 0.4);
  margin-top: -24px;
  cursor: pointer;
}

/* Form Styles */
.form-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  margin-top: 8px;
}

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.required {
  color: #f87171;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
  outline: none;
}

.form-control:focus {
  border-color: #ca8a04;
}

.date-input-wrapper {
  position: relative;
  display: flex;
}

.calendar-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
}

.date-input-native {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  opacity: 0;
  cursor: pointer;
}

.btn-submit {
  width: 100%;
  padding: 12px;
  background: var(--pastel-yellow-dark);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  margin-top: 8px;
}

.btn-submit:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  border: none;
  cursor: pointer;
}

.btn-danger {
  background: #f87171;
  color: white;
}
.btn-secondary {
  background: #cbd5e1;
  color: var(--text-dark);
}
.icon-btn-sm {
  background: none;
  border: none;
  font-size: 1rem;
  color: #ca8a04;
  cursor: pointer;
}

/* Search Box */
.search-box {
  position: relative;
  margin-bottom: 10px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}
.search-input {
  padding-left: 36px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.spinner-box {
  background: #ffffff;
  padding: 24px 32px;
  border-radius: 16px;
  text-align: center;
}

.custom-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #fef08a;
  border-top-color: #ca8a04;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.d-none {
  display: none !important;
}

/* Offline Toast */
.offline-toast {
  position: fixed;
  bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(150px);
  background: #1e293b;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.8rem;
  transition: transform 0.3s;
  z-index: 1000;
}

.offline-toast.visible {
  transform: translateX(-50%) translateY(0);
}

.detail-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-top: 8px;
}

.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}
