/* Woof dashboard - warm, playful, rounded, light-first (DESIGN.md §8).
   Variable names kept from Oracle so this is a re-theme, not a rewrite.
   Dark mode: follows the system by default; the nav toggle sets
   data-theme="light|dark" on <html> (persisted in localStorage). */
:root {
  --bg: #faf4e8;            /* cream */
  --bg-2: #fffdf7;
  --panel: #fffcf6;
  --panel-solid: #fffcf6;
  --panel-2: #fff5e4;
  --border: #eadcc6;
  --text: #4a3728;          /* warm dark brown */
  --muted: #9c846c;
  --primary: #f59e0b;       /* warm amber */
  --primary-2: #e08a00;
  --accent: #e97c2e;
  --success: #62b356;
  --danger: #de5c47;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(122, 90, 44, .10);
  --transition: .2s ease;
  --nav-bg: rgba(250, 244, 232, .85);
  --btn-shadow: 0 3px 0 rgba(122, 90, 44, .18);
}

/* Dark: warm charcoal/brown, same amber primary. One definition, applied two
   ways so the toggle always beats the system preference. */
:root[data-theme="dark"] {
  --bg: #1c1611;
  --bg-2: #262019;
  --panel: #241d15;
  --panel-solid: #241d15;
  --panel-2: #2e251b;
  --border: #4a3d2c;
  --text: #f2e8d9;
  --muted: #b39c81;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --nav-bg: rgba(28, 22, 17, .85);
  --btn-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1611;
    --bg-2: #262019;
    --panel: #241d15;
    --panel-solid: #241d15;
    --panel-2: #2e251b;
    --border: #4a3d2c;
    --text: #f2e8d9;
    --muted: #b39c81;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --nav-bg: rgba(28, 22, 17, .85);
    --btn-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(800px 400px at 90% -10%, rgba(245,158,11,.10), transparent 60%),
    radial-gradient(600px 400px at 5% 105%, rgba(233,124,46,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .brand, .btn, button, .price, .pet-name {
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
}

a { color: var(--primary-2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

/* --- top nav --- */
.nav {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 30px; background: var(--nav-bg); backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
/* brand pushes everything else to the right; explicit order keeps the toggle
   last on desktop but lets mobile pull it up beside the brand (see media query). */
.nav .brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: 1.35rem; font-weight: 700; color: var(--text); }
.nav .brand img { width: 40px; height: 40px; }
.nav .links { display: flex; align-items: center; order: 2; gap: 20px; font-size: .92rem; color: var(--muted); flex-wrap: wrap; }
.nav .links .avatar { width: 30px; height: 30px; border-radius: 50%; vertical-align: middle; border: 2px solid var(--border); }
.nav .links > span { color: var(--text); font-weight: 600; }

.container { max-width: 1140px; margin: 0 auto; padding: 32px 28px; min-height: calc(100vh - 200px); }

h1 { font-size: 2rem; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 1.2rem; font-weight: 600; }
.muted { color: var(--muted); }
.accent { color: var(--primary); }

/* --- panels & cards --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.panel h2 { margin-top: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* --- forms --- */
input, select, button, textarea {
  font: inherit; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); padding: 9px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="file"] { border-radius: var(--radius-sm); padding: 5px 8px; }
input::placeholder { color: #c4ae92; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

/* Style the native file-picker "Browse" button to match the site's pill buttons. */
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  font: inherit; margin: 0 10px 0 0; padding: 7px 16px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-weight: 600; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover { border-color: var(--primary); }

form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Rename: keep the input and Rename button on one line (input fills the space). */
.rename-form { flex-wrap: nowrap; }
.rename-form input[type="text"] { flex: 1; min-width: 0; }

/* Photos: dropdown (left) and Upload (right) on the top row; the Browse box
   spans the full width beneath them. */
.photo-form { justify-content: space-between; }
.photo-form input[type="file"] { flex: 1 1 100%; min-width: 0; }

/* Card-style editor: live preview + Theme/Bars/Colours tabs. */
.style-preview {
  width: 100%; max-width: 520px; display: block; margin: 0 auto 20px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.style-tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
}
.style-tab {
  background: transparent; color: var(--muted); border: none; box-shadow: none;
  padding: 7px 18px; border-radius: 999px; font-size: .9rem;
}
.style-tab:hover { background: transparent; color: var(--text); transform: none; }
.style-tab.is-active { background: var(--primary); color: #fff; }
.style-pane { display: none; }
.style-pane.is-active { display: block; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { display: inline-flex; margin: 0; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg-2); color: var(--text);
  font-size: .9rem; cursor: pointer; transition: border-color var(--transition), background var(--transition);
}
.chip span:hover { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(245,158,11,.25); }
.colour-field { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.colour-field > label:first-child { margin: 0; color: var(--text); font-size: .95rem; min-width: 90px; text-align: right; }
input[type="color"] {
  width: 52px; height: 38px; padding: 3px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-2); cursor: pointer;
}
input[type="color"]:disabled { opacity: .4; cursor: not-allowed; }
.style-actions { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 20px; }

.apply-all { display: inline-flex; align-items: center; gap: 10px; margin: 0; color: var(--text); font-size: .95rem; cursor: pointer; }

/* Site-styled checkbox: rounded square, amber + white tick when checked. */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; margin: 0; padding: 0; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-2);
  cursor: pointer; position: relative;
  transition: border-color var(--transition), background var(--transition);
}
input[type="checkbox"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }

/* pill buttons - the stat-bar shape carried through the whole UI */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: 1px solid transparent;
  border-radius: 999px; padding: 10px 22px; font-weight: 600; font-size: .95rem;
  cursor: pointer; transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  box-shadow: var(--btn-shadow);
}
button:hover, .btn:hover { background: var(--primary-2); color: #fff; transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(1px); box-shadow: none; }
button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; box-shadow: none; transform: none; }
.btn.secondary { background: var(--bg-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--primary); color: var(--text); }
.btn.danger, button.danger { background: var(--danger); }
.btn.danger:hover, button.danger:hover { background: #c74a36; }

.back-btn { margin-bottom: 18px; }
.back-btn svg { width: 16px; height: 16px; }

/* Pet page header: back button inline with the pet's name. */
.pet-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.pet-header h1 { margin: 0; }
.pet-header .back-btn { margin-bottom: 0; }

/* Pet page: centre every panel's title + content for a consistent look.
   (The Photos space-between and Rename fill-width forms keep their layouts.) */
.pet-detail .panel { text-align: center; }

/* --- flashes & badges --- */
.flash { border-radius: var(--radius-sm); padding: 12px 18px; margin-bottom: 18px; font-weight: 600; }
.flash.success { background: rgba(98,179,86,.14); border: 1px solid rgba(98,179,86,.4); color: #3c7a33; }
.flash.error { background: rgba(222,92,71,.12); border: 1px solid rgba(222,92,71,.4); color: #a83a29; }

.badge {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px; padding: 2px 12px; font-size: .72rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .6px; vertical-align: middle;
}
.badge.premium { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.5); color: var(--primary-2); }

/* --- hero (landing) --- */
.hero { text-align: center; padding: 56px 0 30px; max-width: 720px; margin: 0 auto; }
.hero-logo { width: 110px; height: 110px; }
.hero h1 { font-size: 2.7rem; line-height: 1.15; margin: 18px 0 14px; }
.hero p { font-size: 1.08rem; color: var(--muted); }
.hero-actions { display: flex; gap: 14px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

.feature-row { margin-top: 26px; }
.feature { text-align: center; }
.feature-icon { width: 46px; height: 46px; color: var(--primary); margin-bottom: 8px; }

/* --- pets grid (dashboard) - the signature: live rendered cards --- */
.pet-grid { margin-bottom: 22px; }
.pet-card {
  display: block; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--text);
  box-shadow: var(--shadow); transition: transform var(--transition), border-color var(--transition);
}
.pet-card:hover { transform: translateY(-4px) rotate(-.4deg); border-color: var(--primary); color: var(--text); }
.pet-card img { width: 100%; display: block; }
.pet-card-meta { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px 20px 16px; }
.pet-name { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.pet-card.dormant img { filter: grayscale(.6) opacity(.75); }

.pet-hero { padding: 14px; }
.pet-card-img { width: 100%; border-radius: var(--radius-sm); display: block; }

/* Care actions live under the card image in the stats panel; even button grid. */
.care-panel { text-align: center; }
.action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.action-row form { display: block; }
.action-btn { width: 100%; min-width: 0; }
.pet-hero .action-row { margin-top: 16px; }
.action-note { margin: 10px 0 0; font-size: .85rem; }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .btn { margin-top: 12px; }
code { background: var(--panel-2); border-radius: 6px; padding: 2px 7px; font-size: .9em; }

.danger-zone { border-color: rgba(222,92,71,.35); }

/* --- referral card --- */
.referral-link {
  width: 100%; max-width: 100%; border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
}
.referral-stats {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; font-size: .9rem;
}
.referral-progress { margin-top: 16px; }
.referral-progress-track {
  height: 12px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
}
.referral-progress-fill {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width var(--transition);
}
.referral-progress-label { display: block; margin-top: 6px; font-size: .85rem; color: var(--muted); }

/* --- premium plans --- */
.plan {
  background: var(--bg-2); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 22px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.plan:hover, .plan.selected { border-color: var(--primary); transform: translateY(-2px); }
.plan .name { font-size: 1.1rem; font-weight: 700; }
.plan .price { font-size: 1.9rem; font-weight: 700; color: var(--primary-2); }
.plan .price small { font-size: .85rem; color: var(--muted); font-weight: 600; }
.plan .cap-note { font-weight: 700; margin: 4px 0 8px; }
.plan .or-subscribe { margin: 12px 0 4px; font-size: .85rem; }
.pp-slot { min-height: 8px; }
.status-line { margin-top: 14px; }

.donate-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.legal h2 { margin-top: 22px; }
.legal h2:first-child { margin-top: 0; }

/* --- language switcher / footer --- */
.theme-toggle {
  order: 3;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--border);
  padding: 6px 14px; font-size: .85rem; box-shadow: none;
}
.theme-toggle:hover { background: var(--bg-2); color: var(--text); border-color: var(--primary); transform: none; }
.theme-icon { width: 18px; height: 18px; display: none; }  /* icon only on mobile; text label on desktop */
/* Compact filled/outlined buttons used in the nav (Invite, Log in). */
.nav-btn { padding: 8px 16px; font-size: .9rem; }
.mobile-only { display: none; }  /* shown only at <=640px (see media query) */

/* Avatar dropdown (account menu) */
.user-menu { position: relative; display: inline-flex; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 8px 3px 3px; box-shadow: none;
}
.avatar-btn:hover { background: var(--bg-2); border-color: var(--primary); color: var(--text); transform: none; }
.avatar-btn .chevron { width: 14px; height: 14px; transition: transform var(--transition); }
.avatar-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: .9rem;
}
.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; min-width: 180px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 8px; z-index: 60;
}
.user-dropdown-name {
  font-weight: 700; color: var(--text); padding: 6px 10px 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.user-dropdown a { padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: .92rem; }
.user-dropdown a:hover { background: var(--panel-2); color: var(--text); }

.lang-form { display: inline-flex; }
.lang-switch { padding: 6px 12px; font-size: .85rem; }

.site-footer {
  display: flex; gap: 22px; justify-content: center; align-items: center;
  padding: 26px; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* --- confirm modal --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 28, 18, .5); backdrop-filter: blur(3px);
}
.modal {
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 26px; max-width: 420px; width: 100%; text-align: center;
  animation: modal-pop .18s ease;
}
.modal-title { margin: 0 0 10px; font-size: 1.3rem; }
.modal-body { margin: 0 0 22px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn { min-width: 120px; }
@keyframes modal-pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 640px) {
  /* Declutter the stacked mobile nav (Donate still lives in the footer). */
  .hide-on-mobile { display: none; }
  /* Row 1: brand (left) + a compact lightbulb toggle (top-right).
     Row 2: the action buttons (Invite, Log in), right-aligned (lower-right). */
  .mobile-only { display: inline; }
  /* Single line (like desktop): logo left; Invite, Log in and the lightbulb
     toggle grouped on the right. Login label shortens to "Log in" to fit. */
  .nav { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .nav .links { gap: 10px; font-size: .9rem; }
  .nav .theme-toggle { padding: 8px; }                   /* compact icon button */
  .nav .theme-toggle .theme-icon { display: block; }
  .nav .theme-toggle .theme-label { display: none; }
  .container { padding: 22px 16px; }
  .hero h1 { font-size: 2rem; }
  /* Centre the "Delete your data" panel (title, text, button) on mobile only. */
  .danger-zone { text-align: center; }
  /* Centre the referral card and its stats on mobile only. */
  .referral-card { text-align: center; }
  .referral-card .referral-stats { justify-content: center; }
  /* Two action buttons per row on mobile. */
  .action-row { grid-template-columns: repeat(2, 1fr); }
}
