/* CSS Reset & Variable Design System */
:root {
  --primary-color: #0F3A65;       /* JDC Archives Deep Blue */
  --secondary-color: #00AED6;     /* JDC Cyan / Teal */
  --accent-color: #E36F26;        /* JDC Orange Submit / Contact buttons */
  --accent-hover: #C85A16;
  --text-dark: #1F2E3D;           /* Deep charcoal body text */
  --text-muted: #5A6E7F;          /* Secondary text */
  --bg-light: #F8FAF7;            /* Soft off-white */
  --bg-white: #FFFFFF;
  --border-color: #E2E8F0;
  --focus-ring: rgba(0, 174, 214, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 58, 101, 0.08);
  --shadow-lg: 0 12px 30px rgba(15, 58, 101, 0.15);
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --border-radius: 6px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text-dark);
  background-color: var(--bg-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--secondary-color);
  text-decoration: none;
  transition: var(--transition-smooth);
}

a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
  transition: var(--transition-smooth);
}

/* Header & Navigation */
.main-header {
  background-color: var(--primary-color);
  color: var(--bg-white);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.jdc-logo {
  width: 42px;
  height: 42px;
  color: var(--secondary-color);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--bg-white);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-menu a {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.25rem;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
}

.nav-menu a:hover,
.nav-menu a.active {
  color: var(--bg-white);
  text-decoration: none;
  border-bottom-color: var(--secondary-color);
}

.nav-menu .btn-donate {
  background-color: var(--accent-color);
  color: var(--bg-white) !important;
  padding: 0.5rem 1.25rem;
  border-radius: var(--border-radius);
  border-bottom: none;
}

.nav-menu .btn-donate:hover {
  background-color: var(--accent-hover);
}

/* Hero Section (Matching top visual style of mockup) */
.hero-banner {
  position: relative;
  background-color: #071f38;
  /* Premium linear gradient transitioning to represent historical files background */
  background-image: linear-gradient(135deg, rgba(15,58,101,0.95) 0%, rgba(0,174,214,0.7) 100%);
  background-size: cover;
  background-position: center;
  color: var(--bg-white);
  padding: 5rem 2rem;
  text-align: left;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hero-banner h1 {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.hero-banner p {
  font-size: 1.05rem;
  max-width: 650px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 300;
}

/* Names Index Box (Matching the card inside the mockup) */
.names-index-card {
  max-width: 900px;
  margin: -3.5rem auto 3rem auto;
  background-color: var(--bg-white);
  border-radius: var(--border-radius);
  padding: 2.5rem;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  text-align: center;
}

.names-index-card h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.names-index-card p {
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 1.5rem auto;
  font-size: 0.95rem;
}

.search-form {
  display: flex;
  gap: 1rem;
  max-width: 700px;
  margin: 0 auto 1.25rem auto;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-form input[type="text"] {
  width: 100%;
  padding: 0.9rem 1.2rem;
  font-size: 1rem;
  border: 1px solid #CBD5E1;
  border-radius: var(--border-radius);
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-smooth);
}

.search-form input[type="text"]:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-search-btn:hover {
  color: var(--text-dark);
}

.btn-submit {
  background-color: var(--accent-color);
  color: var(--bg-white);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  padding: 0.9rem 2.2rem;
  border-radius: var(--border-radius);
  text-transform: uppercase;
}

.btn-submit:hover {
  background-color: var(--accent-hover);
}

.btn-learn {
  background-color: var(--secondary-color);
  color: var(--bg-white);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.5rem;
  border-radius: var(--border-radius);
}

.btn-learn:hover {
  background-color: #0092B3;
}

/* Autocomplete Dropdown overlay */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  text-align: left;
  max-height: 250px;
  overflow-y: auto;
  margin-top: 2px;
  display: none;
}

.autocomplete-item {
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: #F0F9FF;
  color: var(--primary-color);
}

.autocomplete-item svg {
  width: 16px;
  height: 16px;
  color: var(--secondary-color);
}

/* Layout Columns: Facets and Results */
.search-page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem 1.5rem;
}

.search-layout-columns {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
}

/* Sidebar Facets Styling */
.facets-sidebar {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  height: fit-content;
  box-shadow: var(--shadow-sm);
}

.facets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.facets-header h3 {
  font-size: 1rem;
  color: var(--primary-color);
  font-weight: 700;
}

.btn-clear-filters {
  background: none;
  font-size: 0.8rem;
  color: var(--secondary-color);
  font-weight: 500;
}

.btn-clear-filters:hover {
  text-decoration: underline;
}

.facet-group {
  margin-bottom: 1.5rem;
}

.facet-group:last-child {
  margin-bottom: 0;
}

.facet-group h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.facet-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.facet-options::-webkit-scrollbar {
  width: 4px;
}

.facet-options::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 2px;
}

.facet-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.facet-label {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.facet-label input[type="checkbox"] {
  margin-right: 0.5rem;
  accent-color: var(--secondary-color);
  width: 14px;
  height: 14px;
}

.facet-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.75rem;
  background-color: #F1F5F9;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Results Area */
.results-area {
  display: flex;
  flex-direction: column;
}

.results-status {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.active-filters-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-chip {
  background-color: #E0F2FE;
  color: #0369A1;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}

.filter-chip button {
  background: none;
  border: none;
  color: #0369A1;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Results Grid & Cards */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.person-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  display: flex;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #CBD5E1;
}

/* Document Thumbnail Placeholder */
.document-thumb-placeholder {
  width: 100px;
  height: 130px;
  background-color: #F1F5F9;
  border: 1px dashed #CBD5E1;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: center;
  font-size: 0.7rem;
  padding: 0.5rem;
}

.document-thumb-placeholder svg {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.document-thumb-placeholder.large {
  width: 100%;
  height: 200px;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
}

.document-thumb-placeholder.large svg {
  width: 48px;
  height: 48px;
}

.card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.card-title a {
  color: inherit;
}

.card-title a:hover {
  color: var(--secondary-color);
  text-decoration: none;
}

.card-bio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.bio-item {
  color: var(--text-dark);
}

.bio-item strong {
  color: var(--text-muted);
  font-weight: 500;
}

.card-related-badges {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid #F1F5F9;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.doc-badge {
  font-size: 0.75rem;
  background-color: #F1F5F9;
  color: var(--text-dark);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.doc-badge.list { background-color: #ECFDF5; color: #047857; }
.doc-badge.index_cards { background-color: #EFF6FF; color: #1D4ED8; }
.doc-badge.migration_files { background-color: #FFF1F2; color: #BE123C; }
.doc-badge.remittances { background-color: #FDF4FF; color: #A21CAF; }
.doc-badge.transmigration_bureau { background-color: #FFFBEB; color: #B45309; }
.doc-badge.individual_files { background-color: #F5F3FF; color: #6D28D9; }

/* Pagination Bar */
.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.pagination-btn {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--border-radius);
}

.pagination-btn:hover:not(:disabled) {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
}

.pagination-btn.active {
  background-color: var(--secondary-color);
  color: var(--bg-white);
  border-color: var(--secondary-color);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Single Person Profile View */
.profile-page-container {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.profile-back-link {
  margin-bottom: 1.5rem;
}

.back-link {
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-header-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.profile-avatar {
  width: 70px;
  height: 70px;
  background-color: #E0F2FE;
  border-radius: 50%;
  color: var(--secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar svg {
  width: 40px;
  height: 40px;
}

.profile-title-info h2 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.profile-status-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.profile-status-badge span {
  font-weight: 600;
  color: #059669;
  background-color: #D1FAE5;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: capitalize;
}

.profile-content-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
}

.profile-bio-card,
.profile-documents-card,
.document-meta-card,
.document-people-card,
.document-preview-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  height: fit-content;
}

.profile-bio-card h3,
.profile-documents-card h3,
.document-meta-card h3,
.document-people-card h3,
.document-preview-card h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--primary-color);
  border-bottom: 2px solid var(--bg-light);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.bio-table,
.meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  table-layout: fixed;
}

.bio-table th,
.meta-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  width: 120px;
  padding: 0.65rem 0.5rem 0.65rem 0;
  border-bottom: 1px solid #F1F5F9;
}

.bio-table td,
.meta-table td {
  color: var(--text-dark);
  padding: 0.65rem 0;
  border-bottom: 1px solid #F1F5F9;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.alt-names-section {
  background-color: var(--bg-light);
  padding: 1rem;
  border-radius: var(--border-radius);
}

.alt-names-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.alt-names-list {
  list-style: none;
  font-size: 0.85rem;
}

.alt-names-list li {
  margin-bottom: 0.35rem;
}

.alt-names-list li:last-child {
  margin-bottom: 0;
}

.alt-names-list strong {
  color: var(--text-muted);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -1.25rem;
  margin-bottom: 1.5rem;
}

.related-docs-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.related-doc-item {
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  display: flex;
  gap: 1rem;
  transition: var(--transition-smooth);
}

.related-doc-item:hover {
  border-color: var(--secondary-color);
  box-shadow: var(--shadow-sm);
}

.doc-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.doc-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.doc-details {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Single Document Page View */
.document-page-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.document-header-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  position: relative;
}

.document-badge {
  position: absolute;
  right: 2rem;
  top: 2rem;
  background-color: #FEF3C7;
  color: #D97706;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.document-header-card h2 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.document-source-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.document-details-section {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
}

/* People Table in Document Page */
.people-table-container {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.people-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.people-table th {
  background-color: var(--bg-light);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
}

.people-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.people-table tbody tr:hover {
  background-color: #F8FAFC;
}

.btn-view-profile {
  background-color: var(--secondary-color);
  color: var(--bg-white);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
}

.btn-view-profile:hover {
  background-color: #0092B3;
}

/* Need Help Section & Footer (Mockup visual styles) */
.help-section {
  background-color: #10355A;
  color: var(--bg-white);
  padding: 4rem 2rem;
  text-align: center;
}

.help-content {
  max-width: 600px;
  margin: 0 auto;
}

.help-section h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: 1rem;
}

.help-section p {
  font-weight: 300;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2rem;
}

.btn-contact {
  background-color: var(--accent-color);
  color: var(--bg-white);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  padding: 0.9rem 2.5rem;
  border-radius: var(--border-radius);
  display: inline-block;
}

.btn-contact:hover {
  background-color: var(--accent-hover);
  text-decoration: none;
}

.main-footer {
  background-color: #0A223B;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  padding: 2rem;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Loading Spinner */
.loading-spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 174, 214, 0.1);
  border-left-color: var(--secondary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive media queries */
@media (max-width: 900px) {
  .search-layout-columns,
  .profile-content-grid,
  .document-details-section {
    grid-template-columns: 1fr;
  }
  
  .names-index-card {
    margin-top: -2rem;
    padding: 1.5rem;
  }
  
  .search-form {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .btn-submit {
    width: 100%;
  }

  .person-card {
    flex-direction: column;
    gap: 1rem;
  }
  
  .document-thumb-placeholder {
    width: 80px;
    height: 100px;
  }
  
  .hero-banner h1 {
    font-size: 2rem;
  }
  
  .header-container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }
}

/* Embed Search Only Widget Styles */
body.embed-search-only .main-header,
body.embed-search-only .hero-banner,
body.embed-search-only .help-section,
body.embed-search-only .main-footer,
body.embed-search-only .search-layout-columns {
  display: none !important;
}

body.embed-search-only .names-index-card {
  margin: 0 auto !important;
  max-width: 100% !important;
  box-shadow: none !important;
  border: none !important;
  background-color: transparent !important;
  padding: 1rem 0 !important;
}
