/* frontend/css/style.css */

:root {
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 26, 0.8);
  --bg-card-hover: rgba(24, 24, 35, 0.9);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-input-focus: rgba(255, 255, 255, 0.08);
  --bg-dropdown: rgba(18, 18, 26, 0.95);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-tertiary: #55556a;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #06b6d4;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-dropdown: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --positive: #10b981;
  --negative: #ef4444;
  --chart-line: #6366f1;
  --chart-fill-start: rgba(99, 102, 241, 0.3);
  --chart-fill-end: rgba(99, 102, 241, 0.0);
  --chart-grid: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-input-focus: rgba(0, 0, 0, 0.06);
  --bg-dropdown: rgba(255, 255, 255, 0.98);
  --text-primary: #1a1a2e;
  --text-secondary: #64648a;
  --text-tertiary: #9494b0;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #0891b2;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.03) 100%);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 20px 60px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.1);
  --positive: #059669;
  --negative: #dc2626;
  --chart-line: #6366f1;
  --chart-fill-start: rgba(99, 102, 241, 0.15);
  --chart-fill-end: rgba(99, 102, 241, 0.0);
  --chart-grid: rgba(0, 0, 0, 0.06);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
}

.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.bg-orb--1 {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -200px;
  right: -200px;
  opacity: 0.15;
  animation-delay: 0s;
}

.bg-orb--2 {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: -100px;
  left: -100px;
  opacity: 0.12;
  animation-delay: -7s;
  animation-duration: 25s;
}

.bg-orb--3 {
  width: 300px;
  height: 300px;
  background: var(--accent-tertiary);
  top: 50%;
  left: 50%;
  opacity: 0.08;
  animation-delay: -14s;
  animation-duration: 30s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(50px, -30px) scale(1.05);
  }

  50% {
    transform: translate(-20px, 40px) scale(0.95);
  }

  75% {
    transform: translate(30px, 20px) scale(1.02);
  }
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--border-color) 1px, transparent 1px), linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, black 20%, transparent 70%);
}

.theme-toggle {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 100;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-card);
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.theme-toggle__icon {
  font-size: 1.2rem;
  transition: transform var(--transition-spring);
}

.theme-toggle:active .theme-toggle__icon {
  transform: scale(0.8);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.header {
  text-align: center;
  padding: var(--space-xl) 0;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-lg);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.header__title {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__subtitle {
  margin-top: var(--space-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.converter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: visible;
  animation: fadeInUp 0.6s ease-out 0.15s both;
  transition: box-shadow var(--transition-base);
}

.converter-card:hover {
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.input-group {
  margin-bottom: var(--space-md);
}

.input-group__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.input-group__row {
  display: flex;
  gap: var(--space-sm);
  align-items: stretch;
}

.currency-select {
  position: relative;
  flex-shrink: 0;
}

.currency-select__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--text-primary);
  font-family: var(--font-primary);
  height: 100%;
  min-width: 120px;
}

.currency-select__trigger:hover {
  background: var(--bg-input-focus);
  border-color: var(--accent-primary);
}

.currency-select__flag {
  font-size: 1.5rem;
  line-height: 1;
}

.currency-select__code {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.currency-select__arrow {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform var(--transition-base);
  margin-left: auto;
}

.currency-select.open .currency-select__arrow {
  transform: rotate(180deg);
}

.currency-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  backdrop-filter: blur(30px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all var(--transition-base);
}

.currency-select.open .currency-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.currency-dropdown__search {
  width: 100%;
  padding: var(--space-md);
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  outline: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.currency-dropdown__search::placeholder {
  color: var(--text-tertiary);
}

.currency-dropdown__list {
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-xs);
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.currency-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.85rem;
}

.currency-option:hover {
  background: var(--bg-input-focus);
}

.currency-option.selected {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}

.currency-option.featured {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, rgba(255, 165, 0, 0.05) 100%);
  border-left: 2px solid rgba(255, 215, 0, 0.4);
  font-weight: 600;
}

.currency-option.featured:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 165, 0, 0.08) 100%);
}

.currency-option.featured.selected {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
  border-left-color: var(--accent-primary);
}

.currency-option__flag {
  font-size: 1.2rem;
}

.currency-option__code {
  font-weight: 600;
  font-family: var(--font-mono);
  min-width: 36px;
}

.currency-option__name {
  color: var(--text-secondary);
  font-size: 0.8rem;
  flex: 1;
}

.currency-option__star {
  font-size: 0.7rem;
  margin-left: auto;
  opacity: 0.6;
}

.amount-input {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  text-align: right;
  outline: none;
  transition: all var(--transition-base);
  min-width: 0;
}

.amount-input:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.amount-input--result {
  color: var(--accent-primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.amount-input::placeholder {
  color: var(--text-tertiary);
}

.swap-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: var(--space-sm) auto;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--text-secondary);
  position: relative;
  z-index: 2;
}

.swap-button svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-spring);
}

.swap-button:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  transform: scale(1.1);
}

.swap-button:active svg {
  transform: rotate(180deg);
}

.rate-info {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.rate-info__rate {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.rate-info__rate strong {
  color: var(--text-primary);
  font-weight: 600;
}

.rate-info__meta {
  display: flex;
  gap: var(--space-md);
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.rate-info__cache {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.1);
  color: var(--positive);
  font-weight: 500;
}

.rate-info__loading {
  color: var(--text-tertiary);
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.chart-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.chart-header__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.period-selector {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
}

.period-btn {
  padding: var(--space-xs) var(--space-md);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
}

.period-btn:hover {
  color: var(--text-primary);
}

.period-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.chart-container {
  position: relative;
  height: 200px;
  margin-bottom: var(--space-lg);
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  transition: opacity var(--transition-base);
}

.chart-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.stat-card {
  padding: var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-card__label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
}

.stat-card__value {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.stat-card__value.positive {
  color: var(--positive);
}

.stat-card__value.negative {
  color: var(--negative);
}

.popular-section {
  animation: fadeInUp 0.6s ease-out 0.45s both;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.popular-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
}

.popular-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.popular-card__flags {
  font-size: 1.2rem;
  display: flex;
  gap: 2px;
}

.popular-card__pair {
  font-weight: 600;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.popular-card__rate {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.footer {
  text-align: center;
  padding: var(--space-xl) 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  animation: fadeInUp 0.6s ease-out 0.6s both;
}

.footer a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.footer a:hover {
  opacity: 0.8;
}

.footer__tech {
  margin-top: var(--space-xs);
  font-size: 0.65rem;
  opacity: 0.6;
}

@media (max-width: 480px) {
  .container {
    padding: var(--space-lg) var(--space-md);
  }

  .converter-card {
    padding: var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .popular-grid {
    grid-template-columns: 1fr;
  }

  .input-group__row {
    flex-direction: column;
  }

  .currency-select__trigger {
    min-width: unset;
  }

  .amount-input {
    text-align: left;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.number-animate {
  display: inline-block;
  transition: all var(--transition-base);
}

.number-animate.updating {
  transform: translateY(-4px);
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}