/* ════════════════════════════════════════════
   WCURRENCY – Design System
   ════════════════════════════════════════════ */

:root {
  --primary:        #2563EB;
  --primary-hover:  #1D4ED8;
  --primary-bg:     #EFF6FF;
  --primary-border: #BFDBFE;

  --accent:  #7C3AED;
  --success: #059669;
  --warning: #D97706;
  --danger:  #DC2626;

  --bg:        #F1F5F9;
  --surface:   #FFFFFF;
  --surface-2: #F8FAFC;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;

  --text:    #0F172A;
  --text-2:  #475569;
  --text-3:  #94A3B8;
  --text-inv:#FFFFFF;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --header-gradient: linear-gradient(135deg, #1E3A8A 0%, #2563EB 55%, #7C3AED 100%);
}

/* ── Reset ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── App shell ────────────────────────────── */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* ════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--header-gradient);
  box-shadow: var(--shadow-lg);
  padding: 0 20px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  flex-wrap: wrap;
}

/* Logo */
.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

.logo-title {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-inv);
  letter-spacing: 1.5px;
  line-height: 1.1;
}

.logo-sub {
  display: block;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.65);
  font-weight: 500;
  letter-spacing: 0.4px;
  margin-top: 1px;
}

/* Header right */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Live badge */
.update-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 20px;
  padding: 5px 12px;
  backdrop-filter: blur(10px);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #4ADE80;
  border-radius: 50%;
  box-shadow: 0 0 7px #4ADE80;
  flex-shrink: 0;
  animation: livePulse 2.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

#update-label {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.9);
  font-weight: 500;
  white-space: nowrap;
}

/* Clear all button */
.clear-all-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--r-sm);
  color: rgba(255,255,255,0.9);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.clear-all-btn:hover { background: rgba(255,255,255,0.22); }

/* Search bar */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  padding-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}

#search-input {
  width: 100%;
  padding: 11px 40px 11px 44px;
  border: none;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: box-shadow 0.2s, background 0.2s;
}

#search-input:focus {
  background: white;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
}

#search-input::placeholder { color: var(--text-3); }

.search-clear {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.15s;
}

.search-clear:hover { background: var(--border-2); }

/* Info bar */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.count-label {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}

.base-label {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
  background: rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 3px 10px;
}

.base-label strong { color: #FCD34D; }

/* ════════════════════════════════════════════
   STATE PANELS
   ════════════════════════════════════════════ */
.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 24px;
  text-align: center;
}

.state-icon { font-size: 3rem; line-height: 1; }

.state-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.state-sub {
  font-size: 0.88rem;
  color: var(--text-2);
  max-width: 320px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.btn-primary {
  margin-top: 8px;
  padding: 10px 26px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover  { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }

/* ════════════════════════════════════════════
   CURRENCY GRID
   ════════════════════════════════════════════ */
.currency-list {
  margin: 16px 20px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

/* ── Section separator (spans full grid width) ── */
.section-sep {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.section-sep span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-3);
  white-space: nowrap;
}

.section-sep-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Currency card ──────────────────────────── */
.currency-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
  position: relative;
}

.currency-row:hover {
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.currency-row.is-active {
  background: var(--primary-bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.currency-row.is-active:hover { background: #DBEAFE; }

.currency-row.is-hidden { display: none; }

/* Flag image */
.row-flag {
  width: 40px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Fallback for currencies without a single country flag */
.row-flag-fb {
  font-size: 2rem;
  line-height: 1;
  user-select: none;
}

/* Code */
.row-code {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* Name */
.row-name {
  font-size: 0.68rem;
  color: var(--text-3);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 4px;
}

/* Rate chip */
.row-rate {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-row.is-active .row-rate {
  background: var(--primary-border);
  color: var(--primary-hover);
  border-color: var(--primary-border);
}

/* Input */
.row-input-wrap {
  width: 100%;
  margin-top: 4px;
}

.row-input {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: white;
  font-family: 'Inter', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

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

.row-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.currency-row.is-active .row-input {
  border-color: var(--primary);
  background: white;
}

.row-input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

/* ════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: 24px 20px 12px;
  font-size: 0.76rem;
  color: var(--text-3);
}

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

.footer a:hover { text-decoration: underline; }

/* ════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════ */
@media (max-width: 600px) {
  .header { padding: 0 14px; }
  .currency-list {
    margin: 12px 12px 0;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }

  .logo-sub  { display: none; }
  .logo-icon { font-size: 1.8rem; }
  .logo-title { font-size: 1.15rem; }

  .currency-row { padding: 10px 8px 8px; }
  .row-flag  { width: 34px; height: 26px; }
  .row-flag-fb { font-size: 1.7rem; }
  .row-rate  { display: none; }
  .row-input { font-size: 0.85rem; padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .spinner { animation: none; }
}
