/* Ensure stable layout across all screen sizes */
body {
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode styles */
body.dark-mode {
  background-color: #000000;
  color: #ffffff;
}

/* Dark mode - Navigation */
body.dark-mode nav {
  background-color: #000000;
  color: #ffffff;
  border-bottom: 1px solid #333;
}

/* Dark mode - Sidebar */
body.dark-mode #sidebar {
  background-color: #0a0a0a;
  color: #ffffff;
  border-right: 1px solid #333;
}

body.dark-mode #sidebar .border-b {
  border-color: #333 !important;
}

body.dark-mode .sidebar-link {
  color: #ffffff;
}

body.dark-mode .sidebar-link:hover {
  background-color: #1a1a1a;
  color: #60a5fa;
}

/* Dark mode - Dropdowns */
body.dark-mode #search-dropdown,
body.dark-mode #language-dropdown {
  background-color: #0a0a0a;
  border-color: #333;
  color: #ffffff;
}

body.dark-mode .language-item {
  color: #ffffff;
}

body.dark-mode .language-item span {
  color: #ffffff !important;
}

body.dark-mode .language-item:hover {
  background-color: #1a1a1a;
}

/* Dark mode - Inputs */
body.dark-mode input {
  background-color: #1a1a1a;
  border-color: #333;
  color: #ffffff;
}

body.dark-mode input::placeholder {
  color: #888;
}

/* Dark mode - Sections */
body.dark-mode section {
  background-color: #000000 !important;
  color: #ffffff;
}

body.dark-mode .bg-gradient-to-br {
  background: #000000 !important;
}

body.dark-mode .bg-gray-50 {
  background-color: #0a0a0a !important;
}

/* Dark mode - Feature cards */
body.dark-mode .feature-card {
  background-color: #0a0a0a;
  border-color: #333;
  color: #ffffff;
}

body.dark-mode .feature-card:hover {
  border-color: #60a5fa;
  background-color: #1a1a1a;
}

body.dark-mode .feature-card h3 {
  color: #ffffff;
}

body.dark-mode .feature-card p {
  color: #d1d5db;
}

body.dark-mode .bg-blue-100 {
  background-color: #1e3a8a !important;
}

body.dark-mode .text-blue-600 {
  color: #60a5fa !important;
}

/* Dark mode - Text colors */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
  color: #ffffff;
}

body.dark-mode p,
body.dark-mode span,
body.dark-mode div {
  color: #ffffff;
}

body.dark-mode .text-gray-900 {
  color: #ffffff !important;
}

body.dark-mode .text-gray-800 {
  color: #f3f4f6 !important;
}

body.dark-mode .text-gray-700 {
  color: #e5e7eb !important;
}

body.dark-mode .text-gray-600 {
  color: #d1d5db !important;
}

body.dark-mode .text-gray-500 {
  color: #9ca3af !important;
}

body.dark-mode .text-gray-400 {
  color: #6b7280 !important;
}

body.dark-mode .text-gray-300 {
  color: #d1d5db !important;
}

body.dark-mode .text-gray-200 {
  color: #e5e7eb !important;
}

/* Dark mode - Buttons */
body.dark-mode button {
  color: inherit;
}

body.dark-mode .bg-blue-600 {
  background-color: #2563eb !important;
}

body.dark-mode .border-blue-600 {
  border-color: #2563eb !important;
}

body.dark-mode .text-blue-600 {
  color: #60a5fa !important;
}

/* Dark mode - Footer stays dark */
body.dark-mode footer {
  background-color: #0a0a0a;
  color: #ffffff;
  border-top: 1px solid #333;
}

/* Navigation bar stability */
nav {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Animated hamburger menu button */
#menu-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  z-index: 60;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

#menu-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode #menu-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

#menu-toggle span {
  display: block;
  width: 1.25rem;
  height: 2px;
  background-color: #374151;
  transition: all 0.3s ease;
  transform-origin: center;
}

body.dark-mode #menu-toggle span {
  background-color: #f5f5f5;
}

#menu-toggle.active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

#menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

#menu-toggle.active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Logo container - stable centering */
nav > div:has(img) {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
}

nav > div:has(img) img {
  height: 3rem;
  width: auto;
  max-width: 150px;
  object-fit: contain;
}

/* Right side buttons */
nav > div:last-child {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
  z-index: 60;
}

/* Dark mode toggle */
.icon-button {
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
  border: none;
  background: none;
}

.icon-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .icon-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
  color: #374151;
}

body.dark-mode .icon-button svg {
  color: #f5f5f5;
}

/* Search & Language dropdown positioning */
#search-dropdown,
#language-dropdown {
  position: absolute;
  right: 0;
  top: 3rem;
  z-index: 50;
  width: 320px;
  max-width: calc(100vw - 2rem);
}

#language-dropdown {
  max-height: 400px;
  overflow-y: auto;
}

/* Backdrop overlay for sidebar */
#sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 70;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 16rem;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 80;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  background-color: white;
}

body.dark-mode #sidebar {
  background-color: #16213e;
}

#sidebar.open {
  transform: translateX(0);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  color: #374151;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background-color: #f3f4f6;
  color: #2563eb;
  transform: translateX(4px);
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Language item hover effect */
.language-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-radius: 0.375rem;
}

.language-item:hover {
  background-color: #f3f4f6;
}

/* Currently selected language */
.language-item.active {
  background-color: #dbeafe;
  font-weight: 600;
}

.language-flag {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: cover;
}

/* Main content */
main {
  flex: 1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
}

/* Loader */
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 100;
}

.loader-spinner {
  border: 4px solid #f3f4f6;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Feature cards */
.feature-card {
  background-color: white;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.feature-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Footer */
footer {
  background-color: #1f2937;
  color: #f9fafb;
  margin-top: auto;
}

footer a {
  transition: color 0.2s ease;
}

footer a:hover {
  color: #3b82f6;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  nav > div:has(img) img {
    max-width: 200px;
  }
}

/* Shrink the centered logo on small screens so it never overlaps
   the hamburger / search / language / dark-mode / account buttons. */
@media (max-width: 767px) {
  nav {
    padding: 0.75rem 0.5rem;
  }

  nav > div:has(img) img {
    height: 2.25rem;
    max-width: 90px;
  }

  nav > div:last-child {
    gap: 0.25rem;
  }

  .icon-button {
    padding: 0.4rem;
  }

  #menu-toggle {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 420px) {
  nav {
    padding: 0.6rem 0.4rem;
  }

  nav > div:has(img) img {
    height: 2rem;
    max-width: 66px;
  }

  nav > div:last-child {
    gap: 0;
  }

  .icon-button {
    padding: 0.35rem;
  }
}

/* Prevent layout shift */
* {
  box-sizing: border-box;
}

/* Smooth transitions */
button {
  transition: background-color 0.2s ease;
}

/* Hide elements */
.hidden {
  display: none;
}

