/* 1. VARIABLES & THEME */
:root {
  --bg-index: #d9e7e5;     /* Lighter Seafoam for Public */
  --bg-volunteer: #ccdcd6; /* Saturated Seafoam for Volunteers */
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #cbd5e1;
  --radius: 16px;
  --primary: #2d5a52;      /* Deep Sea Pine */
  --accent: #4a8c80;       /* Seafoam Accent */
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 2. GLOBAL STYLES & FONT RESTORATION */
* { box-sizing: border-box; }

body { 
  margin: 0; 
  /* Modern Sans-Serif Font Stack */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Background switching based on HTML body class */
body.index-page { background-color: var(--bg-index) !important; }
body.volunteer-page { background-color: var(--bg-volunteer) !important; }

/* 3. LAYOUT & FILTERS */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 15px; }

header { 
  display: flex; 
  align-items: baseline; 
  justify-content: space-between; 
  gap: 16px; 
  flex-wrap: wrap; 
  margin-bottom: 25px; 
}

.filters { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 10px; /* Reduced gap slightly so 6 items fit better */
  margin-bottom: 30px; 
}

/* Make all dropdowns stretch equally */
.filters select { 
  flex: 1 1 130px; 
}

/* Give the search bar slightly more priority */
.filters #q { 
  flex: 2 1 200px; 
}

input, select { 
  padding: 12px 16px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  background: #fff; 
  font-size: 14px; 
  font-family: inherit; 
  outline: none; 
}

/* 4. CARDS */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s;
  cursor: pointer;
}

.card:hover { transform: translateY(-4px); }

.card-photo {
  width: 100%;
  aspect-ratio: 1 / 1; 
  object-fit: cover;
  object-position: center 20%; 
  display: block;
  background: #eee;
}

/* 5. MODAL SYSTEM & SCROLL FIX */
.modal-backdrop { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.8); 
  display: none; 
  align-items: center; 
  justify-content: center; 
  z-index: 100; 
  padding: 20px; 
}

.modal { 
  background: #fff; 
  width: 100%; 
  max-width: 1000px; 
  max-height: 90vh; /* Prevents button cutoff */
  display: flex; 
  flex-direction: column; 
  position: relative; 
  border-radius: 20px; 
  overflow: hidden; 
}

@media (min-width: 820px) {
  .modal { flex-direction: row; }
}

/* 6. SLIDESHOW */
.modal-media { 
  position: relative; 
  background: #000; 
  width: 100%; 
  height: 350px; 
  overflow: hidden; 
  flex-shrink: 0; 
}

@media (min-width: 820px) {
  .modal-media { width: 60%; height: auto; }
}

.slides-container { display: flex; height: 100%; width: 100%; transition: transform 0.4s ease-out; }
.slide { min-width: 100%; height: 100%; object-fit: contain; }

.close { 
  position: absolute; top: 15px; left: 15px; z-index: 60; 
  width: 40px; height: 40px; background: rgba(255, 255, 255, 0.9); 
  border: none; border-radius: 50%; display: flex; align-items: center; 
  justify-content: center; cursor: pointer; font-size: 24px; 
}

.nav-btn { 
  position: absolute; top: 50%; transform: translateY(-50%); 
  background: rgba(255, 255, 255, 0.85); border: none; border-radius: 50%; 
  width: 44px; height: 44px; cursor: pointer; z-index: 50; 
  display: flex; align-items: center; justify-content: center; 
  font-size: 18px; color: #000; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.prev { left: 12px; } .next { right: 12px; }

/* 7. MODAL CONTENT & INTERNAL SCROLLING */
.modal-content { 
  padding: 30px; 
  display: flex; 
  flex-direction: column; 
  gap: 15px; 
  overflow-y: auto; /* Scrollbar inside modal */
  flex: 1;
}

@media (min-width: 820px) {
  .modal-content { width: 40%; }
}

/* Large Textarea for Description and Medical Notes */
.modal-content textarea {
  width: 100% !important;
  min-height: 150px !important;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fdfdfd;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
}

.kv-edit { display: flex; flex-direction: column; gap: 6px; }
.k { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; }
.edit-input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 15px; }

/* 8. CHECKBOXES & BUTTONS */
.kv-edit.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.kv-edit.checkbox-row input[type="checkbox"] {
  width: 20px; height: 20px; margin: 0; accent-color: var(--accent); order: -1;
}

.save-btn, .adopt-btn {
  display: block; width: 100%; padding: 16px; 
  background-color: var(--primary) !important; color: white !important;
  text-align: center; font-weight: 600; font-size: 16px; 
  border: none; border-radius: 12px; margin-top: 10px; cursor: pointer;
}

.save-btn:hover, .adopt-btn:hover { opacity: 0.9; }

/* AUTH GATE - This centers the box perfectly on the screen */
#auth-gate { 
  position: fixed; 
  inset: 0; 
  background-color: var(--bg-volunteer); /* Matches the volunteer theme */
  z-index: 1000; 
  display: flex;          /* Enables Flexbox */
  align-items: center;    /* Vertical centering */
  justify-content: center; /* Horizontal centering */
  padding: 20px;
}

/* THE LOGIN BOX */
.login-box { 
  text-align: center; 
  background: white; 
  padding: 40px; 
  border-radius: 24px; 
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); 
  width: 100%;
  max-width: 380px; /* Standard size for a login card */
}

/* LOGO IN LOGIN */
.login-box img {
  max-height: 50px;
  margin-bottom: 25px;
}

/* INPUT FIELD */
#pass { 
  width: 100%; 
  padding: 14px; 
  margin-bottom: 15px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  font-family: inherit;
  font-size: 16px;
  text-align: center;
}

/* THE BUTTON - Keeping it contained */
#auth-gate .save-btn { 
  width: 100%; /* Spans the width of the padding inside the box */
  margin-top: 5px;
}

.announcement-card {
  background: #fef9c3; /* Soft yellow */
  border: 1px solid #fde047;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 30px;
  color: #3c5a53;
}

.announcement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.announcement-tag {
  background: #facc15;
  color: #422006;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}
#announcement-content {
  width: 100%;
}
#announcement-content h3 { margin-top: 0; margin-bottom: 5px; }
#announcement-content p { margin: 0; line-height: 1.5; }


.announcement-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 equal columns */
  gap: 0; /* We'll use borders instead of gaps for the "frame" look */
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden; /* Keeps corners rounded */
  background: white;
  margin-top: 15px;
}

/* Container for the entries */
.announcement-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

  /* Responsive: Stack columns on small phones */
@media (max-width: 800px) {
  .announcement-grid {
    grid-template-columns: 1fr 1fr; /* 2x2 on tablets */
  }
  .ann-section:nth-child(2) {
    border-right: none;
  }
}

@media (max-width: 500px) {
  .announcement-grid {
    grid-template-columns: 1fr; /* Stacked on phones */
  }
  .ann-section {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
}

/* Styling the Collapsible Container */
.ann-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Bold Green Headers */
.ann-label {
  display: block;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #3c5a53; /* Dark Green from your button */
  margin-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 4px;
}

/* The Content inside when open */
.ann-section p {
  padding: 0 15px 15px 15px;
  margin: 0;
  font-size: 0.95rem;
  color: #1f2937;
  line-height: 1.5;
}

.ann-section:last-child {
  border-right: none; /* Remove last divider */
}

/* The Clickable Header */
.ann-section summary {
  padding: 15px;
  list-style: none; /* Removes default arrow */
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #3c5a53;
  background: #fff;
  transition: background 0.2s;
}

.ann-section summary:hover {
  background: #f8fafc;
}

/* Custom Arrow Indicator */
.ann-section summary::after {
  content: '▼';
  font-size: 10px;
  transition: transform 0.3s;
}

.ann-section[open] summary::after {
  transform: rotate(180deg);
}

/* Ensure the title input fills the space when editing */
#ann_edit_title {
  width: 100%;
  height: 45px;
  font-size: 1.2em;
  font-weight: bold;
}

/* Button stays its natural size, doesn't stretch */
.ann-btn-sync {
  width: auto !important;
  height: 40px; 
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 !important;
  display: inline-flex;
  align-items: center;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .ann-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end; /* Keeps it right-aligned even on mobile */
  }
}

