/* ============================================================
   Indy Investment Garden — styles.css
   ธีม: สมุดวาดเขียน/ทำมือ น่ารัก สดใส 🌷
   ============================================================ */

:root {
  --cream:    #FFFBF3;
  --cream-2:  #FBEAD9;
  --ink:      #4A4038;
  --ink-soft: #8A7A68;
  --ink-mute: #A8927A;

  --pink:   #FF8FA3;
  --sky:    #7FC8E8;
  --violet: #B79CED;
  --yellow: #FFCB5B;
  --mint:   #5BC98E;
  --peach:  #FFB37A;

  --grow:   #2E9E68;  /* กำไร = เขียวมิ้นต์ */
  --grow-bg:#E6F7EE;
  --wilt:   #E8765C;  /* ขาดทุน = ส้มอ่อน */
  --wilt-bg:#FFEDE8;

  --card-border: #F0E4D2;
  --card-shadow: #F2E6D6;
  --dash:        #EFDDC8;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Mali', sans-serif;
  color: var(--ink);
  background: var(--cream);
  background-image: radial-gradient(rgba(186,156,122,.14) 1.4px, transparent 1.4px);
  background-size: 18px 18px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── App shell ── */
#app {
  max-width: 440px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(circle at 28% 8%, #FFF4E7, transparent 60%),
    var(--cream);
  background-image: radial-gradient(rgba(186,156,122,.14) 1.4px, transparent 1.4px);
  background-size: 18px 18px;
}

/* ── Header ── */
.indy-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 11px;
  background: rgba(255,251,243,.94);
  backdrop-filter: blur(8px);
  border-bottom: 2px dashed var(--dash);
}
.indy-brand { display: flex; align-items: center; gap: 9px; }
.indy-logo {
  width: 38px; height: 38px; border-radius: 13px;
  background: linear-gradient(140deg, #FF9DB0, #FFC36B);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 8px -2px rgba(242,109,133,.5);
}
.indy-brand-name { font-family: 'Itim'; font-size: 19px; line-height: 1; color: var(--ink); }
.indy-brand-sub  { font-size: 10px; color: var(--ink-mute); margin-top: 1px; }
.indy-head-actions { display: flex; align-items: center; gap: 8px; }
.indy-learn-badge {
  font-size: 11px; font-family: 'Itim';
  background: #FFF1D9; color: #C99A3E;
  border: 1.5px solid #F6E0AE; border-radius: 12px; padding: 4px 9px;
}
.indy-gear {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--dash); background: #fff; cursor: pointer;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
}

/* ── Main scroll ── */
.indy-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 110px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.indy-scroll::-webkit-scrollbar { width: 0; height: 0; }
.indy-scroll { scrollbar-width: none; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* ── Bottom nav ── */
.indy-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 440px;
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 8px 6px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: rgba(255,251,243,.96);
  backdrop-filter: blur(8px);
  border-top: 2px dashed var(--dash);
}
.indy-nav-btn {
  flex: 1; background: none; border: none; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.indy-nav-pill {
  position: relative; width: 48px; height: 30px;
  display: flex; align-items: center; justify-content: center;
}
.indy-nav-ico { position: relative; font-size: 19px; line-height: 1; z-index: 1; filter: grayscale(.3) opacity(.8); transition: .15s; }
.indy-nav-label { font-size: 9.5px; font-family: 'Itim'; color: var(--ink-soft); }
.indy-nav-btn.active .indy-nav-pill::before {
  content: ''; position: absolute; inset: 0;
  background: #FFE3E9; border-radius: 15px;
}
.indy-nav-btn.active .indy-nav-ico { filter: none; transform: scale(1.05); }
.indy-nav-fab { gap: 3px; }
.indy-fab {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(140deg, #FF9DB0, #FF8FA3);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px -3px rgba(242,109,133,.6);
  margin-top: -12px; border: 3px solid var(--cream);
  font-size: 24px; color: #fff; line-height: 1;
}

/* ── Sticker cards ── */
.card {
  background: #fff;
  border: 2.5px solid var(--card-border);
  border-radius: 22px;
  box-shadow: 0 5px 0 var(--card-shadow);
  padding: 16px;
}
.h-itim  { font-family: 'Itim'; color: var(--ink); }

/* ── Buttons ── */
.btn-plant {
  background: var(--pink); color: #fff; border: none; cursor: pointer;
  font-family: 'Itim'; font-size: 14px; padding: 9px 15px;
  border-radius: 16px; box-shadow: 0 4px 0 #EC6F88;
}
.btn-plant:active { transform: translateY(2px); box-shadow: 0 2px 0 #EC6F88; }

/* ── Modals / bottom sheet ── */
.indy-modal { position: fixed; inset: 0; z-index: 80; }
.indy-modal-bg { position: absolute; inset: 0; background: rgba(74,64,56,.42); }
.indy-sheet {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 440px;
  background: var(--cream);
  border-radius: 30px 30px 0 0;
  border-top: 3px solid #F0E0CC;
  padding: 14px 22px calc(env(safe-area-inset-bottom, 0px) + 26px);
  box-shadow: 0 -12px 32px rgba(120,80,60,.22);
  animation: pop .25s ease-out;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
}
.indy-sheet::-webkit-scrollbar { width: 0; }
.indy-sheet-grip { width: 44px; height: 5px; background: #E8D8C2; border-radius: 3px; margin: 0 auto 14px; }
.indy-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.indy-sheet-title { font-family: 'Itim'; font-size: 20px; color: var(--ink); }
.indy-sheet-desc  { font-size: 11.5px; color: var(--ink-mute); }
.indy-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--dash); background: #fff; cursor: pointer;
  font-size: 14px; color: var(--ink-soft); flex-shrink: 0;
}

/* ── Form fields ── */
.fld { margin-bottom: 12px; }
.fld-label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; font-family: 'Itim'; }
.fld-input, .fld-select, .fld-textarea {
  width: 100%; background: #fff; border: 2px solid var(--dash);
  border-radius: 15px; padding: 11px 14px;
  font-family: 'Mali'; font-size: 14px; color: var(--ink); outline: none;
}
.fld-input:focus, .fld-select:focus, .fld-textarea:focus { border-color: var(--pink); }
.fld-textarea { resize: none; line-height: 1.55; }
.fld-hint { font-size: 11px; color: var(--ink-mute); margin-top: 4px; }
.fld-row { display: flex; gap: 10px; }
.fld-row > .fld { flex: 1; }
.fld-section-title {
  font-family: 'Itim'; font-size: 13px; color: #C99A3E;
  margin: 4px 2px 8px; display: flex; align-items: center; gap: 5px;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; }

/* ── History modal ── */
.indy-hist-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.indy-hist-price-row { display: flex; align-items: baseline; gap: 10px; padding: 4px 0 10px; border-bottom: 1.5px dashed var(--card-border); }
.indy-hist-price { font-family: 'Itim'; font-size: 30px; color: var(--ink); }
.indy-hist-change { font-family: 'Itim'; font-size: 14px; }
.indy-hist-periods { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; }
.indy-hist-periods::-webkit-scrollbar { height: 0; }
.hist-period-btn {
  border: none; cursor: pointer; font-family: 'Mali'; font-weight: 600;
  font-size: 12px; padding: 7px 14px; border-radius: 14px;
  background: #F4EADB; color: var(--ink-soft); white-space: nowrap; flex-shrink: 0;
}
.hist-period-btn.is-active { background: var(--pink); color: #fff; }
.indy-hist-body { padding-bottom: 6px; }
.indy-hist-loading { display: flex; align-items: center; justify-content: center; height: 150px; color: var(--ink-mute); font-size: 13px; }
.indy-hist-chart { width: 100%; height: 160px; background: #FCF6EC; border-radius: 14px; }
.indy-hist-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ── Toast ── */
.indy-toast {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 50%; transform: translateX(-50%);
  z-index: 90; width: 100%; max-width: 320px; padding: 0 16px;
  pointer-events: none;
}
.indy-toast-inner {
  background: #fff; color: var(--ink); font-family: 'Itim'; font-size: 14px;
  border: 2.5px solid var(--card-border); border-radius: 18px;
  box-shadow: 0 5px 0 var(--card-shadow);
  padding: 12px 16px; text-align: center;
}

/* ── Animations ── */
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes sway   { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes pop    { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes drift  { 0%,100% { transform: translateX(0); } 50% { transform: translateX(7px); } }
.anim-floaty { animation: floaty 3.8s ease-in-out infinite; }
.anim-sway   { animation: sway 5s ease-in-out infinite; transform-origin: bottom center; }
.anim-drift  { animation: drift 6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .anim-floaty, .anim-sway, .anim-drift { animation: none; }
}
