:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text: #1a1a1a;
  --subtext: #6b7280;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* ===== LAYOUT ===== */
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 10px;
}

main {
  width: 100%;
  max-width: 420px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ===== HEADER ===== */
header {
  text-align: center;
}


/* ===== CARD ===== */
.converter {
  width: 100%;
  background: var(--card);
  padding: 20px;
  border-radius: 14px;

  box-shadow: 0 6px 16px rgba(0,0,0,0.05);

  /* animación entrada */
  animation: fadeIn 0.4s ease;
}

/* ===== INPUTS ===== */
input, select {
  width: 100%;
  padding: 12px;
  margin-top: 10px;

  border-radius: 10px;
  border: 1px solid var(--border);

  font-size: 15px;
  background: #fff;

  transition: all 0.2s ease;
}

input:hover, select:hover {
  border-color: #c7d2fe;
}

input:focus, select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}

/* ===== SELECTORES ===== */
.selectors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

/* ===== BOTÓN SWAP ===== */
#swap {
  width: 42px;
  height: 42px;

  border-radius: 50%;
  border: none;

  background: var(--primary);
  color: #fff;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: all 0.25s ease;
}

#swap:hover {
  background: var(--primary-hover);
  transform: rotate(180deg) scale(1.05);
}

#swap:active {
  transform: scale(0.95);
}

/* ===== RESULTADO ===== */
#result {
  margin-top: 16px;
  padding-top: 12px;

  border-top: 1px solid var(--border);

  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;

  transition: all 0.25s ease;
}

/* 🔥 animación cuando cambia */
#result.updated {
  animation: pop 0.3s ease;
}

#rate, #updated {
  font-size: 0.85rem;
  color: var(--subtext);
  text-align: center;
  margin-top: 4px;
}

/* ===== MENSAJES ===== */
.error {
  text-align: center;
  margin-top: 8px;
  font-size: 0.85rem;
  color: #dc2626;
}

.hidden {
  display: none;
}


/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.96);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card: #111827;
    --text: #e5e7eb;
    --subtext: #9ca3af;
    --border: #1f2937;
  }

  body {
    background: var(--bg);
    color: var(--text);
  }

  .converter {
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  }

  input, select {
    background: #020617;
    color: var(--text);
    border: 1px solid var(--border);
  }

  input:hover, select:hover {
    border-color: #6366f1;
  }


}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  body {
    align-items: flex-start;
    padding-top: 20px;
  }

  .converter {
    padding: 18px;
  }

  h1 {
    font-size: 1.3rem;
  }
}