/* --- Base Variables & Reset --- */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent-light: #e0f2fe;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
}

.brand-logo span {
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.nav-app-btn {
  background-color: var(--primary);
  color: #ffffff !important;
  padding: 0.5rem 1rem;
  border-radius: 6px;
}

.nav-app-btn:hover {
  background-color: var(--primary-hover);
}

/* --- Hero & Search --- */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 4rem 0 5rem;
  text-align: center;
}

.hero-content {
  max-width: 700px;
}

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  color: #38bdf8;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.hero p {
  color: #94a3b8;
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.search-box {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 1rem 1rem 1rem 3.25rem;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  outline: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* --- Layout & Controls --- */
.dictionary-layout {
  padding: 2.5rem 1.5rem;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cat-btn, .alpha-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.cat-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.cat-btn.active, .cat-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.alphabet-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.alpha-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.alpha-btn.active, .alpha-btn:hover {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

/* --- Term Cards Grid --- */
.terms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.term-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.term-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.term-header h3 {
  font-size: 1.2rem;
  color: var(--text-main);
}

.term-tag {
  background: var(--accent-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.term-definition {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.term-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.read-more {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.affiliate-cta {
  color: #16a34a;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.affiliate-cta:hover, .read-more:hover {
  text-decoration: underline;
}

/* --- Monetization Banner --- */
.app-banner {
  background: linear-gradient(90deg, #0284c7 0%, #0d9488 100%);
  color: #ffffff;
  padding: 2rem;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.banner-content h2 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.banner-content p {
  opacity: 0.9;
  font-size: 0.95rem;
}

.banner-btn {
  background: #ffffff;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 700;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  white-space: nowrap;
}

.banner-btn:hover {
  background: #f1f5f9;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3rem;
}

@media (max-width: 768px) {
  .app-banner {
    flex-direction: column;
    text-align: center;
  }
}

/* ==========================================
   Term Detail Page Layout (`term.html`)
   ========================================== */

.term-detail-layout {
  padding: 2rem 1.5rem 4rem;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.breadcrumbs a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.content-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2.5rem;
}

/* Article Styling */
.term-article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: var(--shadow);
}

.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.article-header h1 {
  font-size: 2.25rem;
  color: var(--text-main);
  margin: 0.5rem 0 0.25rem;
}

.meta-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Definition & Takeaway Callouts */
.featured-definition {
  background: #f0f9ff;
  border-left: 4px solid var(--primary);
  padding: 1.5rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 2rem;
}

.featured-definition h2 {
  font-size: 1.1rem;
  color: var(--primary-hover);
  margin-bottom: 0.5rem;
}

.takeaways-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2.5rem;
}

.takeaways-box h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}

.takeaways-box ul {
  padding-left: 1.25rem;
}

.takeaways-box li {
  margin-bottom: 0.5rem;
  color: #334155;
}

/* Content & Examples */
.content-section {
  margin-bottom: 2.5rem;
}

.content-section h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.example-box {
  background: #fffbe0;
  border: 1px solid #fef08a;
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.example-box h4 {
  color: #854d0e;
  margin-bottom: 0.5rem;
}

/* Affiliate Broker Listing Cards */
.broker-cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.broker-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  transition: border-color 0.2s;
}

.broker-card:hover {
  border-color: var(--primary);
}

.broker-info h3 {
  font-size: 1.15rem;
  color: var(--text-main);
}

.broker-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0.2rem 0;
}

.broker-perk {
  font-size: 0.85rem;
  color: #16a34a;
  font-weight: 500;
}

.broker-action {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.btn-primary {
  background: #16a34a;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.btn-primary:hover {
  background: #15803d;
}

.btn-link {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Related Term Tags */
.related-terms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.related-terms-tags a {
  background: #f1f5f9;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
}

.related-terms-tags a:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Sidebar Widgets */
.term-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.match-widget {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
}

.match-widget h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.match-widget p {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.widget-btn {
  display: block;
  text-align: center;
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.widget-btn:hover {
  background: var(--primary-hover);
}

.nav-widget h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.nav-widget ul {
  list-style: none;
}

.nav-widget li {
  margin-bottom: 0.5rem;
}

.nav-widget a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-widget a:hover, .nav-widget a.active {
  color: var(--primary);
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .content-wrapper {
    grid-template-columns: 1fr;
  }
}