/* ===================================================================
   Foundation Database Styles
   Uses CSS variables from style.css (--brand-primary, --brand-accent, etc.)
   =================================================================== */

/* ── Search Page ──────────────────────────────────────────── */

.fdn-search-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.fdn-search-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.fdn-search-hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2.25rem;
  color: #111827;
  margin: 0 0 0.5rem;
}

.fdn-search-subtitle {
  color: #6b7280;
  font-size: 1.05rem;
  margin: 0 auto;
  max-width: none;
}

/* Search bar */
.fdn-search-bar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.fdn-search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  color: #111827;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s;
}

.fdn-search-input:focus {
  border-color: #15803d;
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.1);
}

.fdn-search-sm {
  max-width: 320px;
}

.fdn-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  align-items: center;
}

.fdn-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #374151;
  background: #fff;
  cursor: pointer;
}

.fdn-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #374151;
  cursor: pointer;
}

.fdn-checkbox-label input[type="checkbox"] {
  accent-color: #15803d;
}

/* Layout: results + sidebar */
.fdn-search-layout {
  /* full width container */
}

.fdn-search-content {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2rem;
}

.fdn-results-area {
  min-width: 0;
}

.fdn-results-status {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

/* Results grid */
.fdn-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.fdn-prompt-text,
.fdn-no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: #9ca3af;
  padding: 3rem 1rem;
  font-size: 1rem;
  max-width: none;
}

/* ── Foundation Card ──────────────────────────────────────── */

.fdn-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fdn-card:hover {
  border-color: #15803d;
  box-shadow: 0 2px 8px rgba(21, 128, 61, 0.08);
}

.fdn-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.fdn-card-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: #111827;
  margin: 0;
  line-height: 1.3;
}

.fdn-card-location {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0 0 0.75rem;
}

.fdn-card-ein {
  color: #9ca3af;
}

.fdn-card-stats {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.fdn-card-stat {
  display: flex;
  flex-direction: column;
}

.fdn-card-stat-value {
  font-weight: 600;
  font-size: 1rem;
  color: #111827;
}

.fdn-card-stat-label {
  font-size: 0.75rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fdn-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ── Tags / Badges ────────────────────────────────────────── */

.fdn-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 500;
}

.fdn-tag-lg {
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.fdn-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.fdn-badge-green { background: #dcfce7; color: #166534; }
.fdn-badge-red { background: #fef2f2; color: #991b1b; }
.fdn-badge-gray { background: #f3f4f6; color: #6b7280; }

/* ── Sidebar ──────────────────────────────────────────────── */

.fdn-sidebar {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 5rem;
}

.fdn-sidebar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  color: #111827;
}

.fdn-state-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fdn-state-list li a {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  color: #374151;
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid #f3f4f6;
}

.fdn-state-list li a:hover {
  color: #15803d;
}

.fdn-state-count {
  color: #9ca3af;
  font-size: 0.85rem;
}

.fdn-sidebar-more {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #15803d;
  text-decoration: none;
}

.fdn-sidebar-more:hover {
  text-decoration: underline;
}

/* ── Pagination ───────────────────────────────────────────── */

.fdn-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.fdn-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.fdn-page-link:hover {
  background: #f3f4f6;
}

.fdn-page-current {
  background: #15803d;
  color: #fff;
  border-color: #15803d;
  cursor: default;
}

.fdn-page-current:hover {
  background: #15803d;
}

.fdn-page-ellipsis {
  padding: 0 0.25rem;
  color: #9ca3af;
}

.fdn-page-info {
  font-size: 0.9rem;
  color: #6b7280;
  padding: 0 0.5rem;
}

/* ═══════════════════════════════════════════════════════════
   Profile Page
   ═══════════════════════════════════════════════════════════ */

.fdn-profile-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
.fdn-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.fdn-profile-name {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  color: #111827;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.fdn-profile-meta {
  color: #6b7280;
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.fdn-ein-badge {
  display: inline-block;
  background: #f3f4f6;
  color: #6b7280;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: monospace;
  margin-left: 0.5rem;
}

.fdn-website-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #15803d;
  font-size: 0.9rem;
  text-decoration: none;
}

.fdn-website-link:hover {
  text-decoration: underline;
}

/* Save button */
.fdn-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.fdn-btn:hover {
  border-color: #15803d;
  color: #15803d;
}

.fdn-btn-saved {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

.fdn-btn-saved:hover {
  background: #0f5c2e;
  border-color: #0f5c2e;
  color: #fff;
}

/* ── Stat Cards ───────────────────────────────────────────── */

.fdn-stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.fdn-stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.fdn-stat-value {
  display: block;
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: #111827;
  margin-bottom: 0.25rem;
}

.fdn-stat-label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Sections ─────────────────────────────────────────────── */

.fdn-section {
  margin-bottom: 2.5rem;
}

.fdn-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.35rem;
  color: #111827;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #ecfdf5;
}

.fdn-section-count {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #9ca3af;
  font-weight: 400;
}

.fdn-mission-text {
  color: #374151;
  line-height: 1.7;
  font-size: 1rem;
}

.fdn-focus-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Application Info Grid ────────────────────────────────── */

.fdn-app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.fdn-app-wide {
  grid-column: 1 / -1;
}

.fdn-app-item {
  background: #f9fafb;
  border-radius: 8px;
  padding: 1rem;
}

.fdn-app-label {
  display: block;
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.fdn-app-value {
  color: #111827;
  font-size: 0.95rem;
}

/* ── Charts ───────────────────────────────────────────────── */

.fdn-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.fdn-chart-container {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
}

.fdn-chart-sm {
  max-width: 700px;
}

.fdn-chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.75rem;
}

.fdn-chart-table-fallback {
  margin-top: 0.75rem;
}

.fdn-chart-table-fallback summary {
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer;
}

/* Size distribution summary */
.fdn-size-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #374151;
}

.fdn-size-summary span {
  font-weight: 500;
}

/* ── Map ──────────────────────────────────────────────────── */

.fdn-map-container {
  max-width: 700px;
  margin: 0 auto;
}

.fdn-map-container svg {
  width: 100%;
  height: auto;
}

.fdn-map-container path {
  transition: opacity 0.15s;
}

.fdn-map-container path:hover {
  opacity: 0.8;
  stroke-width: 2 !important;
}

.fdn-map-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.fdn-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.fdn-legend-swatch {
  display: inline-block;
  width: 16px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #d1d5db;
}

/* ── Tables ───────────────────────────────────────────────── */

.fdn-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fdn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.fdn-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: #f9fafb;
  color: #6b7280;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

.fdn-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.fdn-table tbody tr:hover {
  background: #f9fafb;
}

.fdn-amount {
  font-weight: 600;
  white-space: nowrap;
  color: #111827;
}

.fdn-purpose {
  max-width: 300px;
  font-size: 0.85rem;
  color: #6b7280;
}

.fdn-grants-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .fdn-search-content {
    grid-template-columns: 1fr;
  }

  .fdn-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .fdn-stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .fdn-charts-grid {
    grid-template-columns: 1fr;
  }

  .fdn-app-grid {
    grid-template-columns: 1fr;
  }

  .fdn-profile-header {
    flex-direction: column;
  }

  .fdn-profile-name {
    font-size: 1.5rem;
  }

  .fdn-search-hero h1 {
    font-size: 1.75rem;
  }

  .fdn-results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 375px) {
  .fdn-search-page,
  .fdn-profile-page {
    padding: 1rem;
  }

  .fdn-stat-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .fdn-stat-card {
    padding: 0.75rem;
  }

  .fdn-stat-value {
    font-size: 1.2rem;
  }

  .fdn-card-stats {
    flex-direction: column;
    gap: 0.35rem;
  }
}
