/* ==========================================================================
   RAG Agent — Modern Legal & AI Policy Design System
   ========================================================================== */

:root {
  --legal-card-bg: rgba(18, 24, 38, 0.72);
  --legal-card-border: rgba(255, 255, 255, 0.08);
  --legal-card-hover: rgba(255, 255, 255, 0.12);
  --legal-accent: #6366f1;
  --legal-accent-light: #818cf8;
  --legal-accent-glow: rgba(99, 102, 241, 0.25);
  --legal-accent-bg: rgba(99, 102, 241, 0.1);
  --legal-teal: #14b8a6;
  --legal-teal-bg: rgba(20, 184, 166, 0.1);
  --legal-emerald: #10b981;
  --legal-emerald-bg: rgba(16, 185, 129, 0.1);
  --legal-amber: #f59e0b;
  --legal-amber-bg: rgba(245, 158, 11, 0.1);
}

html {
  overflow-x: clip !important;
  overflow-y: auto !important;
  height: auto !important;
  scroll-behavior: smooth;
}

body.legal-page-body {
  background-color: var(--bg-primary, #0b0f19);
  color: var(--text-primary, #f1f5f9);
  overflow: visible !important;
  overflow-x: clip !important;
  overflow-y: visible !important;
  height: auto !important;
  min-height: 100vh !important;
  position: static !important;
  display: block !important;
  -webkit-overflow-scrolling: touch;
}

.legal-page-wrapper {
  min-height: 100vh;
  height: auto;
  overflow: visible !important;
  display: block;
  background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
              radial-gradient(circle at 85% 15%, rgba(168, 85, 247, 0.08) 0%, transparent 45%),
              radial-gradient(circle at 10% 40%, rgba(20, 184, 166, 0.05) 0%, transparent 40%),
              var(--bg-primary, #0b0f19);
  position: relative;
  width: 100%;
}

/* ==========================================================================
   Header Navbar
   ========================================================================== */
.legal-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--legal-card-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(11, 15, 25, 0.85);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.legal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  transition: opacity 0.2s ease;
}

.legal-brand:hover {
  opacity: 0.9;
}

.legal-brand-badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legal-nav-tabs {
  display: flex;
  align-items: center;
  background: rgba(18, 24, 38, 0.8);
  border: 1px solid var(--legal-card-border);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.legal-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  border: 1px solid transparent;
}

.legal-nav-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.legal-nav-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(168, 85, 247, 0.25) 100%);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

.legal-nav-tab .tab-icon {
  font-size: 1rem;
}

.legal-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.legal-hero {
  text-align: center;
  padding: 56px 24px 32px;
  max-width: 900px;
  margin: 0 auto;
}

.legal-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: 0.3px;
}

.legal-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.legal-hero p {
  font-size: 1.05rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.6;
  max-width: 760px;
  margin: 0 auto 24px;
}

.legal-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #94a3b8;
}

.legal-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--legal-card-border);
}

/* ==========================================================================
   Main Legal Layout: Sidebar + Content
   ========================================================================== */
.legal-main-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 80px;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
  overflow: visible !important;
}

/* Sticky Left Sidebar */
.legal-sidebar {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 84px !important;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.legal-sidebar::-webkit-scrollbar {
  width: 4px;
}
.legal-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.legal-sidebar-card {
  background: var(--legal-card-bg);
  border: 1px solid var(--legal-card-border);
  border-radius: 14px;
  padding: 18px;
  backdrop-filter: blur(12px);
}

.sidebar-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* TOC Navigation */
.legal-toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
}

.legal-toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 0.8rem;
  color: var(--text-secondary, #94a3b8);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.35;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

.legal-toc-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.legal-toc-link.active {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.1);
  border-left-color: #6366f1;
  font-weight: 600;
}

/* Guarantees & Badges */
.badge-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--legal-card-border);
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.4;
}

.badge-item strong {
  display: block;
  color: #ffffff;
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.badge-item p {
  color: #94a3b8;
  margin: 0;
}

/* Contact Card */
.contact-dpo-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.78rem;
}

.contact-dpo-box h4 {
  font-size: 0.84rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.contact-email-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contact-email-btn:hover {
  background: rgba(99, 102, 241, 0.35);
  color: #ffffff;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.legal-content-card {
  background: var(--legal-card-bg);
  border: 1px solid var(--legal-card-border);
  border-radius: 20px;
  padding: 44px 48px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
}

.policy-panel {
  display: none;
}

.policy-panel.active {
  display: block;
  animation: legalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes legalFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Section styling */
.policy-section {
  padding-bottom: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--legal-card-border);
  scroll-margin-top: 120px;
}

.policy-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-num-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-num {
  font-size: 0.9rem;
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  color: var(--legal-accent-light);
  background: rgba(99, 102, 241, 0.15);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.policy-section h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.policy-section h3 {
  font-size: 1.12rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 22px 0 10px;
}

.copy-anchor-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.4;
  transition: all 0.2s ease;
}

.policy-section:hover .copy-anchor-btn {
  opacity: 1;
}

.copy-anchor-btn:hover {
  color: #818cf8;
}

.policy-section p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.policy-section ul,
.policy-section ol {
  margin: 12px 0 18px 24px;
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.7;
}

.policy-section li {
  margin-bottom: 8px;
}

.policy-section li strong {
  color: #ffffff;
}

/* Callout Highlights */
.callout-box {
  background: rgba(18, 24, 38, 0.85);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 24px 0;
  border-left: 4px solid var(--legal-accent);
  border-top: 1px solid var(--legal-card-border);
  border-right: 1px solid var(--legal-card-border);
  border-bottom: 1px solid var(--legal-card-border);
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.callout-box.emerald {
  border-left-color: var(--legal-emerald);
  background: rgba(16, 185, 129, 0.04);
}

.callout-box.amber {
  border-left-color: var(--legal-amber);
  background: rgba(245, 158, 11, 0.04);
}

.callout-box.teal {
  border-left-color: var(--legal-teal);
  background: rgba(20, 184, 166, 0.04);
}

.callout-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.callout-content {
  flex: 1;
}

.callout-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.callout-content p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #cbd5e1;
}

/* Tables */
.legal-table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--legal-card-border);
  margin: 22px 0;
  background: rgba(11, 15, 25, 0.5);
}

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

.legal-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 12px 16px;
  font-weight: 600;
  color: #94a3b8;
  border-bottom: 1px solid var(--legal-card-border);
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.5px;
}

.legal-table td {
  padding: 14px 16px;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  line-height: 1.5;
}

.legal-table tr:last-child td {
  border-bottom: none;
}

.legal-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Accordion / Expandable clauses */
.legal-accordion {
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legal-accordion-item {
  border: 1px solid var(--legal-card-border);
  border-radius: 10px;
  background: rgba(18, 24, 38, 0.5);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.legal-accordion-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.legal-accordion-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
}

.accordion-chevron {
  font-size: 0.8rem;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.legal-accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
  color: #818cf8;
}

.legal-accordion-content {
  display: none;
  padding: 0 18px 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #cbd5e1;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.legal-accordion-item.open .legal-accordion-content {
  display: block;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.legal-footer {
  margin-top: auto;
  border-top: 1px solid var(--legal-card-border);
  background: rgba(7, 9, 14, 0.95);
  padding: 40px 32px 32px;
}

.legal-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.legal-footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.legal-footer-link {
  font-size: 0.84rem;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease;
}

.legal-footer-link:hover {
  color: #ffffff;
}

.legal-footer-copy {
  font-size: 0.8rem;
  color: #64748b;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  body.legal-page-body {
    background: #ffffff !important;
    color: #111827 !important;
  }
  .legal-navbar,
  .legal-sidebar,
  .legal-nav-actions,
  .copy-anchor-btn,
  .legal-footer {
    display: none !important;
  }
  .legal-main-container {
    display: block !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .legal-content-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .policy-section {
    border-bottom: 1px solid #e5e7eb !important;
    page-break-inside: avoid;
  }
  .policy-section h2,
  .policy-section h3 {
    color: #111827 !important;
  }
  .policy-section p,
  .policy-section li {
    color: #374151 !important;
  }
  .callout-box {
    background: #f9fafb !important;
    border-color: #d1d5db !important;
  }
  .callout-content p {
    color: #374151 !important;
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .legal-main-container {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px 20px 60px;
  }
  .legal-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .legal-navbar {
    padding: 14px 20px;
    flex-wrap: wrap;
  }
  .legal-content-card {
    padding: 28px 24px;
  }
  .legal-hero h1 {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  .legal-nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .legal-hero {
    padding: 36px 16px 24px;
  }
  .legal-hero h1 {
    font-size: 1.7rem;
  }
  .legal-content-card {
    padding: 20px 16px;
    border-radius: 14px;
  }
  .section-header {
    flex-direction: column;
  }
}
