/*
  Official Government Search Aesthetic
  Inspired by ASD / ACSC Portals
*/

:root {
  --primary-navy: #032049;
  --primary-navy-light: #0d3872;
  --accent-blue: #0076c0;
  --accent-red: #d32f2f;
  --bg-white: #ffffff;
  --bg-light-grey: #f5f6f8;
  --border-grey: #e0e0e0;
  
  --text-main: #1a1f24;
  --text-grey: #5c6670;
  --text-white: #ffffff;
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-white);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ──────────────────────────────────────────
   Utility Top Bar & Header 
─────────────────────────────────────────── */
.header-container {
  border-bottom: 1px solid var(--border-grey);
}

.utility-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 2rem;
  background-color: var(--bg-white);
  gap: 1.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.utility-bar a {
  color: var(--primary-navy);
  text-decoration: none;
}

.utility-bar a:hover {
  text-decoration: underline;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background-color: var(--bg-white);
  gap: 1.5rem;
}

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

.brand-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-navy);
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.9rem;
  color: var(--text-grey);
  border-left: 2px solid var(--border-grey);
  padding-left: 1rem;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.main-nav a {
  color: var(--primary-navy);
  text-decoration: none;
  padding-bottom: 0.5rem;
}

.main-nav a:hover, .main-nav a.active {
  border-bottom: 3px solid var(--primary-navy);
}

/* ──────────────────────────────────────────
   Hero Banner 
─────────────────────────────────────────── */
.hero-banner {
  background-color: var(--primary-navy);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.05) 150px, transparent 151px),
    radial-gradient(circle at 90% 80%, rgba(255,255,255,0.05) 250px, transparent 251px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.03) 400px, transparent 401px);
  color: var(--text-white);
  padding: 4rem 2rem;
  position: relative;
  overflow: hidden;
}

.hero-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-icon {
  width: 64px;
  height: 64px;
  background-color: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.hero-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.hero-banner h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.hero-banner p {
  font-size: 1.25rem;
  max-width: 800px;
  opacity: 0.9;
}

/* ──────────────────────────────────────────
   Layout Container 
─────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: flex;
  gap: 4rem;
  flex: 1;
}

/* ──────────────────────────────────────────
   Left Column (Search & Results) 
─────────────────────────────────────────── */
.main-content {
  flex: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Search Box */
.search-container {
  background: var(--bg-light-grey);
  border: 1px solid var(--border-grey);
  padding: 2rem;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.search-container h2 {
  font-size: 1.25rem;
  color: var(--primary-navy);
  margin-bottom: 1rem;
}

.search-form {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.search-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-navy);
  box-shadow: 0 0 0 3px rgba(3, 32, 73, 0.1);
}

.btn-submit {
  background: var(--primary-navy);
  color: white;
  border: none;
  padding: 0 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.25rem;
}

.btn-submit:hover {
  background: var(--primary-navy-light);
}

.btn-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Results Area */
.answer-section {
  display: none;
  margin-top: 2rem;
}

.answer-header {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-navy);
  border-bottom: 2px solid var(--primary-navy);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.answer-text {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-main);
}

.answer-text p {
  margin-bottom: 1.5rem;
}

/* Loading Spinner */
.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

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

/* ──────────────────────────────────────────
   Right Column (Citations / Evidence) 
─────────────────────────────────────────── */
.sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-grey);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-count {
  background: var(--bg-light-grey);
  color: var(--text-grey);
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

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

.empty-citations {
  color: var(--text-grey);
  font-size: 0.95rem;
  padding: 2rem 0;
  text-align: center;
  background: var(--bg-light-grey);
  border: 1px dashed #ccc;
  border-radius: 4px;
}

.citation-card {
  border: 1px solid var(--border-grey);
  background: white;
  padding: 1rem;
  border-radius: 4px;
  border-left: 4px solid var(--accent-blue);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.citation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  background: var(--bg-light-grey);
  color: var(--text-main);
  border: 1px solid #ccc;
  border-radius: 3px;
}

.tag.control { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }
.tag.category { background: #f3e5f5; border-color: #ce93d8; color: #6a1b9a; }

.citation-scores {
  font-size: 0.75rem;
  color: var(--text-grey);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dotted var(--border-grey);
}

.citation-text {
  font-size: 0.9rem;
  color: #333;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ──────────────────────────────────────────
   Responsive
─────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-section {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .brand-title {
    font-size: 1.45rem;
    letter-spacing: 0;
  }

  .brand-subtitle {
    border-left: none;
    padding-left: 0;
  }

  .main-nav {
    width: 100%;
    gap: 1rem;
  }

  .hero-banner {
    padding: 2.25rem 1rem;
  }

  .hero-banner h1 {
    font-size: 2rem;
  }

  .hero-banner p {
    font-size: 1rem;
  }

  .container {
    flex-direction: column;
    padding: 2rem 1rem;
    gap: 2rem;
  }

  .search-container {
    padding: 1.25rem;
  }

  .search-form {
    flex-direction: column;
  }

  .btn-submit {
    width: 100%;
    padding: 0 1rem;
  }

  .answer-text {
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .main-header {
    padding: 1rem;
  }

  .main-nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .main-nav a {
    padding: 0.4rem 0;
  }

  .hero-icon {
    width: 48px;
    height: 48px;
  }

  .hero-banner h1 {
    font-size: 1.65rem;
  }
}

/* ──────────────────────────────────────────
   Query Expansion (Search Page)
─────────────────────────────────────────── */
.query-expansion {
  background: var(--bg-light-grey);
  border: 1px solid var(--border-grey);
  border-radius: 6px;
  margin-top: 1rem;
  overflow: hidden;
}

.expansion-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
}

.expansion-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary-navy);
}

.expansion-arrow {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-grey);
  transition: transform 0.2s;
}

.query-expansion.expanded .expansion-arrow {
  transform: rotate(180deg);
}

.expansion-body {
  display: none;
  padding: 0 1rem 0.75rem 1rem;
}

.query-expansion.expanded .expansion-body {
  display: block;
}

.expansion-body ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.expansion-body li {
  font-size: 0.9rem;
  color: var(--text-main);
  padding: 0.3rem 0.5rem;
  background: white;
  border: 1px solid var(--border-grey);
  border-radius: 4px;
}

/* ──────────────────────────────────────────
   Guardrail Badge
─────────────────────────────────────────── */
.guardrail-badge {
  display: inline-block;
  background: #fff3e0;
  border: 1px solid #ffb74d;
  color: #e65100;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
