/* ===== Currency Converter Styles ===== */

:root {
  --bg: #fafaf5;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.07);

  --usd: #0d9488;
  --usd-soft: #14b8a6;
  --usd-bg: #f0fdfa;
  --usd-border: #99f6e4;

  --dop: #c2410c;
  --dop-soft: #ea580c;
  --dop-bg: #fff7ed;
  --dop-border: #fed7aa;

  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-card: #111827;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    --border: #1f2937;
    --border-strong: #334155;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.3);

    --usd-bg: rgba(20, 184, 166, 0.08);
    --usd-border: rgba(20, 184, 166, 0.3);

    --dop-bg: rgba(234, 88, 12, 0.08);
    --dop-border: rgba(234, 88, 12, 0.3);
  }
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 0.75rem;
  padding-bottom: env(safe-area-inset-bottom);
}

.converter {
  max-width: 560px;
  margin: 0 auto;
  padding: 0.5rem 0 2rem;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 1.5rem 0 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.flag {
  font-size: 1.6rem;
  line-height: 1;
  display: inline-block;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

.brand-divider {
  color: var(--text-muted);
  font-weight: 300;
  font-size: 1.2rem;
}

h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ===== Rate status card ===== */
.rate-status {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  gap: 0.25rem;
}

.rate-main {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.rate-main strong {
  color: var(--text);
  font-weight: 700;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.rate-secondary {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.rate-secondary-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
  font-weight: 600;
}

.rate-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

#rateUpdated { flex: 1; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.status-dot.stale {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.status-dot.loading {
  background: var(--text-subtle);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-refresh {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-refresh:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-refresh:active {
  background: var(--border);
}

.btn-refresh.spinning svg { animation: spin 0.9s linear infinite; }

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

/* ===== Inputs ===== */
.inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  position: relative;
  margin: 1.5rem 0 1rem;
}

.field {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  position: relative;
  z-index: 1;
}

.field-usd {
  border-color: var(--usd-border);
  background: var(--usd-bg);
}

.field-dop {
  border-color: var(--dop-border);
  background: var(--dop-bg);
}

.field:focus-within {
  box-shadow: var(--shadow-lg);
  z-index: 2;
}

.field-usd:focus-within { border-color: var(--usd); }
.field-dop:focus-within { border-color: var(--dop); }

.field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.field-flag {
  font-size: 1.1rem;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

.field-code {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}

.field-name {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-symbol {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.field-usd .field-symbol { color: var(--usd); }
.field-dop .field-symbol { color: var(--dop); }

.field input {
  flex: 1;
  border: none;
  background: none;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  outline: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}

.field input::placeholder {
  color: var(--text-subtle);
  font-weight: 500;
}

/* Hide spinner on number inputs */
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-clear:hover {
  background: var(--bg);
  color: var(--text);
}

/* ===== Chips ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
  justify-content: center;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  background: var(--usd-bg);
  border-color: var(--usd-border);
  color: var(--usd);
}

.chip:active {
  transform: scale(0.95);
}

/* ===== Quick table ===== */
.quick-table {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.quick-table h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.quick-table table {
  width: 100%;
  border-collapse: collapse;
}

.quick-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.quick-table th:last-child { text-align: right; }

.quick-table td {
  padding: 0.45rem 0;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.quick-table td:first-child { color: var(--text); font-weight: 500; }
.quick-table td:last-child {
  text-align: right;
  color: var(--dop);
  font-weight: 600;
}

.quick-table tr:last-child td { border-bottom: none; }

/* ===== Tips ===== */
.tips {
  margin-bottom: 2rem;
}

.tips h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-weight: 700;
  padding-left: 0.25rem;
}

.tip-cards {
  display: grid;
  gap: 0.6rem;
}

.tip-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.tip-card h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tip-card p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ===== Footer ===== */
.foot {
  text-align: center;
  padding: 1rem 0 1.5rem;
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.foot p { margin: 0.25rem 0; }
.foot a {
  color: var(--text-muted);
  text-decoration: none;
}
.foot a:hover {
  text-decoration: underline;
  color: var(--text);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
  max-width: calc(100vw - 2rem);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (min-width: 560px) {
  body { padding: 1.5rem; }
  h1 { font-size: 2.1rem; }
  .field input { font-size: 1.9rem; }
  .tip-cards { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 800px) {
  .converter { max-width: 640px; }
  h1 { font-size: 2.25rem; }
  .field input { font-size: 2rem; }
  .tip-cards { grid-template-columns: 1fr 1fr 1fr; }
}

/* ===== iOS zoom fix (inputs must be ≥16px to prevent auto-zoom) ===== */
@supports (-webkit-touch-callout: none) {
  .field input { font-size: 16px; }
}

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