/* Override default styles */
.container,
.tool-content {
  width: auto;
  text-align: center;
}

#currency_wrapper {
  background: #f1f1f1;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 20px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Add currency search field */
.currency-search-wrap {
  position: relative;
  text-align: left;
  margin-bottom: 14px;
}

#currency-search {
  border: 1px solid #ccc;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.95em;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}

#currency-search:disabled {
  background-color: #e9e9e9;
  color: #999;
  cursor: not-allowed;
}

.currency_list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background-color: #fff;
  border: 1px solid #ddd;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}

.currency_list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.currency_list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  justify-content: space-between;
}

.currency_list li .cl-name {
  color: #777;
  margin-left: 8px;
}

.currency_list li:hover {
  background-color: #f0f0f0;
}

.currency_list .cl-empty {
  padding: 12px;
  color: #999;
  font-size: 0.9em;
  text-align: center;
}

#currency_rows {
  text-align: left;
}

.currency-row {
  display: flex;
  align-items: center;
  border-radius: 5px;
  margin-bottom: 6px;
  padding: 8px 10px;
  background-color: #f9f9f9;
  border: 1px solid transparent;
  position: relative;
  transition: opacity 0.3s ease, border-color 0.2s ease;
}

.currency-row.is-primary {
  background-color: #fff;
  border-color: #e0e0e0;
}

.currency-row.is-editing {
  border-color: #007bff;
}

.currency-row.is-removing {
  opacity: 0;
}

.currency-row.is-dragging {
  opacity: 0.5;
}

.currency-row.drag-over {
  border-color: #007bff;
  border-style: dashed;
}

.currency-row .remove {
  flex: 0 0 auto;
  width: 24px;
  text-align: center;
  color: #999;
  cursor: pointer;
  font-size: 1em;
  margin-right: 6px;
}

.currency-row .remove:hover {
  color: #d9534f;
}

.currency-row .badge {
  font-weight: bold;
  font-size: 1.1em;
  width: 56px;
  flex: 0 0 56px;
  text-align: center;
  color: #555;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: element;
}

.currency-row .badge:active {
  cursor: grabbing;
}

.currency-row .meta {
  /* 30ch = longest currency name, "Central African CFA Franc" (25 chars), + 5 char padding */
  flex: 0 0 30ch;
  margin-left: 5px;
  margin-right: 10px;
  overflow: hidden;
}

.currency-row .name {
  font-weight: bold;
  font-size: 1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.currency-row .amount-wrap {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.currency-row .amount {
  border: none;
  background: transparent;
  font-size: 1.1em;
  font-weight: bold;
  text-align: right;
  flex: 1 1 auto;
  min-width: 0;
  outline: none;
  color: #222;
  font-family: inherit;
}

.currency-row .symbol {
  font-size: 1em;
  color: #777;
  /* fixed slot so symbols line up down the list despite differing glyph widths;
     min-width:0 stops a wide symbol (e.g. "MOP$") from growing the slot and
     throwing off alignment on other rows */
  flex: 0 0 6ch;
  min-width: 0;
  margin-left: 4px;
  text-align: left;
}

.currency-row .amount:focus {
  color: #007bff;
}

.rates-updated {
  margin-top: 14px;
  font-size: 0.75em;
  color: #999;
  text-align: center;
}

.rates-updated.is-stale {
  color: #c08a2e;
}

#jsWarning {
  color: red;
  font-weight: bold;
  margin-top: 10px;
  display: none;
}

/* Mobile numeric keypad */
#numeric-keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #e8e8e8;
  border-top: 1px solid #ccc;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  z-index: 9998;
  padding-bottom: env(safe-area-inset-bottom);
}

#numeric-keypad.is-visible {
  display: grid;
}

#numeric-keypad button {
  border: none;
  background: #fff;
  padding: 16px 0;
  font-size: 1.3em;
  color: #222;
}

#numeric-keypad button:active {
  background-color: #dbeafe;
}

#numeric-keypad button:disabled {
  color: #ccc;
  background: #f5f5f5;
}

#numeric-keypad button.kp-done {
  grid-column: 1 / -1;
  background-color: #007bff;
  color: #fff;
  font-size: 1em;
  font-weight: 600;
  padding: 12px 0;
}

@media (min-width: 768px) {
  #numeric-keypad {
    display: none !important;
  }
}

/* Currency code is enough on small screens; keep the full name on desktop */
@media (max-width: 767px) {
  .currency-row .meta {
    flex: 0 0 auto;
  }

  .currency-row .meta .name {
    display: none;
  }
}
