/* ============================================
   Component Styles
   ============================================ */

/* Source Row — dropdown + input */
.source-row {
  display: flex;
  gap: var(--space-sm);
  align-items: stretch;
}

/* ---- Custom Currency Dropdown ---- */
.currency-select {
  position: relative;
  flex: 1 1 55%;
  min-width: 0;
}

.currency-select__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  height: 3rem;
  padding: 0 var(--space-md);
  background: var(--color-card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
}

.currency-select__trigger:hover {
  border-color: var(--color-border-focus);
}

.currency-select__trigger:focus-visible {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.currency-select__trigger[aria-expanded="true"] {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.currency-select__flag {
  flex-shrink: 0;
}

.currency-select__code {
  font-weight: 600;
  flex-shrink: 0;
}

.currency-select__name {
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-size: var(--font-size-sm);
}

.currency-select__chevron {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.currency-select__trigger[aria-expanded="true"] .currency-select__chevron {
  transform: rotate(180deg);
}

/* Dropdown Options List */
.currency-select__options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--color-card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  list-style: none;
  padding: var(--space-xs) 0;
  display: none;
}

.currency-select__options--open {
  display: block;
}

.currency-select__option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background-color var(--transition-fast);
}

.currency-select__option:hover,
.currency-select__option--focused {
  background-color: var(--color-accent-light);
}

.currency-select__option--selected {
  background-color: var(--color-accent-light);
  font-weight: 600;
}

.currency-select__option-code {
  font-weight: 600;
  width: 2.5rem;
  flex-shrink: 0;
}

.currency-select__option-name {
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Amount Input ---- */
.amount-wrapper {
  flex: 1 1 45%;
  min-width: 0;
}

.amount-input {
  width: 100%;
  height: 3rem;
  padding: 0 var(--space-md);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: right;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.amount-input:hover {
  border-color: var(--color-border-focus);
}

.amount-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.amount-input--invalid {
  border-color: var(--color-error);
}

.amount-input--invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* ---- Result Cards ---- */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.results-container:empty {
  background: transparent;
}

.result-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-card-bg);
  transition: background-color var(--transition-fast);
}

.result-card:hover {
  background-color: #fafbfc;
}

.result-card__flag {
  flex-shrink: 0;
}

.result-card__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.result-card__code {
  font-weight: 700;
  font-size: var(--font-size-sm);
  line-height: 1.2;
}

.result-card__name {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card__amount {
  font-size: var(--font-size-lg);
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

/* ---- Loading Skeleton ---- */
.loading-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-card-bg);
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton--circle {
  width: 1.5rem;
  height: 1.125rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.skeleton--text-sm {
  width: 3rem;
  height: 0.875rem;
}

.skeleton--text-md {
  width: 6rem;
  height: 0.75rem;
  margin-top: 0.25rem;
}

.skeleton--amount {
  width: 5rem;
  height: 1.25rem;
  margin-left: auto;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Error State ---- */
.error-container[hidden] {
  display: none;
}

.error-message {
  background: var(--color-error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}

.error-message__text {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.error-message__retry {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-error);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.error-message__retry:hover {
  opacity: 0.9;
}

.error-message__retry:focus-visible {
  outline: 2px solid var(--color-error);
  outline-offset: 2px;
}

/* ---- Validation Message ---- */
.validation-msg {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: var(--space-xs);
  min-height: 1rem;
}

/* ---- Custom Target Section ---- */
.custom-target-section {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

.custom-target__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.custom-target__select {
  width: 100%;
  height: 3rem;
  padding: 0 var(--space-md);
  background: var(--color-card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-target__select:hover {
  border-color: var(--color-border-focus);
}

.custom-target__select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#custom-result {
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ---- Rate Trend Chart ---- */
.chart-section {
  margin-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

.chart-section__title {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.chart-section__canvas-wrapper {
  position: relative;
  height: 220px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .source-row {
    flex-direction: column;
  }

  .currency-select,
  .amount-wrapper {
    flex: 1 1 auto;
  }

  .amount-input {
    text-align: left;
  }

  .result-card__name {
    display: none;
  }

  .result-card__amount {
    font-size: var(--font-size-base);
  }

  .currency-select__name {
    display: none;
  }
}
