/* ===== CSS Custom Properties ===== */
:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --text-dim: #5a5a70;

  --accent: #7c5ce7;
  --accent-glow: rgba(124, 92, 231, 0.35);
  --accent-subtle: rgba(124, 92, 231, 0.12);
  --green: #34d399;
  --green-subtle: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --amber: #fbbf24;

  --chf-color: #fbbf24;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 4px 24px rgba(0,0,0,0.2);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem 4rem;

  /* Subtle radial gradient for depth */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(124, 92, 231, 0.08), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(52, 211, 153, 0.04), transparent);
}

/* ===== App Container ===== */
.app-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 0.5rem 0 0;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo h1 span {
  color: var(--accent);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== Converter Card ===== */
.converter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  transition: border-color 0.3s ease;
}

.converter-card:focus-within {
  border-color: var(--accent);
}

/* ===== Section Labels ===== */
.section-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ===== Amount Input ===== */
.amount-input-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.currency-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
}

.source-badge {
  background: var(--accent-subtle);
  color: var(--chf-color);
  border: 1px solid rgba(251, 191, 36, 0.3);
  min-width: 58px;
}

.amount-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  outline: none;
  color: var(--text);
  font-size: 2rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 0.25rem 0;
  width: 100%;
  transition: border-color 0.2s ease;
  -moz-appearance: textfield;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.amount-input:focus {
  border-color: var(--accent);
}

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

/* ===== Swap Button ===== */
.swap-row {
  display: flex;
  justify-content: center;
  position: relative;
}

.swap-row::before,
.swap-row::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 28px);
  height: 1px;
  background: var(--border);
}

.swap-row::before { left: 0; }
.swap-row::after  { right: 0; }

.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  z-index: 1;
}

.swap-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
}

.swap-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

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

/* ===== Currency Select ===== */
.currency-select-group {
  position: relative;
}

.currency-select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface-hover);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%238888a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.currency-select:hover {
  border-color: var(--accent);
}

.currency-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.currency-select option {
  background: var(--surface);
  color: var(--text);
}

/* ===== Result Section ===== */
.result-section {
  background: var(--surface-hover);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.result-section.has-value {
  border-color: rgba(52, 211, 153, 0.25);
  box-shadow: 0 0 30px rgba(52, 211, 153, 0.06);
}

.result-amount {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--green);
  line-height: 1.2;
  word-break: break-all;
  transition: color 0.3s ease;
}

.result-rate {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-weight: 500;
}

/* ===== Quick Buttons ===== */
.quick-section {
  margin-top: -0.25rem;
}

.quick-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-btn {
  flex: 1;
  min-width: 52px;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--text);
}

.quick-btn:active {
  transform: scale(0.96);
}

.quick-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  padding-top: 0.25rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-dot.online {
  background: var(--green);
  animation: none;
}

.status-dot.error {
  background: var(--red);
  animation: none;
}

.status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}

/* ===== Rates Grid ===== */
.rates-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rates-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.rates-sub {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.rate-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.rate-card {
  flex: 1;
  min-width: 90px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.rate-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

.rate-card:active {
  transform: scale(0.97);
}

.rate-card.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 16px var(--accent-glow);
}

.rate-card-currency {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.rate-card-flag {
  font-size: 1.2rem;
  margin-bottom: 0.15rem;
}

.rate-card-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 1rem 0 0;
}

.app-footer p {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--accent);
}

.rate-timestamp {
  margin-top: 0.1rem;
}

/* ===== Smooth Appear Animation ===== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.converter-card,
.rates-grid,
.app-footer {
  animation: fadeUp 0.5s ease both;
}

.rates-grid { animation-delay: 0.1s; }
.app-footer  { animation-delay: 0.2s; }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  body {
    padding: 1rem 0.75rem 2rem;
  }

  .converter-card {
    padding: 1.25rem;
  }

  .result-amount {
    font-size: 1.75rem;
  }

  .amount-input {
    font-size: 1.6rem;
  }

  .rate-cards {
    gap: 0.4rem;
  }

  .rate-card {
    min-width: 70px;
    padding: 0.65rem 0.5rem;
  }

  .rate-card-value {
    font-size: 0.8rem;
  }
}
