/* ============================================================
   กำลังใจ Inspired by Love — Design Tokens
   Palette (brief-mandated core + derived support colors):
     --brand-orange   #f47b30   (primary / warmth / กำลังใจ)
     --brand-white    #ffffff
     --brand-bg       #ededed
     --ink            #2b2420   (warm charcoal, not pure black)
     --ink-soft       #8a7f77   (secondary text)
     --line           #e2ddd8   (hairline borders on white cards)
     --tint           #fff3ec   (pale orange tint for highlight blocks)
     --good           #4caf7d   (success / confirmed states)
   Type:
     Display  — 'Kanit'    (Thai+Latin geometric, used for headings only)
     Body     — 'Sarabun'  (Thai+Latin text face, legible at small sizes)
   Signature element: the "heart-meter" — กำลังใจ balance rendered as a
   glowing heart fill rather than a plain number, since the product's
   whole currency is encouragement.
   ============================================================ */

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

:root {
    --brand-orange: #f47b30;
    --brand-orange-dark: #d9631e;
    --brand-white: #ffffff;
    --brand-bg: #ededed;
    --ink: #2b2420;
    --ink-soft: #8a7f77;
    --line: #e2ddd8;
    --tint: #fff3ec;
    --good: #4caf7d;
    --danger: #d9534f;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 2px 10px rgba(43, 36, 32, 0.06);
    --shadow-pop: 0 10px 30px rgba(43, 36, 32, 0.18);
}

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

html, body {
    background: var(--brand-bg);
    color: var(--ink);
    font-family: 'Sarabun', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body {
    padding-top: 62px;
    padding-bottom: 76px;
    min-height: 100vh;
}

h1, h2, h3, h4, .display {
    font-family: 'Kanit', sans-serif;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.01em;
}

a { color: inherit; }

.container { max-width: 480px; margin: 0 auto; padding: 14px 16px 6px; }

/* ---------- Top nav ---------- */
.top-nav {
    position: fixed; top: 0; left: 0; right: 0; height: 62px;
    background: var(--brand-orange);
    background-image: linear-gradient(135deg, var(--brand-orange) 0%, var(--brand-orange-dark) 100%);
    color: var(--brand-white);
    display: flex; align-items: center; justify-content: flex-start;
    gap: 12px; padding: 0 14px;
    box-shadow: 0 2px 8px rgba(217, 99, 30, 0.25);
    z-index: 1000;
}
.top-nav .logo-mark { font-size: 20px; line-height: 1; }
.top-nav .logo-text {
    font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 18px;
}
.top-nav .logo-sub { font-size: 10px; opacity: 0.85; font-weight: 400; display: block; }

/* Left-aligned brand layout for larger logo + title */
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand .brand-logo img {
    height: 36px; width: auto; display: block; object-fit: contain;
}
.topbar-brand .brand-text { line-height: 1; display: flex; flex-direction: column; }
.topbar-brand .brand-text span { font-size: 13px; font-weight: 600; }
.topbar-brand .brand-text strong { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 14px; }

/* Responsive logo sizing */
@media (max-width: 359px) {
    .topbar-brand .brand-logo img { height: 30px; }
}
@media (min-width: 360px) and (max-width: 539px) {
    .topbar-brand .brand-logo img { height: 34px; }
}
@media (min-width: 540px) and (max-width: 899px) {
    .topbar-brand .brand-logo img { height: 44px; }
}
@media (min-width: 900px) {
    .topbar-brand .brand-logo img { height: 52px; }
}

/* ---------- Bottom nav (5 tabs) ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 68px;
    background: var(--brand-white);
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(43,36,32,0.05);
}
.nav-item {
    text-decoration: none; color: var(--ink-soft); font-size: 11px;
    text-align: center; flex: 1; padding: 6px 0;
    transition: color .15s ease;
}
.nav-item .icon { font-size: 20px; display: block; margin-bottom: 2px; }
.nav-item .icon.bi { font-size: 20px; }
.nav-item.active { color: var(--brand-orange); font-weight: 600; }

.bi { vertical-align: middle; }
.inline-icon, .section-icon, .brand-icon, .logo-mark .bi { display: inline-flex; align-items: center; justify-content: center; }
.inline-icon { color: var(--brand-orange); margin-right: 6px; }
.section-icon { color: var(--brand-orange); font-size: 1.05em; margin-right: 6px; }
.logo-mark .bi { font-size: 20px; }
.empty-state .icon.bi { font-size: 34px; margin-bottom: 8px; }

/* ---------- Cards ---------- */
.card {
    background: var(--brand-white);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
}
.card-flat { border-radius: var(--radius-md); }
.card-tint { background: var(--tint); border-color: #ffe1cc; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; border: none; border-radius: var(--radius-sm);
    padding: 11px 16px; font-family: 'Sarabun', sans-serif; font-weight: 600;
    font-size: 14px; cursor: pointer; text-decoration: none;
    transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-orange { background: var(--brand-orange); color: var(--brand-white); }
.btn-orange:hover { opacity: 0.92; }
.btn-outline { background: transparent; color: var(--brand-orange); border: 1.5px solid var(--brand-orange); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-ghost { background: var(--brand-bg); color: var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 12px; border: 1.5px solid var(--line);
    border-radius: var(--radius-sm); font-family: 'Sarabun', sans-serif;
    font-size: 14px; background: var(--brand-bg); color: var(--ink);
    outline: none; transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-orange); background: var(--brand-white); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
.error-text { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal {
    display: none; position: fixed; z-index: 3000; inset: 0;
    background: rgba(43,36,32,0.55); backdrop-filter: blur(2px);
    align-items: flex-end; justify-content: center;
}
.modal.open { display: flex; }
.modal-content {
    background: var(--brand-white); width: 100%; max-width: 480px;
    border-radius: 22px 22px 0 0; padding: 22px 20px 28px;
    max-height: 88vh; overflow-y: auto;
    box-shadow: var(--shadow-pop);
    animation: slideUp .22s ease;
}
@media (min-width: 540px) {
    .modal { align-items: center; }
    .modal-content { border-radius: var(--radius-lg); }
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { cursor: pointer; font-size: 22px; color: var(--ink-soft); line-height: 1; background: none; border: none; }
.tab-switch { display: flex; background: var(--brand-bg); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.tab-switch button {
    flex: 1; border: none; background: none; padding: 9px 0; border-radius: 999px;
    font-family: 'Sarabun', sans-serif; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); cursor: pointer;
}
.tab-switch button.active { background: var(--brand-white); color: var(--brand-orange); box-shadow: var(--shadow-card); }

/* ---------- Heart meter (signature element) ---------- */
.heart-meter { display: flex; align-items: center; gap: 14px; }
.heart-meter svg { flex-shrink: 0; }
.heart-meter .hm-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.heart-meter .hm-value { font-family: 'Kanit', sans-serif; font-size: 26px; color: var(--brand-orange); font-weight: 700; line-height: 1.1; }
.heart-meter .hm-value small { font-family: 'Sarabun', sans-serif; font-size: 13px; font-weight: 500; color: var(--ink-soft); }

/* ---------- Misc ---------- */
.avatar {
    width: 66px; height: 66px; border-radius: 50%; background: var(--brand-orange);
    color: var(--brand-white); display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-family: 'Kanit', sans-serif; font-weight: 600;
    object-fit: cover; border: 3px solid var(--tint);
}
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-orange { background: var(--tint); color: var(--brand-orange-dark); }
.badge-good { background: #e8f7ef; color: var(--good); }
.badge-muted { background: var(--brand-bg); color: var(--ink-soft); }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.text-soft { color: var(--ink-soft); }
.text-sm { font-size: 12.5px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.section-title { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; margin-bottom: 10px; }
.empty-state { text-align: center; padding: 30px 10px; color: var(--ink-soft); }
.empty-state .icon { font-size: 34px; margin-bottom: 8px; }
.toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: var(--brand-white); padding: 10px 18px;
    border-radius: 999px; font-size: 13px; z-index: 4000; opacity: 0;
    transition: opacity .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; }
.star-rate { display: flex; gap: 4px; font-size: 26px; cursor: pointer; }
.star-rate span { color: var(--line); transition: color .1s ease; }
.star-rate span.active { color: var(--brand-orange); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
    flex-shrink: 0; padding: 7px 14px; border-radius: 999px; font-size: 12.5px;
    font-weight: 600; background: var(--brand-white); border: 1.5px solid var(--line); color: var(--ink-soft);
    cursor: pointer;
}
.chip.active { background: var(--brand-orange); border-color: var(--brand-orange); color: var(--brand-white); }

/* ---------- Ad slider ---------- */
.ad-slider { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 0; }
.ad-slide { display: none; }
.ad-slide.active { display: block; }
.ad-slider img { display: block; width: 100%; height: 300px; object-fit: cover; }
.ad-controls { position: absolute; left: 8px; right: 8px; top: 50%; transform: translateY(-50%); display:flex; justify-content:space-between; pointer-events: none; }
.ad-controls button { pointer-events: auto; background: rgba(255,255,255,0.92); border: none; width: 40px; height: 40px; border-radius: 999px; font-size: 20px; color: var(--ink); box-shadow: var(--shadow-card); cursor: pointer; }
.ad-controls button:hover { opacity: 0.95; }

@media (max-width: 420px) {
    .ad-slider img { height: 200px; }
}
