@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== Currency widget ===== */
.currency-widget {
  font-family: 'Inter', sans-serif;
  padding: 0 1rem;
}

/* ===== Form layout – flex, no fragile offsets ===== */
.currency-form {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* ===== Cards ===== */
.currency-card {
  flex: 1;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  width: 100%;
  box-sizing: border-box;
}

.currency-card__legend {
  font-size: 1.125rem;      /* ≈ 18 px */
  font-weight: 700;         /* bold */
  color: #5f6368;
  margin-bottom: 0.5rem;
}

/* ===== Card body – stack vertically ===== */
.currency-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Amount row (symbol + input) stays horizontal */
.currency-card__amount {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 500;
}

.currency-card__symbol {
  margin-right: 0.25rem;
}

.currency-card__input {
  border: none;
  outline: none;
  font-size: 1.5rem;
  font-weight: 500;
  flex: 1 1 0%;
  background: transparent;
  padding: 0;
  margin: 0;
  line-height: 1.2;
}

/* ===== Dropdown wrapper (relative anchor) ===== */
.currency-card__dropdown-wrapper {
  position: relative;
  width: 100%;
}

/* ===== Currency selector button ===== */
.currency-card__selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.currency-card__selector * {
  pointer-events: none;
}

.currency-card__flag {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.currency-card__code {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-card__name {
  color: #5f6368;
  display: none;                  /* shown on wider screens */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-card__arrow {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ===== Swap button – centered relative to cards ===== */
.currency-swap {
  align-self: center;
  margin-top: 0.25rem;
  background: white;
  border: 1px solid #dadce0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

/* ===== Conversion statement ===== */
.currency-statement {
  text-align: center;
  margin-top: 1.5rem;
}

.currency-statement__main {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.currency-statement__rate {
  font-size: 0.875rem;
  color: #5f6368;
  margin-top: 0.25rem;
}

/* ===== Disclaimer ===== */
.currency-disclaimer {
  text-align: center;
  color: #5f6368;
  font-size: 0.75rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

/* ===== Dropdown dialog (anchored, no backdrop) ===== */
.currency-dialog {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
  background: white;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  z-index: 100;
  display: none;
  padding: 0.5rem;
  box-sizing: border-box;
}

.currency-dialog:not([hidden]) {
  display: block;                /* visible when hidden attribute is removed */
}

.currency-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
  padding-top: 0.5rem;
}

.currency-dialog__search input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #dadce0;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
  margin-left: 0;
  margin-right: 0;
}

.currency-dialog__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.currency-dialog__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
}

.currency-dialog__item:hover {
  background: #f8f9fa;
}

.currency-dialog__item--highlight {
  background: #e8f0fe;
  outline: none;
}

.currency-dialog__flag {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.currency-dialog__code {
  font-weight: 600;
}

.currency-dialog__name {
  color: #5f6368;
}

.currency-dialog__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.currency-dialog__close:hover {
  background: #f1f3f4;
  border-radius: 50%;
}

/* ===== Focus indicators ===== */
.currency-card__input:focus-visible,
.currency-card__selector:focus-visible,
.currency-swap:focus-visible,
.currency-dialog__close:focus-visible,
.currency-dialog__search input:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .currency-card__name {
    display: inline;
  }
}

@media (max-width: 599px) {
  .currency-form {
    flex-direction: column;
    gap: 0.5rem;
  }
  .currency-swap {
    align-self: center;
    margin: 0.5rem auto;
  }
}