/* ============================================================
   pif — Pet QR System · custom CSS (Bootstrap 5.3 overrides)
   warm cream/peach palette · matches React prototype
   ============================================================ */

:root {
  --pif-bg:        #ece4d4;
  --pif-bg-2:      #e3d9c5;
  --pif-phone:     #faf6ee;
  --pif-card:      #ffffff;
  --pif-ink:       #1f1a14;
  --pif-ink-2:     #4a3f33;
  --pif-mute:      #8a7a66;
  --pif-line:      #ece3d3;
  --pif-line-2:    #f5eedf;
  --pif-accent:    #d97a4e;
  --pif-accent-dk: #a3522d;
  --pif-accent-sf: #f6dac8;
  --pif-indigo:    #6b6db0;
  --pif-indigo-sf: #dcd6ee;
  --pif-sage:      #7c9b6f;
  --pif-sage-sf:   #d6e1cf;
  --pif-butter-sf: #f1e3b5;
  --pif-rose-sf:   #f3d6cd;
  --pif-ok:        #5f8a5d;
  --pif-warn:      #c98a2a;
  --pif-err:       #a3522d;

  /* Bootstrap overrides */
  --bs-body-bg: var(--pif-bg);
  --bs-body-color: var(--pif-ink);
  --bs-body-font-family: 'Kanit', system-ui, -apple-system, sans-serif;
  --bs-border-color: var(--pif-line);
  --bs-link-color: var(--pif-accent);
  --bs-link-hover-color: var(--pif-accent-dk);
  --bs-primary: #d97a4e;
  --bs-primary-rgb: 217, 122, 78;
  --bs-secondary: #6b6db0;
}

body {
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  background: var(--pif-bg);
  color: var(--pif-ink);
  min-height: 100vh;
  font-family: 'Kanit', system-ui, sans-serif;
}

/* Force Kanit on EVERY element — Thai + English alike.
   Buttons / inputs / etc. don't inherit body font by default. */
*, *::before, *::after,
button, input, select, textarea, optgroup {
  font-family: 'Kanit', system-ui, sans-serif;
}

.mono {
  font-family: 'Kanit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ─── Layout shell ────────────────────────────────────────── */
.pif-shell { display: flex; min-height: 100vh; }
.pif-side {
  width: 280px; min-height: 100vh; flex-shrink: 0;
  background: linear-gradient(180deg, #1f1a14 0%, #2a221b 100%);
  color: #e9e0cf; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.pif-main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.pif-main-narrow { max-width: 1080px; margin: 0 auto; }

@media (max-width: 991.98px) {
  .pif-shell { flex-direction: column; }
  .pif-side { position: relative; width: 100%; height: auto; min-height: 0; }
  .pif-side:not(.show-mobile) { display: none; }
  .pif-main { padding: 20px 16px 48px; }
}

/* ─── Sidebar ────────────────────────────────────────────── */
.pif-brand { display: flex; align-items: center; gap: 10px; }
.pif-brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: #fcb558; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
}
.pif-brand-name { font-family: 'Kanit'; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.pif-brand-sub { font-size: 11px; color: #a99a82; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }

.pif-side h4 {
  font-family: 'Kanit'; font-weight: 600; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase;
  color: #a99a82; margin: 0 0 10px;
}

.pif-nav { display: flex; flex-direction: column; gap: 4px; }
.pif-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #d9cfb9; text-decoration: none; font-size: 14px;
  transition: background .15s, color .15s;
}
.pif-nav a:hover { background: rgba(255,255,255,.04); color: #fff; }
.pif-nav a.active { background: rgba(217,122,78,.18); color: #fff; font-weight: 600; }
.pif-nav a.active .pif-nav-ico { color: var(--pif-accent); }
.pif-nav-ico { color: #8a7e68; font-size: 18px; width: 20px; text-align: center; }

.pif-side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.06); }
.pif-side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  font-size: 13px; color: #d9cfb9;
}
.pif-side-user .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--pif-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Kanit'; font-weight: 700; font-size: 13px;
}

/* ─── Page header ────────────────────────────────────────── */
.pif-page-head { margin-bottom: 22px; }
.pif-crumb { font-family: 'Kanit'; font-size: 11px; color: var(--pif-mute); letter-spacing: .06em; text-transform: uppercase; }
.pif-page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.pif-page-desc { font-size: 14px; color: var(--pif-ink-2); margin-top: 4px; max-width: 640px; line-height: 1.5; }

/* ─── Cards ──────────────────────────────────────────────── */
.pif-card {
  background: #fff; border-radius: 18px; padding: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); border: 0;
}
.pif-card-flat {
  background: #fff; border-radius: 14px; padding: 14px;
  border: 1px solid var(--pif-line);
}
.pif-card-dark {
  background: linear-gradient(135deg, #1f1a14 0%, #3a2e22 100%);
  color: #fff; border-radius: 18px; padding: 18px;
  position: relative; overflow: hidden;
}
.pif-card-dark::after {
  content: ''; position: absolute; right: -30px; bottom: -30px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, var(--pif-accent) 0%, transparent 70%);
  opacity: .35; pointer-events: none;
}

.pif-section-title {
  font-family: 'Kanit'; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--pif-mute);
  font-weight: 600; margin: 22px 0 10px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-pif {
  background: var(--pif-ink); color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-weight: 600; font-size: 14px; border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 3px 10px rgba(31,26,20,.15);
  transition: transform .12s, box-shadow .12s;
}
.btn-pif:hover { color: #fff; background: #2a221b; transform: translateY(-1px); box-shadow: 0 5px 14px rgba(31,26,20,.2); }
.btn-pif:active { transform: translateY(0); }

.btn-pif-accent { background: var(--pif-accent); box-shadow: 0 3px 10px rgba(217,122,78,.25); }
.btn-pif-accent:hover { background: var(--pif-accent-dk); box-shadow: 0 5px 14px rgba(217,122,78,.3); }
.btn-pif-indigo { background: var(--pif-indigo); box-shadow: 0 3px 10px rgba(107,109,176,.25); }
.btn-pif-indigo:hover { background: #555793; }

.btn-pif-outline {
  background: #fff; color: var(--pif-ink);
  border: 1px solid var(--pif-line); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-pif-outline:hover { color: var(--pif-ink); background: var(--pif-phone); border-color: var(--pif-mute); }

/* ─── Forms ──────────────────────────────────────────────── */
.pif-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.pif-field label { font-size: 12px; font-weight: 600; color: var(--pif-ink-2); font-family: 'Kanit'; }
.pif-field .form-control, .pif-field .form-select {
  background: #fff; border: 1px solid var(--pif-line); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; color: var(--pif-ink);
}
.pif-field .form-control:focus, .pif-field .form-select:focus {
  border-color: var(--pif-accent); box-shadow: 0 0 0 3px rgba(217,122,78,.12);
}
.pif-field .form-control::placeholder { color: #b9ab92; }

/* ─── Chips / pills ──────────────────────────────────────── */
.pif-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: #fff; border: 1px solid var(--pif-line);
  color: var(--pif-ink-2); font-family: 'Kanit';
  text-decoration: none;
}
.pif-chip:hover { color: var(--pif-ink); }
.pif-chip.on { background: var(--pif-ink); color: #fff; border-color: var(--pif-ink); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  font-family: 'Kanit';
}
.pill-ok       { background: var(--pif-sage-sf);   color: #4f7245; }
.pill-warn     { background: #fdf2d9;              color: #9a7218; }
.pill-err      { background: #fbe5e0;              color: var(--pif-err); }
.pill-info     { background: var(--pif-indigo-sf); color: var(--pif-indigo); }
.pill-mute     { background: var(--pif-line);      color: var(--pif-mute); }
.pill-accent   { background: var(--pif-accent-sf); color: var(--pif-accent-dk); }

.pill-active, .pill-paid     { background: var(--pif-sage-sf);   color: #4f7245; }
.pill-pending, .pill-trialing{ background: #fdf2d9;              color: #9a7218; }
.pill-overdue, .pill-rejected { background: #fbe5e0;             color: var(--pif-err); }
.pill-paused, .pill-inactive { background: var(--pif-line);      color: var(--pif-mute); }

/* ─── Pet avatar / species color ─────────────────────────── */
.pif-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.pif-avatar-sm { width: 40px; height: 40px; font-size: 20px; }
.pif-avatar-lg { width: 88px; height: 88px; font-size: 42px; }
.pif-avatar-xl { width: 160px; height: 160px; font-size: 80px; }

/* real-photo avatars */
.pet-avatar { overflow: hidden; }
.pet-avatar > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pet-avatar-empty { color: var(--pif-accent-dk); font-size: 42%; }
.pet-avatar-empty.pif-avatar-sm { font-size: 18px; }
.pet-avatar-empty.pif-avatar-xl { font-size: 60px; }

.tone-peach  { background: var(--pif-accent-sf); }
.tone-blue   { background: #cfe0ee; }
.tone-sage   { background: var(--pif-sage-sf); }
.tone-lilac  { background: var(--pif-indigo-sf); }
.tone-butter { background: var(--pif-butter-sf); }
.tone-rose   { background: var(--pif-rose-sf); }

/* ─── List row ───────────────────────────────────────────── */
.pif-list { background: #fff; border-radius: 16px; overflow: hidden; }
.pif-list > .pif-list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--pif-line-2);
  text-decoration: none; color: var(--pif-ink);
}
.pif-list > .pif-list-row:first-child { border-top: 0; }
.pif-list > a.pif-list-row:hover { background: var(--pif-phone); }
.pif-list-row .row-title { font-weight: 600; font-size: 14px; }
.pif-list-row .row-sub { font-size: 12px; color: var(--pif-mute); margin-top: 2px; }

/* ─── Stat tile ──────────────────────────────────────────── */
.pif-stat {
  background: #fff; border-radius: 14px; padding: 14px 16px;
  text-align: left;
}
.pif-stat .k { font-size: 11px; color: var(--pif-mute); font-family: 'Kanit'; }
.pif-stat .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.pif-stat-bar { width: 28px; height: 4px; background: var(--pif-accent); border-radius: 2px; margin-bottom: 8px; }

/* ─── Alert ──────────────────────────────────────────────── */
.alert-pif {
  border-radius: 12px; padding: 12px 16px;
  border: 1px solid transparent; font-size: 14px;
}
.alert-pif-ok  { background: var(--pif-sage-sf);   color: #3d5a35; border-color: #cfdcc4; }
.alert-pif-err { background: #fbe5e0;              color: var(--pif-err); border-color: #ecccc1; }
.alert-pif-warn{ background: #fff7e8;              color: #6f5219; border-color: #f3e2bf; }

/* ─── Public scan page ───────────────────────────────────── */
.pif-public-wrap {
  max-width: 480px; margin: 0 auto;
  background: var(--pif-phone); min-height: 100vh;
  box-shadow: 0 0 60px rgba(0,0,0,.06);
}
.pif-public-hero {
  background: linear-gradient(180deg, var(--pif-accent-sf) 0%, var(--pif-phone) 100%);
  padding: 24px 24px 28px; text-align: center;
}
.pif-public-content { padding: 18px 20px 32px; display: flex; flex-direction: column; gap: 12px; }

/* ─── Auth pages ─────────────────────────────────────────── */
.pif-auth-wrap {
  max-width: 460px; margin: 0 auto; padding: 40px 24px;
  min-height: 100vh; display: flex; flex-direction: column;
}
.pif-auth-hero {
  background: linear-gradient(180deg, var(--pif-accent-sf) 0%, var(--pif-phone) 100%);
  padding: 40px 24px 24px;
  border-radius: 24px;
  margin-bottom: 18px;
}
.pif-auth-mark {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--pif-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  box-shadow: 0 10px 22px rgba(217,122,78,.32);
  margin-bottom: 18px;
}
.pif-auth-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.pif-auth-desc { font-size: 14px; color: var(--pif-ink-2); margin-top: 8px; line-height: 1.5; }
.pif-auth-mark.indigo { background: var(--pif-indigo); box-shadow: 0 10px 22px rgba(107,109,176,.28); }
.pif-auth-mark.dark   { background: #1f1a14; color: var(--pif-accent); box-shadow: 0 10px 22px rgba(0,0,0,.25); }
.pif-auth-hero.indigo { background: linear-gradient(180deg, var(--pif-indigo-sf) 0%, var(--pif-phone) 100%); }
.pif-auth-hero.dark   { background: #1f1a14; color: #fff; }

/* ─── QR detail page ─────────────────────────────────────── */
.pif-qr-frame {
  background: #fff; border-radius: 18px; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.pif-qr-image { width: 240px; max-width: 100%; height: auto; }

/* ─── Tables (admin) ─────────────────────────────────────── */
.pif-table {
  width: 100%; background: #fff; border-radius: 14px; overflow: hidden;
  border-collapse: separate; border-spacing: 0;
}
.pif-table thead th {
  font-family: 'Kanit'; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--pif-mute);
  padding: 12px 14px; text-align: left; font-weight: 600;
  background: var(--pif-phone);
}
.pif-table tbody td {
  padding: 14px 14px; font-size: 13px;
  border-top: 1px solid var(--pif-line-2);
}
.pif-table tbody tr:first-child td { border-top: 0; }
.pif-table tbody tr:hover { background: var(--pif-phone); }

/* ─── Timeline (history) ─────────────────────────────────── */
.pif-timeline { position: relative; padding-left: 22px; }
.pif-timeline::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--pif-line);
}
.pif-timeline-item { position: relative; margin-bottom: 14px; }
.pif-timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 16px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--pif-accent);
  box-sizing: border-box;
}
.pif-timeline-item.vaccine::before { border-color: var(--pif-indigo); }
.pif-timeline-item.checkup::before { border-color: var(--pif-sage); }

/* ─── Map placeholder ────────────────────────────────────── */
.pif-map { height: 200px; border-radius: 14px; background: #e8e3d6; position: relative; overflow: hidden; }
.pif-map .pin {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -100%); font-size: 36px; color: var(--pif-accent);
}
.pif-map .ring {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(217,122,78,.18); border: 2px solid rgba(217,122,78,.35);
}

/* ─── Scan camera (mock) ─────────────────────────────────── */
.pif-scanbox {
  position: relative; width: 260px; height: 260px; margin: 24px auto;
}
.pif-scanbox::before {
  content: ''; position: absolute; inset: 0;
  border: 1px solid rgba(255,255,255,.1); border-radius: 24px;
}
.pif-scancorner { position: absolute; width: 36px; height: 36px; }
.pif-scancorner.tl { top: -2px; left: -2px; border-top: 3px solid var(--pif-accent); border-left: 3px solid var(--pif-accent); border-radius: 12px 0 0 0; }
.pif-scancorner.tr { top: -2px; right: -2px; border-top: 3px solid var(--pif-accent); border-right: 3px solid var(--pif-accent); border-radius: 0 12px 0 0; }
.pif-scancorner.bl { bottom: -2px; left: -2px; border-bottom: 3px solid var(--pif-accent); border-left: 3px solid var(--pif-accent); border-radius: 0 0 0 12px; }
.pif-scancorner.br { bottom: -2px; right: -2px; border-bottom: 3px solid var(--pif-accent); border-right: 3px solid var(--pif-accent); border-radius: 0 0 12px 0; }

/* ─── Bar chart (revenue) ────────────────────────────────── */
.pif-bars { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.pif-bars > div { flex: 1; background: linear-gradient(180deg, var(--pif-accent), var(--pif-accent-dk)); border-radius: 4px 4px 0 0; min-height: 4px; }
.pif-bars > div.muted { background: linear-gradient(180deg, var(--pif-mute), #6b5b46); opacity: .5; }

.stacked-bar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
}

/* ─── QR card thumbnail (in pet list / dashboard) ───────── */
.pif-mini-qr {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--pif-phone);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--pif-ink); font-size: 16px;
}

/* ─── Pet profile card (PETER-style) ─────────────────────── */
.pet-profile-card {
  max-width: 360px; width: 100%;
  background: #fff; border-radius: 28px; overflow: hidden;
  box-shadow: 0 16px 48px rgba(31,26,20,.12);
}
.pet-profile-photo {
  aspect-ratio: 3 / 3.4; background: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pet-profile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pet-profile-noimg { font-size: 120px; line-height: 1; }
.pet-profile-body {
  background: linear-gradient(180deg, #f4dac9 0%, #efccb7 100%);
  padding: 20px 22px 22px;
}
.pet-profile-name {
  font-size: 19px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--pif-ink);
}
.pet-profile-heart { color: #c0392b; font-size: 19px; }
.pet-profile-stats {
  display: flex; background: rgba(255,255,255,.35);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.pet-profile-stats .cell {
  flex: 1; padding: 10px 8px; text-align: left;
  border-left: 1px solid rgba(255,255,255,.7);
}
.pet-profile-stats .cell:first-child { border-left: 0; }
.pet-profile-stats .lbl {
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--pif-ink);
}
.pet-profile-stats .val { font-size: 11px; color: var(--pif-ink-2); margin-top: 3px; line-height: 1.3; }
.pet-profile-about .ttl {
  font-size: 14px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; margin-bottom: 6px;
}
.pet-profile-about p { font-size: 13px; color: var(--pif-ink-2); line-height: 1.5; margin: 0 0 16px; }
.pet-profile-cta {
  display: block; width: 100%; text-align: center;
  padding: 14px; border-radius: 14px;
  background: rgba(255,255,255,.55); color: var(--pif-ink);
  font-weight: 700; font-size: 15px; text-decoration: none;
  border: 0; transition: background .15s;
}
.pet-profile-cta:hover { background: rgba(255,255,255,.85); color: var(--pif-ink); }
.pet-profile-cta-dark { background: var(--pif-ink); color: #fff; }
.pet-profile-cta-dark:hover { background: #2a221b; color: #fff; }

/* ─── Photo upload dropzone ──────────────────────────────── */
.pif-dropzone {
  position: relative; border: 2px dashed #d4c8b1; border-radius: 18px;
  background: var(--pif-phone); cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; transition: border-color .15s, background .15s;
}
.pif-dropzone:hover { border-color: var(--pif-accent); background: #fbf3ea; }
.pif-dropzone.has-image { border-style: solid; border-color: var(--pif-line); }
.pif-dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pif-dropzone .dz-placeholder { text-align: center; color: var(--pif-mute); padding: 24px; }
.pif-dropzone .dz-placeholder i { font-size: 36px; display: block; margin-bottom: 8px; color: var(--pif-accent); }
.pif-dropzone .dz-preview { width: 100%; height: 100%; object-fit: cover; display: none; }
.pif-dropzone.has-image .dz-preview { display: block; }
.pif-dropzone.has-image .dz-placeholder { display: none; }
.pif-dropzone .dz-change {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(31,26,20,.78); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  display: none; align-items: center; gap: 6px;
}
.pif-dropzone.has-image .dz-change { display: inline-flex; }

/* ─── Tiny helpers ──────────────────────────────────────── */
.text-mute-pif { color: var(--pif-mute) !important; }
.text-accent { color: var(--pif-accent) !important; }
.bg-phone { background: var(--pif-phone) !important; }
.divider-pif { height: 1px; background: var(--pif-line); margin: 16px 0; }

@media print {
  .pif-side, .pif-page-head .btn, .btn { display: none !important; }
  body { background: #fff; }
}