/* /CSS/pets.css
 * Stage 4 Session B — "My Pets" page.
 * Mirrors the structure of favorites.css: a single index.html shows the pets
 * view by setting body.view-pets (done by pets.js when window._view==='pets'),
 * which hides every other #mainContent section and reveals #petsView.
 * Reuses the CENTUO green palette throughout.
 */

/* ====================================================================
 * View switching
 * ==================================================================== */
body.view-pets #mainContent > section:not(#petsView),
body.view-pets #productCount,
body.view-pets #pagination,
body.view-pets #filterBar {
  display: none !important;
}
body.view-pets #petsView {
  display: block;
}

/* CRITICAL: the `hidden` attribute must win over the display rules below
   (.pets-state/.pets-loading/.pets-grid/.pet-modal and the toggled buttons).
   Without this, an author `display:flex|grid` beats the `hidden` attribute and
   every state stacks on top of each other. Scoped to #petsView so it cannot
   affect anything else on the site. */
#petsView [hidden] { display: none !important; }

/* When the signed-in user has pets, the homepage pet CTA is hidden; collapse the
   two-up hero-cards grid to a single column so the remaining card isn't lopsided. */
body.pets-hide-feature .hero-cards { grid-template-columns: 1fr; }

#petsView {
  /* Top padding clears the fixed nav (~68px tall), matching the homepage hero. */
  padding: 104px 24px 80px;
  min-height: 50vh;
}

.pets-page-inner {
  max-width: 1180px;
  margin: 0 auto;
}

.pets-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 20px;
  flex-wrap: wrap;
  margin: 0 0 28px;
  padding-top: 4px;
}

.pets-page-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 3.2vw, 2.3rem);
  color: #1A4418;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ====================================================================
 * Add button (shared look for header + empty-state)
 * ==================================================================== */
.pets-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border: 0;
  border-radius: 999px;
  background: #2D6A27;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
  box-shadow: 0 2px 6px rgba(45, 106, 39, 0.18);
}
.pets-add-btn:hover {
  background: #235420;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 106, 39, 0.24);
}
.pets-add-btn:active { transform: translateY(0); }
.pets-add-btn:focus-visible { outline: 2px solid #5DB852; outline-offset: 2px; }

/* ====================================================================
 * Loading + empty + signed-out states
 * ==================================================================== */
.pets-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 80px 24px;
  background: #F7FAF6;
  border-radius: 24px;
  border: 1px solid #E2EDDF;
}
.pets-state-icon {
  color: #5DB852;
  margin-bottom: 20px;
  opacity: 0.7;
}
.pets-state-text {
  font-size: 1.05rem;
  color: #3A4A38;
  max-width: 440px;
  line-height: 1.5;
  margin: 0 0 24px;
}

.pets-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
}
.pets-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #E2EDDF;
  border-top-color: #2D6A27;
  border-radius: 50%;
  animation: pets-spin 0.8s linear infinite;
}
@keyframes pets-spin { to { transform: rotate(360deg); } }

/* ====================================================================
 * Pets grid + cards
 * ==================================================================== */
.pets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 8px;
}

.pet-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border: 1px solid #E2EDDF;
  border-radius: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: opacity 0.22s ease, transform 0.22s ease, box-shadow 0.18s ease;
}
.pet-card:hover {
  box-shadow: 0 6px 18px rgba(26, 68, 24, 0.10);
  transform: translateY(-2px);
}
.pet-card.removing {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
}

/* top: avatar + name/species */
.pet-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
}
.pet-card-avatar {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: #EEF6EC;
  border-radius: 16px;
  overflow: hidden;
}
.pet-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pet-card-headtext {
  flex: 1 1 auto;
  min-width: 0;
}
.pet-card-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1A4418;
  margin: 0 0 2px;
  line-height: 1.2;
  word-break: break-word;
}
.pet-card-species {
  font-size: 0.9rem;
  color: #5A6B57;
  margin: 0;
  line-height: 1.35;
}

/* detail chips (age, sex, weight, neutered, colour) */
.pet-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pet-chip {
  font-size: 0.78rem;
  color: #3A4A38;
  background: #F2F8F0;
  border: 1px solid #E2EDDF;
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

/* footer: edit / delete, split full width */
.pet-card-foot {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid #F0F4EF;
}
.pet-card-foot button {
  flex: 1 1 0;
  border: 1px solid #E2EDDF;
  background: #fff;
  color: #2D6A27;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pet-card-foot .pet-edit:hover {
  background: #EEF6EC;
  border-color: #5DB852;
}
.pet-card-foot .pet-delete { color: #C0392B; }
.pet-card-foot .pet-delete:hover {
  background: #FBEDEC;
  border-color: #E0796F;
}

/* ====================================================================
 * Add / edit modal
 * ==================================================================== */
.pet-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pet-modal[hidden] { display: none; }

.pet-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 68, 24, 0.45);
  backdrop-filter: blur(2px);
}
.pet-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 22px;
  padding: 28px 28px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
.pet-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: #F0F4EF;
  color: #3A4A38;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.pet-modal-close:hover { background: #E2EDDF; }
.pet-modal-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  color: #1A4418;
  margin: 0 0 20px;
  font-weight: 600;
}

/* ====================================================================
 * Form
 * ==================================================================== */
.pet-form { display: flex; flex-direction: column; gap: 16px; }
.pet-field { display: flex; flex-direction: column; gap: 6px; }
.pet-field > label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2A3A28;
}
.pet-field .pet-req { color: #C0392B; }

.pet-input,
.pet-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #D6E2D2;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: #1A2A18;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pet-input:focus,
.pet-textarea:focus {
  outline: none;
  border-color: #5DB852;
  box-shadow: 0 0 0 3px rgba(93, 184, 82, 0.18);
}
.pet-textarea { min-height: 72px; resize: vertical; }

/* two-column row for compact fields (weight, birth date) on wider screens */
.pet-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* option button groups (species, sex, neutered) */
.pet-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pet-option {
  border: 1px solid #D6E2D2;
  background: #fff;
  color: #3A4A38;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pet-option:hover { border-color: #5DB852; }
.pet-option.selected {
  background: #2D6A27;
  border-color: #2D6A27;
  color: #fff;
}

.pet-form-error {
  color: #C0392B;
  font-size: 0.85rem;
  margin: 0;
  min-height: 1em;
}

/* photo upload field (edit mode only) */
.pet-photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.pet-photo-preview {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #EEF6EC;
  border: 1px solid #E2EDDF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  transition: opacity 0.18s ease;
}
.pet-photo-preview.is-busy { opacity: 0.5; }
.pet-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pet-photo-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pet-photo-controls button:disabled { opacity: 0.6; cursor: default; }
.pet-photo-hint {
  font-size: 0.78rem;
  color: #6B7A68;
  margin: 8px 0 0;
}

.pet-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.pet-btn-primary {
  flex: 1 1 auto;
  border: 0;
  border-radius: 10px;
  background: #2D6A27;
  color: #fff;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pet-btn-primary:hover { background: #235420; }
.pet-btn-primary:disabled { opacity: 0.6; cursor: default; }
.pet-btn-secondary {
  border: 1px solid #D6E2D2;
  border-radius: 10px;
  background: #fff;
  color: #3A4A38;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.pet-btn-secondary:hover { background: #F0F4EF; }
.pet-btn-danger {
  border: 1px solid #E0796F;
  border-radius: 10px;
  background: #fff;
  color: #C0392B;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.pet-btn-danger:hover { background: #FBEDEC; }

/* ====================================================================
 * Responsive
 * ==================================================================== */
@media (max-width: 640px) {
  #petsView { padding: 88px 16px 60px; }
  .pets-state { padding: 56px 20px; border-radius: 18px; }
  .pets-grid { grid-template-columns: 1fr; }
  .pet-modal-card { padding: 24px 20px 20px; border-radius: 18px; }
  .pet-row { grid-template-columns: 1fr; }
}
