/* Professional Theme 3.0 - Enhanced */
@layer base {
  :root {
    /* Dark Theme */
    --bg-primary: #0a0c0f;
    --bg-secondary: #121418;
    --bg-surface: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.05);
    --text-primary: #e2e8f0;
    --text-secondary: #ffffff;
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --accent-tertiary: #34d399;
    --border-light: rgba(255, 255, 255, 0.06);
    --color-primary: #3b82f6; /* Added from inline config */
    --color-secondary: #60a5fa; /* Added from inline config */
    --accent-primary-rgb: 59, 130, 246;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  }

  html[data-theme='light'] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-surface: #e9ecef;
    --bg-card-hover: #f1f3f5;
    --text-primary: #212529; /* A standard, very-dark-gray for better readability */
    --text-secondary: #495057; /* A standard dark gray for secondary text */
    --accent-primary: #0d6efd;
    --accent-secondary: #1a73e8;
    --accent-tertiary: #01865e;
    /* Added for better heading contrast in light mode */
    --accent-green: #047857; /* Tailwind green-700 */
    --accent-blue: #1d4ed8;  /* Tailwind blue-700 */
    --accent-purple: #6b21a8;/* Tailwind purple-700 */
    --border-light: rgba(0, 0, 0, 0.08);
    --color-primary: #0d6efd;
    --color-secondary: #1a73e8;
    --accent-primary-rgb: 13, 110, 253;
    --bg-primary-rgb: 248, 249, 250; /* Added for light theme header */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  }

  html,
  body {
    height: 100%;
    scroll-behavior: smooth;
  }

  body {
    font-family: Inter, ui-sans-serif, system-ui;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
  }

  /* Skip link visible on focus */
  .skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  .skip-link:focus {
    left: 16px;
    top: 12px;
    width: auto;
    height: auto;
    padding: 8px 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 8px;
    z-index: 60;
    outline: none;
  }

  /* For visually hiding elements while keeping them accessible to screen readers */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}

/* Light Mode Text Visibility Fixes */
/* Override Tailwind's static dark-theme-friendly colors in light mode */
html[data-theme='light'] .text-slate-200 {
  /* Make headings that are light in dark mode, dark in light mode for contrast */
  color: var(--text-primary);
}

html[data-theme='light'] .text-slate-300,
html[data-theme='light'] .text-slate-400,
html[data-theme='light'] .text-slate-500 {
  color: var(--text-secondary);
}

/* Light Mode Heading & Code Block Contrast Fixes */
html[data-theme='light'] .text-green-400 {
  color: var(--accent-green);
}
html[data-theme='light'] .text-blue-400 {
  color: var(--accent-blue);
}
html[data-theme='light'] .text-purple-400 {
  color: var(--accent-purple);
}

/* Override PrismJS light theme to match site design */
html[data-theme='light'] pre[class*="language-"] {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-light);
    box-shadow: none;
    text-shadow: none;
}

/* Ensure high contrast for buttons in light mode */
html[data-theme='light'] .btn-whatsapp {
  color: #000;
}

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

/* Enhanced Header & Navigation */
.site-header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(var(--bg-primary-rgb, 10, 12, 15), 0.8);
  transition: background-color 0.3s ease;
}

.nav-link {
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

/* Professional Search */
.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 12px 16px 12px 40px;
  border-radius: 12px;
  width: 100%;
  max-width: 320px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
}

/* Style for search bars inside a dedicated container, like on the tools page */
.search-container .search-input {
  background-color: var(--bg-primary);
}

html[data-theme='light'] .search-container .search-input {
  background-color: var(--bg-secondary);
}

.search-container .search-input:focus {
  box-shadow: none;
}

/* Form Inputs */
.form-input {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  width: 100%;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  margin-top: 0.25rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.3);
}

/* Enhanced Article Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  height: 100%;
  position: relative;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.card:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  padding: 0;
}

.card-thumb {
  aspect-ratio: 16/9;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(45deg, var(--bg-primary), var(--bg-secondary));
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.card-body {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: space-between;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
}

.card-desc {
  color: var(--text-secondary-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

.card-read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-top: 8px;
  transition: gap 0.2s ease;
}

.card-read-more .arrow {
  transition: transform 0.2s ease;
}

.card:hover .card-read-more {
  gap: 10px;
}
.card:hover .card-read-more .arrow {
  transform: translateX(4px);
}

/* Professional Tags */
.tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  color: var(--accent-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid var(--border-light);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid var(--border-light);
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.tag:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

/* Refined Code Blocks */
.code-block {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-light);
  padding: 20px;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 1.5rem 0;
  position: relative;
  overflow-x: auto; /* Add horizontal scroll on overflow */
}

.copy-code-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.copy-code-btn:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.copy-code-btn.copied {
  color: var(--accent-tertiary);
  border-color: var(--accent-tertiary);
}

/* Announcement Bar */
.announce-bar {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  padding: 10px 0;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.announce-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-surface);
  opacity: 0.95;
}

.announce-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.announce-text {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.announce-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.announce-dismiss {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
  padding: 4px;
  line-height: 1;
}

/* WhatsApp Button */
.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: #25D366;
  color: #000;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.btn-whatsapp:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  color: #000;
  box-shadow: var(--shadow-lg);
}

.btn-whatsapp svg {
  width: 20px;
  height: 20px;
}

/* Article Content */
.article-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.article-content h2 {
  font-size: 1.8rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--accent-secondary);
}

.article-content h3 {
  font-size: 1.4rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--accent-tertiary);
}

.article-content p {
  margin-bottom: 1.5rem;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.25rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

/* Breadcrumbs */
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.breadcrumb li a {
  color: var(--accent-secondary);
  text-decoration: none;
}

.breadcrumb li a:hover {
  text-decoration: underline;
}

.breadcrumb li:not(:last-child)::after {
  content: '/';
  margin: 0 0.5rem;
}

/* Responsive Tables */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin: 1.5rem 0;
}

.comparison-table {
  width: 100%;
  min-width: 600px; /* Ensures table has a minimum width to show scrollbar */
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  border: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
  text-align: left;
  color: var(--text-primary);
  white-space: nowrap; /* Prevent text wrapping in cells */
}

.comparison-table th {
  background-color: var(--bg-surface);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* Responsive Design */
@media (min-width: 768px) {
  .search-input {
    min-width: 300px;
  }
}

@media (max-width: 768px) {
  .announce-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 24px;
  }

  .announce-text {
    margin-bottom: 12px;
  }

  .card-thumb {
    aspect-ratio: 16/10;
  }

  .card-body {
    padding: 16px;
  }

  .container {
    padding: 0 16px;
  }

  .article-content {
    font-size: 1rem;
    line-height: 1.7;
  }

  .code-block {
    padding: 16px;
    font-size: 0.875rem; /* Slightly smaller font for mobile */
  }
}

/* Animation States */
.page-enter {
  opacity: 0;
  transform: translateY(8px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Focus States */
/* A more modern, accessible focus ring for interactive elements */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.2);
}

/* Mobile nav improvements */
#mobileNav {
  padding: 8px 0;
}

#mobileNav .nav-link {
  padding: 10px 12px;
  border-radius: 8px;
}

/* Loading States */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Print Styles */
@media print {
  .no-print {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .article-content {
    font-size: 12pt;
    line-height: 1.6;
  }
}

/* Footer styling - professional multi-column footer */
footer[role="contentinfo"],
.site-footer {
  background: var(--bg-secondary);
  transition: background-color 0.3s ease;
}

footer[role="contentinfo"] h5,
footer[role="contentinfo"] .font-mono {
  color: var(--text-primary);
}

footer[role="contentinfo"] .nav-link,
footer[role="contentinfo"] a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease, transform 0.12s ease;
}

footer[role="contentinfo"] .nav-link:hover,
footer[role="contentinfo"] a:hover {
  color: var(--accent-tertiary);
  transform: translateY(-2px);
}

footer[role="contentinfo"] .btn-whatsapp {
  padding: 10px 14px;
  border-radius: 10px;
}

/* Make footer columns stack cleanly on small screens */
@media (max-width: 768px) {
  footer[role="contentinfo"] .max-w-6xl {
    padding-left: 16px;
    padding-right: 16px;
  }

  footer[role="contentinfo"] .grid {
    gap: 18px;
  }
}

/* Small tweak for copyright row */
footer[role="contentinfo"] .border-t {
  border-top-color: var(--border-light);
}

@media print {
  .no-print {
    display: none;
  }

  body {
    background: white;
    color: black;
  }
}
