/**
 * Token-Chips CSS (MD3-konform)
 * Filter-Chips für alphanumerische Token-IDs mit 8-Zeichen-Kürzung
 */

/* ===========================
   Token-Filter Section
   =========================== */

.tokid-filter-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.tokid-input-row {
  display: flex;
  .tokid-chip:hover {
    background-color: rgba(233, 30, 99, 0.18);
    border-color: rgba(233, 30, 99, 0.35);
    color: #ad1457;
  }
  gap: 12px;
  align-items: flex-start;
}

.tokid-input-row .md3-outlined-textfield {
  flex: 1;
  min-width: 0;
}

.tokid-helper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  line-height: 16px;
  min-height: 16px;
}

.tokid-helper-text {
  color: var(--md-sys-color-on-surface-variant, rgba(0, 0, 0, 0.6));
}

.md3-text-field-helper-line {
  background-color: rgba(233, 30, 99, 0.18);
  color: #ad1457;
  padding: 0.375rem 0;
  gap: 0.75rem;
}

.tokid-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant, #49454f);
  text-transform: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-right: 0.5rem;
}

/* Enforce non-uppercase specifically for the tokid-count inside the chip bar (override other global rules) */
#tokid-chip-container .tokid-count {
  text-transform: none !important;
}

@media (prefers-color-scheme: dark) {
  .tokid-count {
    color: #9e9e9e;
  }
}

/* ===========================
   Chip Container
   =========================== */

.tokid-chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: var(--space-4, 1rem);
  align-items: center;
  align-content: flex-start;
  transition: background-color 0.2s ease;
  background: var(--md-sys-color-surface-container-low, #f7f2fa);
  border-radius: var(--radius-md, 8px);
}

.tokid-chip-container:empty {
  display: none;
}

/* ===========================
   Filter Chip (MD3 Style - Purple/Indigo Theme)
   =========================== */

/* Scoped token chip appearance inside tokid-chip-items to reduce conflict */
/* Scoped token chip appearance inside tokid-chip-items to reduce conflict */
#tokid-chip-items .tokid-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: auto;
  padding: 0.375rem 0.75rem;
  background-color: rgba(233, 30, 99, 0.12);
  border: 1px solid rgba(233, 30, 99, 0.2);
  border-radius: 1rem;
  font-family: var(--md-sys-typescale-label-large-font, "Roboto", sans-serif);
  font-size: 0.875rem;
  line-height: 1.4;
  font-weight: 500;
  color: #c2185b;
  cursor: default;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Fallback generic selector for older templates */
.tokid-chip {
  color: #c2185b;
}

.tokid-chip:active {
  background-color: var(--md-sys-color-surface-container-highest, #d6d6d6);
}

/* Chip Text Label */
.tokid-chip__label {
  /* Show full token ids — allow wrapping if very long */
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  font-family: "Roboto Mono", "Consolas", monospace;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  word-break: break-all;
}

/* Trailing Icon (Remove Button) */
.tokid-chip__trailing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  margin: 0;
  margin-left: 0.25rem;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #311b92;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1rem;
  line-height: 1;
  font-weight: 400;
  flex-shrink: 0;
}

.tokid-chip__trailing:hover {
  background-color: rgba(233, 30, 99, 0.18);
  color: #ad1457;
}

.tokid-chip__trailing:active {
  background-color: rgba(233, 30, 99, 0.25);
  transform: scale(0.95);
}

/* ===========================
   Responsive Anpassungen
   =========================== */

@media (max-width: 839px) {
  .tokid-input-row {
    flex-direction: column;
  }

  .tokid-input-row .md3-outlined-textfield {
    width: 100%;
  }

  .tokid-helper-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ===========================
   Empty State
   =========================== */

.tokid-chip-container.tokid-chip-container--empty {
  display: none !important;
}

/* ===========================
   Dark Mode Support
   =========================== */

@media (prefers-color-scheme: dark) {
  .tokid-chip-container {
    background-color: var(--md-sys-color-surface-container-low, #1e1e1e);
  }

  /* Use discourse (discurso) color scheme for chips in dark mode as well */
  .tokid-chip {
    background-color: rgba(233, 30, 99, 0.18);
    border-color: rgba(233, 30, 99, 0.3);
    color: #ff80ab; /* bright pink-ish for dark mode */
  }

  .tokid-chip:hover {
    background-color: rgba(233, 30, 99, 0.3);
    border-color: rgba(233, 30, 99, 0.42);
  }

  .tokid-chip:active {
    background-color: rgba(233, 30, 99, 0.35);
  }

  .tokid-helper-text {
    color: var(--md-sys-color-on-surface-variant, rgba(255, 255, 255, 0.6));
  }

  .tokid-chip__trailing {
    color: #e1bee7;
  }

  .tokid-chip__trailing:hover {
    background-color: rgba(149, 117, 205, 0.2);
    color: #ff9ccc;
  }
}
