/* ==========================================================================
   VeloCalc Legal Portal & Production Compliance Design System
   Jurisdictions: India (DPDP), United States (CCPA/CPRA), European Union (GDPR), Australia (Privacy Act)
   Responsive: Mobile (<640px), Tablet (768px-1024px), Desktop (1280px+)
   WCAG 2.2 AA Compliant | Light & Dark Mode | Print Ready
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Color Palette - Emerald / Teal + Slate */
  --primary: #0F766E;
  --primary-hover: #115E59;
  --primary-light: #F0FDFA;
  --primary-border: #99F6E4;
  --accent: #2563EB;
  --accent-light: #EFF6FF;

  /* Surfaces & Backgrounds */
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-highlight: #FEF3C7;
  --border-color: #E2E8F0;
  --border-subtle: #CBD5E1;

  /* Typography */
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-light: #64748B;
  --text-inverse: #FFFFFF;

  /* Status & Jurisdiction Colors */
  --badge-india-bg: #FFF7ED;
  --badge-india-text: #C2410C;
  --badge-india-border: #FFEDD5;

  --badge-us-bg: #EFF6FF;
  --badge-us-text: #1D4ED8;
  --badge-us-border: #DBEAFE;

  --badge-eu-bg: #F0FDF4;
  --badge-eu-text: #15803D;
  --badge-eu-border: #DCFCE7;

  --badge-au-bg: #FAF5FF;
  --badge-au-text: #7E22CE;
  --badge-au-border: #F3E8FF;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --container-max-width: 1040px;
}

/* Permanent Production Light Mode */
html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
  -webkit-text-size-adjust: 100%;
}

/* Scroll Offset to Prevent Sticky Header from Obscuring Headings */
section,
section[id],
h1[id],
h2,
h2[id],
h3,
h3[id],
[id] {
  scroll-margin-top: 100px;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.header-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #0D9488 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.3);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  font-weight: 500;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links {
  display: flex;
  gap: 16px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--border-color);
}

/* ==========================================================================
   Page Layout & Container
   ========================================================================== */
.main-wrapper {
  flex: 1;
  max-width: var(--container-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.legal-document-container {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.full-width-container {
  display: block;
  max-width: 860px;
  margin: 0 auto;
}

/* Left Sidebar / Table of Contents */
.toc-sidebar {
  position: sticky;
  top: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-list a {
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* Content Area */
.document-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Header Elements & Badges
   ========================================================================== */
.doc-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.badge-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.badge-india {
  background: var(--badge-india-bg);
  color: var(--badge-india-text);
  border-color: var(--badge-india-border);
}

.badge-us {
  background: var(--badge-us-bg);
  color: var(--badge-us-text);
  border-color: var(--badge-us-border);
}

.badge-eu {
  background: var(--badge-eu-bg);
  color: var(--badge-eu-text);
  border-color: var(--badge-eu-border);
}

.badge-au {
  background: var(--badge-au-bg);
  color: var(--badge-au-text);
  border-color: var(--badge-au-border);
}

.doc-title {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--primary);
  margin-bottom: 10px;
}

.doc-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.doc-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ==========================================================================
   Typography & Content Flow
   ========================================================================== */
h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 36px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 24px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 16px;
  color: var(--text-muted);
  line-height: 1.7;
}

p strong,
li strong {
  color: var(--text-main);
}

ul,
ol {
  margin-left: 24px;
  margin-bottom: 18px;
  color: var(--text-muted);
}

li {
  margin-bottom: 8px;
  line-height: 1.6;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

/* Callout & Highlight Boxes */
.callout {
  padding: 18px 22px;
  border-radius: var(--radius-md);
  margin: 24px 0;
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  color: var(--text-main);
}

.callout strong {
  color: var(--primary);
  display: block;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.callout-warning {
  border-left-color: #D97706;
  background: #FFFBEB;
}

.callout-warning strong {
  color: #B45309;
}

.callout-jurisdiction {
  border-left-width: 4px;
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.callout-india {
  border-left-color: #EA580C;
}

.callout-us {
  border-left-color: #2563EB;
}

.callout-eu {
  border-left-color: #16A34A;
}

.callout-au {
  border-left-color: #9333EA;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

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

th {
  background: var(--bg-subtle);
  color: var(--text-main);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
}

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

tr:hover td {
  background: var(--bg-subtle);
}

/* ==========================================================================
   Portal Index Hub Specifics
   ========================================================================== */
.portal-hero {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 40px;
}

.portal-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.portal-hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.search-bar-wrapper {
  max-width: 540px;
  margin: 24px auto 0;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 14px 20px 14px 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 36px;
}

.policy-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.policy-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.policy-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.policy-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.policy-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
  flex: 1;
}

.policy-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 40px 20px;
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  list-style: none;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Action Buttons (Print / Back to Top) */
.action-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.btn-action {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-action:hover {
  background: var(--border-color);
  color: var(--primary);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 960px) {
  .legal-document-container {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    display: none;
    /* Hide sticky TOC on mobile/tablet or convert to collapsible */
  }

  .document-card {
    padding: 24px 20px;
  }

  .doc-title {
    font-size: 1.7rem;
  }
}

@media (max-width: 640px) {
  .header-container {
    padding: 12px 16px;
  }

  .brand-sub {
    display: none;
  }

  .nav-links {
    display: none;
    /* Mobile navigation simplified */
  }

  .main-wrapper {
    padding: 20px 12px 40px;
  }

  .portal-hero h1 {
    font-size: 1.8rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Print Stylesheet (@media print)
   ========================================================================== */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  .site-header,
  .toc-sidebar,
  .site-footer,
  .action-toolbar,
  .theme-toggle-btn {
    display: none !important;
  }

  .main-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .document-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .doc-title {
    color: #000000 !important;
    font-size: 20pt;
  }

  h2 {
    color: #000000 !important;
    page-break-after: avoid;
  }

  a {
    color: #000000 !important;
    text-decoration: underline;
  }

  .callout {
    border-left: 3pt solid #666666 !important;
    background: #F4F4F4 !important;
    color: #000000 !important;
  }
}