/* ─────────────────────────────────────────────────────────────
   BARKR Components
   Buttons · Inputs · Cards · Nav · Badges · Avatar · Toast
   Requires: variables.css, reset.css, global.css
───────────────────────────────────────────────────────────── */


/* ════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-body);
  font-size: .93rem;
  font-weight: 600;
  line-height: 1;
  padding: 14px 24px;
  border-radius: var(--r-full);
  border: none;
  cursor: pointer;
  transition:
    background var(--t-base) var(--ease-out),
    box-shadow  var(--t-base) var(--ease-out),
    transform   var(--t-base) var(--ease-bounce);
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.97); }
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary */
.btn-primary {
  background: var(--c-primary);
  color: var(--c-white);
  box-shadow: 0 4px 16px var(--c-primary-ring);
}
.btn-primary:hover:not(:disabled) {
  background: var(--c-primary-lt);
  box-shadow: 0 6px 24px var(--c-primary-ring);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--c-primary);
  color: var(--c-primary);
  transform: translateY(-1px);
}

/* Subtle (light bg, no border) */
.btn-subtle {
  background: var(--c-primary-bg);
  color: var(--c-primary-dk);
}
.btn-subtle:hover:not(:disabled) {
  background: rgba(242, 107, 56, 0.15);
}

/* Danger */
.btn-danger {
  background: var(--c-error-bg);
  color: var(--c-error);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(217, 79, 79, 0.15);
}

/* Sizes */
.btn-sm  { font-size: .8rem;  padding: 9px 16px; }
.btn-lg  { font-size: 1rem;   padding: 16px 32px; }
.btn-xl  { font-size: 1.05rem; padding: 18px 40px; }
.btn-full { width: 100%; }

/* Icon button */
.btn-icon {
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  color: var(--c-text-2);
  box-shadow: var(--shadow-xs);
}
.btn-icon:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-icon svg   { width: 20px; height: 20px; }


/* ════════════════════════════════════════════════════════════
   FORM ELEMENTS
════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--c-text-2);
  letter-spacing: .01em;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-size: .95rem;
  color: var(--c-text);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--c-text-4);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-ring);
}

.form-input.error,
.form-textarea.error {
  border-color: var(--c-error);
  box-shadow: 0 0 0 3px rgba(217, 79, 79, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239C9080' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-error {
  font-size: .8rem;
  color: var(--c-error);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-hint {
  font-size: .78rem;
  color: var(--c-text-3);
}

/* Checkbox row */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 20px; height: 20px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  accent-color: var(--c-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check-label {
  font-size: .9rem;
  color: var(--c-text-2);
  font-weight: 500;
}

/* Row of two inputs side by side */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}

/* Full-width form stack */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}


/* ════════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */

.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border-2);
  overflow: hidden;
}

.card-body {
  padding: var(--s-6);
}

.card-hover {
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}


/* ════════════════════════════════════════════════════════════
   TOP NAVIGATION (authenticated pages)
════════════════════════════════════════════════════════════ */

.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-top-h);
  z-index: 100;
  background: rgba(253, 246, 238, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--c-border-2);
}

.top-nav-inner {
  height: 100%;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.top-nav-logo {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--c-text);
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}
.top-nav-logo span { color: var(--c-primary); }

.top-nav-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
  position: absolute;
  left: 50%; transform: translateX(-50%);
}

.top-nav-btn {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--c-text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.top-nav-btn:hover { background: var(--c-primary-bg); color: var(--c-primary); }
.top-nav-btn svg   { width: 22px; height: 22px; }


/* ════════════════════════════════════════════════════════════
   BOTTOM NAVIGATION (mobile primary nav)
════════════════════════════════════════════════════════════ */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-bot-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--c-border-2);
  display: flex;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--c-text-4);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav-item svg {
  width: 24px; height: 24px;
  transition: transform var(--t-base) var(--ease-bounce);
}

.bottom-nav-item.active {
  color: var(--c-primary);
}

.bottom-nav-item.active svg {
  transform: scale(1.1);
}

.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%; height: 2px;
  background: var(--c-primary);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}

/* Notification dot */
.bottom-nav-item .nav-dot {
  position: absolute;
  top: 8px; right: calc(50% - 18px);
  width: 8px; height: 8px;
  background: var(--c-primary);
  border-radius: 50%;
  border: 2px solid var(--c-surface);
}


/* ════════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

.badge-primary   { background: var(--c-primary-bg);  color: var(--c-primary-dk); }
.badge-success   { background: var(--c-success-bg);  color: var(--c-success); }
.badge-muted     { background: rgba(156,144,128,.1);  color: var(--c-text-3); }
.badge-verified  { background: var(--c-success-bg);  color: var(--c-success); }


/* ════════════════════════════════════════════════════════════
   AVATAR
════════════════════════════════════════════════════════════ */

.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--c-bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  overflow: hidden;
}

.avatar-sm  { width: 36px;  height: 36px;  font-size: 1rem; }
.avatar-md  { width: 48px;  height: 48px;  font-size: 1.3rem; }
.avatar-lg  { width: 64px;  height: 64px;  font-size: 1.8rem; }
.avatar-xl  { width: 88px;  height: 88px;  font-size: 2.4rem; }

.avatar-ring {
  border: 2.5px solid var(--c-primary);
  box-shadow: 0 0 0 2px var(--c-bg), 0 0 0 4px var(--c-primary-ring);
}


/* ════════════════════════════════════════════════════════════
   DIVIDER
════════════════════════════════════════════════════════════ */

.divider {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: var(--s-6) 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--c-text-3);
  font-size: .8rem;
  margin: var(--s-6) 0;
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}


/* ════════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-12) var(--s-6);
  gap: var(--s-4);
}

.empty-state-icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: var(--s-2);
  animation: pulse 3s ease-in-out infinite;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--c-text);
}

.empty-state p {
  font-size: .9rem;
  color: var(--c-text-3);
  max-width: 280px;
  line-height: 1.6;
}


/* ════════════════════════════════════════════════════════════
   LOADING SPINNER
════════════════════════════════════════════════════════════ */

.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(242, 107, 56, .2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.spinner-lg { width: 40px; height: 40px; border-width: 3.5px; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--c-bg);
  display: flex; align-items: center; justify-content: center;
}


/* ════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════════════ */

#toast-container {
  position: fixed;
  bottom: calc(var(--nav-bot-h) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--c-text);
  color: var(--c-white);
  font-size: .875rem;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s var(--ease-out) both;
  max-width: 320px;
  text-align: center;
}

.toast-success { background: var(--c-success); }
.toast-error   { background: var(--c-error); }


/* ════════════════════════════════════════════════════════════
   STATS ROW (dashboard)
════════════════════════════════════════════════════════════ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
}

.stat-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-4);
  text-align: center;
  border: 1px solid var(--c-border-2);
  box-shadow: var(--shadow-xs);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--c-text);
  line-height: 1;
}

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: var(--s-1);
}


/* ════════════════════════════════════════════════════════════
   AUTH PAGES
════════════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-6) var(--s-5);
  background: var(--c-bg);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242,107,56,.10), transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242,107,56,.07), transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: var(--max-card);
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--s-10) var(--s-8);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border-2);
  position: relative; z-index: 1;
  animation: scaleIn var(--t-slow) var(--ease-bounce) both;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--c-text);
  letter-spacing: -0.02em;
  text-decoration: none;
  display: inline-block;
  margin-bottom: var(--s-6);
}
.auth-logo span { color: var(--c-primary); }

.auth-heading {
  font-size: 1.65rem;
  margin-bottom: var(--s-1);
}

.auth-sub {
  font-size: .9rem;
  color: var(--c-text-3);
  margin-bottom: var(--s-8);
}

.auth-footer {
  margin-top: var(--s-6);
  text-align: center;
  font-size: .875rem;
  color: var(--c-text-3);
}

.auth-footer a {
  color: var(--c-primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* Alert / server error banner */
.alert {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 500;
  display: none;
}
.alert-error   { background: var(--c-error-bg);   color: var(--c-error); }
.alert-success { background: var(--c-success-bg); color: var(--c-success); }
.alert.show    { display: block; }


/* ════════════════════════════════════════════════════════════
   SECTION HEADERS (dashboard / pages)
════════════════════════════════════════════════════════════ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--c-text);
}

/* ════════════════════════════════════════════════════════════
   DOG MINI CARDS (dashboard grid)
════════════════════════════════════════════════════════════ */

.dogs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}

.dog-mini-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--c-border-2);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base);
  display: flex;
  flex-direction: column;
}

.dog-mini-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.dog-mini-photo {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, var(--c-bg-alt), var(--c-bg));
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
  overflow: hidden;
}

.dog-mini-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.dog-mini-info {
  padding: var(--s-3) var(--s-4);
}

.dog-mini-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
}

.dog-mini-meta {
  font-size: .75rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

/* Add dog card */
.dog-add-card {
  background: var(--c-primary-bg);
  border: 1.5px dashed rgba(242,107,56,.3);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  aspect-ratio: 1 / 1.05;
  text-decoration: none;
  color: var(--c-primary);
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-base) var(--ease-bounce);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  padding: var(--s-4);
}

.dog-add-card:hover {
  background: rgba(242,107,56,.15);
  border-color: var(--c-primary);
  transform: scale(1.02);
}

.dog-add-card .add-icon {
  font-size: 1.8rem;
  line-height: 1;
}


/* ════════════════════════════════════════════════════════════
   ONBOARDING NUDGE BANNER
════════════════════════════════════════════════════════════ */

.nudge-banner {
  background: linear-gradient(135deg, var(--c-primary-bg), rgba(242,107,56,.05));
  border: 1px solid rgba(242,107,56,.2);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  animation: fadeUp var(--t-slow) var(--ease-out) both;
}

.nudge-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.nudge-body { flex: 1; min-width: 0; }

.nudge-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 2px;
}

.nudge-desc {
  font-size: .8rem;
  color: var(--c-text-3);
  line-height: 1.4;
}


/* ════════════════════════════════════════════════════════════
   NO-DOGS DISCOVERY WARNING
════════════════════════════════════════════════════════════ */

.discovery-gate {
  margin: var(--s-8) auto;
  max-width: var(--max-card);
  padding: 0 var(--s-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
}

.discovery-gate-icon { font-size: 3.5rem; }

.discovery-gate h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--c-text);
}

.discovery-gate p {
  font-size: .9rem;
  color: var(--c-text-3);
  max-width: 260px;
  line-height: 1.6;
}
