/* ============================================================
   Seed Code Chat — Reusable Components
   Buttons · Icon buttons · Dropdowns · Dialog · Toasts
   Toggles · Sliders · Segmented controls · Cards · Badges
   ============================================================ */

/* ==================== Buttons ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--surface-4);
  color: var(--text);
  border-color: var(--muted-2);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  flex: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #062A15;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  box-shadow: var(--shadow-glow);
  color: #062A15;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: transparent;
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.18);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: var(--fs-12);
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: 11px 20px;
  font-size: var(--fs-15);
}

.btn-block {
  width: 100%;
}

/* ==================== Icon buttons ==================== */

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast),
    border-color var(--t-fast);
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.has-ring {
  border: 1px solid var(--border);
}

.icon-btn.branded {
  color: var(--brand-strong);
}

/* ==================== Dropdown / Menu ==================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: 6px;
  z-index: var(--z-dropdown);
  animation: sc-scale-in var(--t-fast) var(--ease-out);
  transform-origin: top left;
}

.menu.right {
  left: auto;
  right: 0;
  transform-origin: top right;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  color: var(--text-2);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}

.menu-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.menu-item svg {
  flex: none;
  color: var(--muted);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: var(--danger-bg);
}

.menu-item.danger svg {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 8px;
}

.menu-label {
  font-size: var(--fs-11);
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px 4px;
}

/* Model / provider trigger button */
.model-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 500;
  transition: border-color var(--t-fast), background var(--t-fast),
    box-shadow var(--t-fast);
  max-width: 100%;
}

.model-btn:hover {
  border-color: var(--brand-deep);
  background: var(--surface-3);
}

.model-btn .model-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-btn .chev {
  color: var(--muted);
  transition: transform var(--t-fast);
}

.model-btn[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-11);
  color: var(--brand-strong);
  background: var(--brand-dim);
  border: 1px solid rgba(46, 204, 113, 0.25);
  border-radius: var(--r-pill);
  padding: 1px 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ==================== Selectable list (models/providers) ==================== */

.picker-panel {
  width: min(400px, calc(100vw - 32px));
}

.picker-head {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.picker-head input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-13);
}

.picker-head input:focus {
  border-color: var(--brand-deep);
  outline: none;
}

.picker-head .picker-search {
  position: relative;
}

.picker-head .picker-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.picker-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-13);
  text-align: left;
  transition: background var(--t-fast);
}

.picker-item:hover {
  background: var(--surface-3);
}

.picker-item.active {
  background: var(--brand-dim);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--brand-deep);
}

.picker-item .pi-meta {
  flex: 1;
  min-width: 0;
}

.picker-item .pi-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-item .pi-sub {
  font-size: var(--fs-11);
  color: var(--muted);
  display: block;
}

.picker-item .pi-check {
  color: var(--brand-strong);
  flex: none;
  opacity: 0;
}

.picker-item.active .pi-check {
  opacity: 1;
}

.free-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-soft);
  background: var(--brand-dim);
  border: 1px solid rgba(123, 237, 159, 0.3);
  border-radius: 4px;
  padding: 0 5px;
  letter-spacing: 0.03em;
  flex: none;
}

/* ==================== Dialog ==================== */

.dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 6, 5, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog[hidden] {
  display: none;
}

.dialog-box {
  width: 100%;
  max-width: 460px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: sc-scale-in var(--t-base) var(--ease-out);
  overflow: hidden;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h3 {
  font-size: var(--fs-16);
}

.dialog-body {
  padding: 18px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

/* ==================== Toast ==================== */

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--brand-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: 12px 14px;
  font-size: var(--fs-13);
  color: var(--text-2);
  animation: sc-slide-in-right var(--t-base) var(--ease-out);
  pointer-events: auto;
}

.toast[data-kind="error"] {
  border-left-color: var(--danger);
}

.toast[data-kind="warning"] {
  border-left-color: var(--warning);
}

.toast[data-kind="info"] {
  border-left-color: var(--info);
}

.toast svg {
  flex: none;
  color: var(--brand-strong);
}

.toast[data-kind="error"] svg { color: var(--danger); }
.toast[data-kind="warning"] svg { color: var(--warning); }
.toast[data-kind="info"] svg { color: var(--info); }

.toast.out {
  opacity: 0;
  transform: translateX(24px);
  transition: opacity var(--t-base), transform var(--t-base);
}

/* ==================== Toggle switch ==================== */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--surface-4);
  border: 1px solid var(--border-strong);
  transition: background var(--t-base), border-color var(--t-base);
  position: relative;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--t-base) var(--ease-out), background var(--t-base);
}

.switch input:checked + .track {
  background: var(--brand-dim);
  border-color: var(--brand-deep);
}

.switch input:checked + .track::after {
  transform: translateX(16px);
  background: var(--brand-strong);
  box-shadow: 0 0 8px var(--brand-glow-strong);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

/* ==================== Slider ==================== */

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row output {
  min-width: 44px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--brand-strong);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-4);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-strong);
  border: 2px solid var(--surface);
  box-shadow: 0 0 8px var(--brand-glow);
  cursor: pointer;
  transition: transform var(--t-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-strong);
  border: 2px solid var(--surface);
  box-shadow: 0 0 8px var(--brand-glow);
  cursor: pointer;
}

/* ==================== Segmented control ==================== */

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}

.segmented .seg-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast),
    box-shadow var(--t-fast);
}

.segmented .seg-btn:hover {
  color: var(--text);
}

.segmented .seg-btn.active {
  background: var(--surface-4);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.segmented .seg-btn[aria-pressed="true"] {
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px var(--brand-deep), 0 0 12px var(--brand-glow);
}

/* ==================== Cards ==================== */

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

/* ==================== Badges / tags ==================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-11);
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 2px 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag.brand {
  color: var(--brand-strong);
  border-color: rgba(46, 204, 113, 0.3);
  background: var(--brand-dim);
}

.tag.online {
  color: var(--brand-strong);
  border-color: rgba(46, 204, 113, 0.35);
  background: var(--brand-dim);
}

.tag.offline {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--danger-bg);
}

/* ==================== Form fields ==================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field > label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-2);
}

.field .field-hint {
  font-size: var(--fs-12);
  color: var(--muted);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-14);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-deep);
  box-shadow: var(--shadow-focus);
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.password-input {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input input {
  padding-right: 42px;
}

.password-input .eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-input .eye-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

/* ==================== Tabs ==================== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 8px 14px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--brand-strong);
  border-bottom-color: var(--brand-strong);
}

/* ==================== Empty state ==================== */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.empty-state .es-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: var(--brand-dim);
  border: 1px solid rgba(46, 204, 113, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-strong);
  margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}

.empty-state h2 {
  font-size: var(--fs-20);
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--muted);
  max-width: 420px;
  font-size: var(--fs-14);
}
