:root {
  --bg-primary: hsl(220, 20%, 97%);
  --bg-secondary: hsl(0, 0%, 100%);
  --text-primary: hsl(222, 47%, 11%);
  --text-secondary: hsl(215, 16%, 47%);
  --accent: hsl(262, 80%, 50%);
  --accent-hover: hsl(262, 80%, 40%);
  --border-color: hsl(220, 15%, 90%);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: hsl(222, 47%, 6%);
    --bg-secondary: hsl(222, 47%, 10%);
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --accent: hsl(262, 80%, 60%);
    --accent-hover: hsl(262, 80%, 50%);
    --border-color: hsl(222, 20%, 18%);
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.dashboard-error-banner {
  color: #dc2626;
  font-size: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(220, 38, 38, 0.45);
  background: rgba(220, 38, 38, 0.08);
  border-radius: 12px;
  margin-block-end: 1rem;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 2000;
  background: var(--accent);
  color: #ffffff;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:where(:not(:focus-visible, :focus-within, :active)) {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  padding: clamp(1rem, 2.5vw, 2.5rem) clamp(0.875rem, 3vw, 2rem);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image: radial-gradient(circle at 50% -20%, hsl(262, 80%, 90%), transparent 60%);
}
@media (prefers-color-scheme: dark) {
  body {
    background-image: radial-gradient(circle at 50% -20%, hsl(262, 80%, 20%), transparent 60%);
  }
}

.container {
  max-inline-size: 1160px;
  inline-size: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

/* Header and Navigation */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
  width: 100%;
  background: transparent !important;
}
.header-logo {
  height: 32px !important;
  display: block;
  transition: height 0.2s ease;
}
.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.nav-links form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.nav-btn {
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-primary);
  padding: 0.5rem 0.9rem;
  margin: 0;
  min-block-size: 40px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.2;
  transition: all 0.2s ease;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  touch-action: manipulation;
}
.nav-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.nav-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.nav-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Language toggle button styles */
.lang-toggle-container {
  display: inline-flex;
  background: rgba(147, 51, 234, 0.06);
  border: 1px solid rgba(147, 51, 234, 0.15);
  padding: 3px;
  border-radius: 12px;
  align-items: center;
  gap: 2px;
  min-block-size: 40px;
}
.lang-toggle-btn {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.45rem 0.65rem;
  border-radius: 9px;
  transition: all 150ms ease;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lang-toggle-btn.active {
  background: hsl(262, 80%, 60%) !important;
  color: #fff !important;
}
.lang-toggle-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Common animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile adaptation for headers */
@media (max-width: 767px) {
  .app-header {
    padding: 0.5rem 0 0.75rem;
  }
  .header-logo {
    height: 28px !important;
  }
  .nav-btn {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    min-inline-size: 40px;
  }
  .nav-btn-text {
    display: none;
  }
  .nav-links {
    gap: 0.4rem;
  }
  .lang-toggle-btn {
    padding: 0.4rem 0.55rem;
  }
}
@media (pointer: coarse) {
  .nav-btn,
  .lang-toggle-container {
    min-block-size: 44px;
  }
}

/* Flash Alerts & Toast Notifications */
.flash-alert {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
  right: max(1.5rem, env(safe-area-inset-right, 1.5rem));
  left: auto;
  transform: translateY(0) scale(1);
  width: 380px;
  max-width: calc(100vw - 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 12px;
  z-index: 99999;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.4), 0 4px 12px -2px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: flashSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
  cursor: pointer;
  box-sizing: border-box;
}

.flash-alert > span,
.flash-alert .flash-message {
  flex: 1;
  min-width: 0;
}

.flash-success {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #10b981;
  font-weight: 500;
}

.flash-error {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  font-weight: 500;
}

.flash-close-btn,
.flash-alert button,
.flash-alert .close-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.35rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  touch-action: manipulation;
}

.flash-close-btn:hover,
.flash-alert button:hover,
.flash-alert .close-btn:hover,
.flash-close-btn:focus-visible,
.flash-alert button:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

@keyframes flashSlideIn {
  from {
    transform: translateY(1rem) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
  .flash-alert {
    bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
    right: max(1rem, env(safe-area-inset-right, 1rem));
    left: auto;
    width: calc(100vw - 2rem);
    max-width: 360px;
    padding: 0.85rem 1.15rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 400px) {
  .flash-alert {
    right: max(0.75rem, env(safe-area-inset-right, 0.75rem));
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
    width: calc(100vw - 1.5rem);
    max-width: calc(100vw - 1.5rem);
    border-radius: 10px;
  }
}

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