/* ============================================
   BASE RESET & ROOT VARIABLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  font-size: 10px;

  /* Colors */
  --color-bg: #f0f2f5;
  --color-white: #ffffff;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-text-dark: #0f1a2e;
  --color-text-medium: #374151;
  --color-text-light: #6b7280;
  --color-text-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-input-bg: #f3f5f8;
  --color-card-bg: #f8f9fb;
  --color-error: #ef4444;
  --color-error-bg: #fef2f2;
  --color-success: #10b981;

  /* Spacing */
  --gap-xs: 0.4rem;
  --gap-sm: 0.8rem;
  --gap-md: 1.6rem;
  --gap-lg: 2.4rem;
  --gap-xl: 3.2rem;
  --gap-xxl: 4.8rem;

  /* Rounded */
  --radius-sm: 0.8rem;
  --radius-md: 1.2rem;
  --radius-lg: 1.6rem;
  --radius-xl: 2rem;
  --radius-round: 50%;

  /* Shadows */
  --shadow-card: 0 0.4rem 2.4rem rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 0.8rem 3.2rem rgba(0, 0, 0, 0.1);
  --shadow-btn: 0 0.4rem 1.6rem rgba(37, 99, 235, 0.35);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}

/* ============================================
   TYPOGRAPHY & GLOBAL
   ============================================ */
html, body {
  min-height: 100vh;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.6rem;
  background-color: var(--color-bg);
  color: var(--color-text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LAYOUT
   ============================================ */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: var(--gap-xl) var(--gap-md);
}

.container {
  max-width: 80rem;
  margin: 0 auto;
}

/* ============================================
   HEADER / HERO
   ============================================ */
.hero {
  text-align: center;
  margin-bottom: var(--gap-xl);
}

.hero__title {
  font-size: 3.8rem;
  font-weight: 800;
  color: var(--color-text-dark);
  line-height: 1.2;
  margin-bottom: var(--gap-sm);
  letter-spacing: -0.05rem;
}

.hero__subtitle {
  font-size: 1.6rem;
  color: var(--color-text-light);
  max-width: 50rem;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============================================
   CONVERTER CARD
   ============================================ */
.converter-card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: var(--gap-xl);
  box-shadow: var(--shadow-card);
  border-top: 0.4rem solid var(--color-primary);
  position: relative;
  margin-bottom: var(--gap-lg);
}

/* ============================================
   ERROR / ALERT MESSAGES
   ============================================ */
.alert {
  display: none;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap-md);
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: var(--gap-md);
}

.alert--error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 0.1rem solid #fecaca;
}

.alert--warning {
  background: #fffbeb;
  color: #d97706;
  border: 0.1rem solid #fde68a;
}

.alert.is-visible {
  display: flex;
}

.alert__icon {
  flex-shrink: 0;
  font-size: 1.6rem;
}

/* ============================================
   FORM FIELDS
   ============================================ */
.form-row {
  display: grid;
  grid-template-columns: 55% 1fr; /* Aumentado un 10% extra (45% + 10% = 55%) */
  gap: var(--gap-md);
  margin-bottom: var(--gap-md);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
}

.field__label {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  color: var(--color-text-light);
}

.field__input-group {
  display: flex;
  align-items: center;
  background: var(--color-input-bg);
  border-radius: var(--radius-md);
  border: 0.15rem solid transparent;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
  height: 100%; /* Obliga a que ambas cajas grises tengan la misma altura exacta */
}

.field__input-group:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.3rem rgba(37, 99, 235, 0.12);
}

.field__input {
  flex: 1 1 75%;
  padding: 1.4rem 1.6rem;
  font-size: 2.4rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--color-text-dark);
  background: transparent;
  border: none;
  border-right: 0.1rem solid var(--color-border);
  outline: none;
  min-width: 0;
}

.field__input::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 1.8rem;
}

/* Eliminar flechas del input number */
.field__input[type="number"]::-webkit-inner-spin-button,
.field__input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field__input[type="number"] {
  -moz-appearance: textfield;
}

.field__select-group {
  flex: 1 1 25%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.4rem 1.2rem;
}

.field__select {
  appearance: none;
  background: var(--color-white);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-size: 1.3rem; 
  font-weight: 700;
  font-family: inherit;
  padding: 0.6rem 2.2rem 0.6rem 0.8rem;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.2rem;
  transition: background-color var(--transition-fast);
  width: 100%; /* Expandido dentro de su propio contenedor */
}

.field__select:hover {
  background-color: var(--color-primary-light);
}

/* Destination field: text placeholder */
.field__destination-text {
  flex: 1 1 75%;
  padding: 1.4rem 1.6rem;
  font-size: 1.3rem;
  color: var(--color-text-muted);
  font-family: inherit;
  user-select: none;
  border-right: 0.1rem solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   SWAP BUTTON
   ============================================ */
.swap-wrapper {
  display: flex;
  justify-content: center;
  margin: var(--gap-sm) 0 var(--gap-md);
}

.btn-swap {
  width: 4.8rem;
  height: 4.8rem;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-btn);
  transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--color-white);
}

.btn-swap:hover {
  background: var(--color-primary-dark);
  transform: translateY(-0.2rem);
  box-shadow: 0 0.8rem 2.4rem rgba(37, 99, 235, 0.45);
}

.btn-swap:active {
  transform: translateY(0);
}

.btn-swap svg {
  width: 2rem;
  height: 2rem;
  transition: transform var(--transition-base);
}

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

/* ============================================
   DIVIDER
   ============================================ */
.divider {
  height: 0.1rem;
  background: var(--color-border);
  margin: var(--gap-md) 0;
}

/* ============================================
   RESULT AREA
   ============================================ */
.result-area {
  text-align: center;
  padding: var(--gap-md) 0;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-label {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-sm);
}

.result-label__dots {
  display: flex;
  gap: 0.4rem;
}

.result-label__dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: var(--radius-round);
  background: var(--color-primary);
  opacity: 0.3;
}

.result-label__dot:first-child {
  opacity: 1;
}

.result-label__dot:nth-child(2) {
  opacity: 0.6;
}

.result-label__text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12rem;
  text-transform: uppercase;
  color: var(--color-primary);
}

.result-value {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: var(--gap-sm);
}

.result-value__amount {
  font-size: 5.6rem;
  font-weight: 800;
  color: var(--color-text-dark);
  letter-spacing: -0.1rem;
  line-height: 1;
}

.result-value__currency {
  font-size: 5.6rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.result-detail {
  font-size: 1.4rem;
  color: var(--color-text-light);
}

.result-placeholder {
  color: var(--color-text-muted);
  font-size: 1.6rem;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */
.loading-indicator {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-md) 0;
}

.loading-indicator.is-visible {
  display: flex;
}

.spinner {
  width: 3.2rem;
  height: 3.2rem;
  border: 0.3rem solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-round);
  animation: spin 0.8s linear infinite;
}

.loading-indicator__text {
  font-size: 1.4rem;
  color: var(--color-text-light);
}

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

/* ============================================
   TRANSFER BUTTON
   ============================================ */
.btn-transfer {
  display: block;
  width: 100%;
  padding: 1.8rem;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 1.6rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.02rem;
  box-shadow: var(--shadow-btn);
  transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  margin-top: var(--gap-md);
}

.btn-transfer:hover {
  background: var(--color-primary-dark);
  transform: translateY(-0.2rem);
  box-shadow: 0 0.8rem 2.4rem rgba(37, 99, 235, 0.45);
}

.btn-transfer:active {
  transform: translateY(0);
}

.btn-transfer:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================
   HISTORY SECTION
   ============================================ */
.history-section {
  margin-top: var(--gap-lg);
}

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

.btn-history {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.8rem 1.6rem;
  background: var(--color-white);
  border: 0.15rem solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text-medium);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn-history:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-history svg {
  width: 1.6rem;
  height: 1.6rem;
}

.history-title-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  color: var(--color-text-light);
}

/* History slider wrapper */
.history-carousel-wrapper {
  display: none;
  position: relative;
  width: 100%;
  animation: fadeInUp 0.3s ease;
  align-items: center;
  gap: var(--gap-sm);
}

.history-carousel-wrapper.is-visible {
  display: flex;
}

.history-carousel-mask {
  overflow: hidden;
  width: 100%;
}

.history-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--gap-md);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Botones del slider */
.btn-slider {
  background: var(--color-white);
  color: var(--color-primary);
  border: 0.1rem solid var(--color-border);
  box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.05);
  border-radius: 50%;
  width: 4.4rem;
  height: 4.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  z-index: 2;
}

.btn-slider:hover:not(:disabled) {
  background: var(--color-primary-light);
  transform: scale(1.05);
}

.btn-slider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: var(--color-text-muted);
}

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

/* ============================================
   HISTORY CARD
   ============================================ */
.history-card {
  flex: 0 0 calc((100% - (2 * var(--gap-md))) / 3);
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  position: relative;
  overflow: hidden;
}

.history-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-0.2rem);
}

.history-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
}

.history-card__icon {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-sm);
  background: var(--color-card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.history-card__date {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.history-card__amount {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--color-text-dark);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.history-card__from {
  font-size: 1.3rem;
  color: var(--color-text-light);
}

.history-card__from span {
  font-weight: 600;
  color: var(--color-text-medium);
}

/* Empty history message */
.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--gap-xl);
  color: var(--color-text-muted);
  font-size: 1.5rem;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  padding: var(--gap-lg) var(--gap-md);
  border-top: 0.1rem solid var(--color-border);
  margin-top: auto;
}

.footer-inner {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-md);
}

.footer-copyright {
  font-size: 1.3rem;
  color: var(--color-text-muted);
}

.footer-links {
  display: flex;
  gap: var(--gap-lg);
  list-style: none;
}

.footer-links a {
  font-size: 1.3rem;
  color: var(--color-text-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-primary);
}

/* ============================================
   STATUS / OFFLINE BADGE
   ============================================ */
.status-badge {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  font-weight: 600;
  position: absolute;
  top: var(--gap-md);
  right: var(--gap-md);
}

.status-badge.is-visible {
  display: inline-flex;
}

.status-badge--offline {
  background: #fffbeb;
  color: #d97706;
  border: 0.1rem solid #fde68a;
}

.status-badge__dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: var(--radius-round);
  background: currentColor;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 64rem) {
  .hero__title {
    font-size: 3rem;
  }

  .result-value__amount,
  .result-value__currency {
    font-size: 4.4rem;
  }

  .history-card {
    flex: 0 0 calc((100% - var(--gap-md)) / 2);
  }
}

@media (max-width: 48rem) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .hero__title {
    font-size: 2.4rem;
  }

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

  .history-card {
    flex: 0 0 100%;
  }

  .result-value__amount,
  .result-value__currency {
    font-size: 3.6rem;
  }

  .status-badge {
    position: static;
    margin-bottom: var(--gap-md);
  }
}

@media (max-width: 32rem) {
  .main-content {
    padding: var(--gap-lg) var(--gap-sm);
  }

  .converter-card {
    padding: var(--gap-md);
  }
}
