/* LegalKB Main CSS - Production Optimized */
:root {
  --primary: #1a365d;
  --secondary: #2c5282;
  --accent: #3182ce;
  --text: #1a202c;
  --text-light: #4a5568;
  --bg: #ffffff;
  --bg-light: #f7fafc;
  --border: #e2e8f0;
  --success: #48bb78;
  --warning: #ed8936;
  --danger: #f56565;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);
  --radius: 8px;
  --transition: all 0.2s ease;
}

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

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

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

a:hover {
  color: var(--secondary);
}

strong { font-weight: 600; }
em { font-style: italic; }

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.container-narrow {
  max-width: 800px;
}

main {
  flex: 1;
}

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.logo svg {
  width: 32px;
  height: 32px;
}

nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

nav a {
  color: white;
  opacity: 0.9;
  font-weight: 500;
  transition: opacity 0.2s;
}

nav a:hover {
  opacity: 1;
  color: white;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn:hover {
  background: var(--secondary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: white;
}

.btn-primary {
  background: var(--primary);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Forms */
input, textarea, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text);
}

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

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--primary);
}

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

/* Lists */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Breadcrumbs */
.breadcrumb {
  padding: 1rem 0;
  font-size: 0.9rem;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--text-light);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span {
  margin: 0 0.5rem;
}

/* Footer */
footer {
  background: var(--text);
  color: white;
  padding: 3rem 0 1rem;
  margin-top: auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3 {
  color: white;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.footer-section a {
  color: rgba(255, 255, 255, 0.8);
  display: block;
  padding: 0.25rem 0;
  transition: color 0.2s;
}

.footer-section a:hover {
  color: white;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

/* Disclaimer */
.disclaimer {
  background: var(--warning);
  color: white;
  padding: 1rem;
  text-align: center;
  font-size: 0.9rem;
  margin-top: 2rem;
}

/* FAQ Section */
.faq-section {
  margin: 2rem 0;
}

.faq-item {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: var(--radius);
}

.faq-question {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.faq-answer {
  color: var(--text);
  line-height: 1.6;
}

/* Alert Boxes */
.alert {
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.alert-info {
  background: #bee5eb;
  color: #0c5460;
  border-left: 4px solid #17a2b8;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border-left: 4px solid #ffc107;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.alert-danger {
  background: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

/* Page Hero */
.page-hero {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 3rem 0;
  text-align: center;
}

.page-hero h1 {
  color: white;
  margin-bottom: 0.5rem;
}

.page-hero p {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-bottom: 0;
}

/* Related Terms */
.related-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.term-tag {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--bg-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.9rem;
  transition: var(--transition);
  text-decoration: none;
}

.term-tag:hover {
  background: var(--primary);
  color: white;
}

/* Calculators */
.calculator {
  background: var(--bg-light);
  padding: 2rem;
  border-radius: var(--radius);
  margin: 2rem 0;
}

.calculator-result {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-top: 1.5rem;
  border: 2px solid var(--success);
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to main content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 200;
}

.skip-link:focus {
  top: 0;
}

/* Print Styles */
@media print {
  header, footer, nav, .disclaimer, .btn, .no-print {
    display: none;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  html { font-size: 15px; }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }

  nav a {
    font-size: 0.9rem;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  table {
    font-size: 0.9rem;
  }

  th, td {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }

  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* High DPI Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimize for retina displays */
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Dark Mode Support (for future implementation) */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.p-5 { padding: 3rem; }

.bg-light { background: var(--bg-light); }
.bg-white { background: white; }
.bg-primary { background: var(--primary); color: white; }
.bg-secondary { background: var(--secondary); color: white; }

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-light { color: var(--text-light); }
.text-white { color: white; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }

.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }