/* Modern Documentation-Style Theme */
:root {
  /* Light theme - Clean and professional */
  --bg: #ffffff;
  --fg: #1a1a1a;
  --header-bg: #ffffff;
  --header-shadow: rgba(0, 0, 0, 0.08);
  --list-bg: #f8f9fa;
  --card-bg: #ffffff;
  --footer-bg: #f8f9fa;
  --link-color: #2563eb;
  --border-color: #e5e7eb;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
}

.dark-theme {
  /* Modern Dark Theme - Documentation inspired */
  --bg: #0f172a;           /* Deep navy background */
  --fg: #f1f5f9;           /* Light text */
  --header-bg: #1e293b;    /* Dark header */
  --header-shadow: rgba(0, 0, 0, 0.3);
  --list-bg: #1e293b;      /* Card/list background */
  --card-bg: #1e293b;      /* Card background */
  --footer-bg: #0f172a;    /* Footer background */
  --link-color: #3b82f6;   /* Blue links */
  --border-color: #334155; /* Subtle borders */
  --text-secondary: #94a3b8; /* Secondary text */
  --text-muted: #64748b;   /* Muted text */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --code-bg: #1e293b;      /* Code blocks background */
  --blockquote-bg: #1e293b; /* Blockquotes background */
  --hover-bg: #334155;     /* Hover states */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.7;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  background: var(--header-bg);
  color: var(--fg);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 60px;
  display: flex;
  align-items: center;
}

/* Header title removed - navigation is now centered */

nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 0;
  flex: 1;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
}

nav a:hover {
  color: var(--link-color);
  background: var(--list-bg);
  text-decoration: none;
}

nav a.active {
  color: var(--link-color);
  background: var(--list-bg);
}

/* Ensure all links use the theme link color */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

.hidden {
  display: none;
}

section {
  margin-bottom: 3rem;
}

/* Hero section styling */
.hero {
  text-align: center;
  padding: 4rem 0;
  background: linear-gradient(135deg, var(--bg) 0%, var(--list-bg) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--link-color), var(--fg));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* Modern card-based layout */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

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

.card h3 {
  margin-top: 0;
  color: var(--fg);
  font-size: 1.25rem;
  font-weight: 600;
}

.card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.card .date {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

li:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--link-color);
  transform: translateY(-1px);
}

li:last-child {
  margin-bottom: 0;
}

/* Modern button styling */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--link-color);
  color: white;
}

.btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--link-color);
  border-color: var(--link-color);
}

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

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

/* Footer styling */
footer {
  background: var(--footer-bg);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0 1rem;
  margin-top: 4rem;
}

footer .container {
  text-align: center;
}

footer p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.875rem;
}

/* Page transition styles */
.page-transition {
  opacity: 0;
  animation: fadeIn 0.5s ease-in-out forwards;
}

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

/* Scroll to Top Button */
#scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--header-bg);
  color: var(--fg);
  border: 2px solid var(--link-color);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

#scroll-to-top:hover {
  background: var(--link-color);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
}

#scroll-to-top:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Enhanced dark theme shadows */
.dark-theme #scroll-to-top {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
}

.dark-theme #scroll-to-top:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.8);
}

.dark-theme #scroll-to-top:active {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Enhanced styling for Darcula theme */
.dark-theme {
  /* Code blocks styling */
  --code-bg: #3c3f41;
  --code-border: #555555;
}

.dark-theme pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
}

.dark-theme code {
  background: var(--code-bg);
  color: #e6db74; /* Yellow-green for code */
  padding: 2px 4px;
  border-radius: 3px;
}

.dark-theme a:hover {
  color: #5ab4fc; /* Lighter blue on hover */
}

.dark-theme li:hover {
  background: var(--hover-bg);
  transition: background-color 0.2s ease;
}

.dark-theme button {
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  color: var(--fg);
}

.dark-theme button:hover {
  background: var(--hover-bg);
  border-color: var(--link-color);
}

/* Blockquotes styling for dark theme */
.dark-theme blockquote {
  background: var(--blockquote-bg);
  border-left: 4px solid var(--link-color);
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 0 4px 4px 0;
}

/* Card Actions Layout */
.card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.card-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  color: var(--fg);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--hover-bg);
  color: var(--fg);
}

.modal-body {
  padding: 1.5rem;
  color: var(--fg);
  line-height: 1.6;
}

.modal-body h4,
.modal-body h5,
.modal-body h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--fg);
}

.modal-body p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: var(--list-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

.modal-body th {
  background: var(--header-bg);
  font-weight: 600;
  color: var(--fg);
}

.modal-body code {
  background: var(--code-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
}

.modal-body pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1rem 0;
}

.loading {
  text-align: center;
  font-size: 2rem;
  padding: 2rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-content {
    max-height: 90vh;
    margin: auto;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .card-actions {
    flex-direction: column;
  }

  .card-actions .btn {
    width: 100%;
  }
}

/* Smooth transition for theme changes */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Mobile Navigation - Hamburger Menu */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-menu-toggle:focus {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
  /* Typography adjustments for mobile */
  body {
    font-size: 14px;
    line-height: 1.6;
  }

  /* Mobile header */
  header {
    padding: 0.5rem 0;
  }

  nav {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 1rem 0;
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    box-shadow: var(--shadow-md);
    z-index: 1000; /* Higher z-index to appear above other content */
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  nav.mobile-open {
    display: flex !important;
    animation: slideDown 0.3s ease-out;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  nav a {
    padding: 1rem;
    width: 100%;
    text-align: center;
    border-radius: 0;
    margin: 0;
  }

  nav a:hover {
    background: var(--hover-bg);
  }

  /* Ensure header has proper height for hamburger button */
  header {
    position: relative;
    min-height: 60px; /* Accommodates 44px button + padding */
    display: flex;
    align-items: center;
    overflow: visible;
  }

  .mobile-menu-toggle {
    display: block;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 101;
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-menu-toggle:hover {
    background: var(--hover-bg);
    transform: translateY(-50%) scale(1.05);
  }

  .mobile-menu-toggle:active {
    transform: translateY(-50%) scale(0.95);
  }

  /* Mobile main content */
  main {
    padding: 1rem 0.5rem;
  }

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

  /* Mobile hero section */
  .hero {
    padding: 2rem 1rem;
    margin-bottom: 2rem;
    border-radius: var(--radius-md);
  }

  .hero h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
  }

  .hero p {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  /* Mobile card grid */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card {
    padding: 1rem;
  }

  /* Mobile buttons */
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    box-sizing: border-box;
    min-height: 44px;
    font-size: 16px;
    padding: 0.875rem 1rem;
  }

  /* Ensure buttons don't overflow */
  .btn, .btn-secondary {
    max-width: 100%;
    word-wrap: break-word;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Fix button containers */
  .hero > div,
  .card .btn,
  .card .btn-secondary {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Language and theme selectors */
  select {
    max-width: 100%;
    font-size: 16px;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--fg);
  }

  /* Mobile language/theme selectors */
  select {
    font-size: 14px;
    padding: 0.5rem;
  }

  /* Mobile footer */
  footer {
    padding: 1.5rem 1rem;
    text-align: center;
  }

  /* Mobile scroll to top button */
  #scroll-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
}

/* General overflow prevention */
* {
  box-sizing: border-box;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Prevent horizontal overflow but allow vertical for dropdowns */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Ensure all content stays within viewport except header dropdown */
main, .container, .hero, .card, .card-grid {
  max-width: 100%;
  overflow-x: hidden;
}

/* Header should allow dropdown overflow */
header {
  overflow: visible !important;
}

/* Extra small devices (iPhone 5 and similar - 320px) */
@media (max-width: 480px) {
  body {
    font-size: 13px;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.9rem;
  }

  .card h3 {
    font-size: 1.1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .card p {
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Ensure card content doesn't overflow */
  .card {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Stack buttons vertically on very small screens */
  .hero > div {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    padding: 0 0.5rem;
    box-sizing: border-box;
    gap: 0.75rem;
  }

  /* Ensure hero content doesn't overflow */
  .hero h1, .hero p {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 0;
    margin-left: auto;
    margin-right: auto;
  }

  /* Specific button fixes for hero section */
  .hero .btn, .hero .btn-secondary {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    display: block;
    text-align: center;
  }

  /* Adjust navigation for very small screens */
  nav a {
    padding: 0.75rem;
    font-size: 14px;
  }

  /* Smaller scroll button for tiny screens */
  #scroll-to-top {
    width: 40px;
    height: 40px;
    font-size: 16px;
    right: 0.5rem;
    bottom: 0.5rem;
  }

  /* Ensure scroll button doesn't cause overflow */
  #scroll-to-top {
    position: fixed;
    z-index: 1000;
    max-width: 50px;
    max-height: 50px;
  }
}

/* Tablet and small desktop adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  main {
    padding: 2rem;
  }
}

/* Large desktop adjustments */
@media (min-width: 1200px) {
  .hero h1 {
    font-size: 3.5rem;
  }

  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Print styles */
@media print {
  .mobile-menu-toggle,
  #scroll-to-top,
  nav select {
    display: none !important;
  }

  nav {
    display: flex !important;
    flex-direction: row !important;
    position: static !important;
    box-shadow: none !important;
    border: none !important;
  }

  nav a {
    padding: 0.25rem 0.5rem !important;
  }

  .hero {
    background: white !important;
    color: black !important;
  }

  .hero h1 {
    background: none !important;
    -webkit-text-fill-color: black !important;
    color: black !important;
  }
}
