/* ── Tagshop AI Agent – Light Theme ── */

@keyframes ts-grad {
  0%   { background-position: 0%   0%;   }
  25%  { background-position: 100% 0%;   }
  50%  { background-position: 100% 100%; }
  75%  { background-position: 0%   100%; }
  100% { background-position: 0%   0%;   }
}

.ts-agent-wrap {
  max-width: 1000px;
  width: 100%;
  /* Clears this theme's fixed top nav (navbar-fixed-top, ~65px) plus its sticky promo
     bar when shown (~40px, z-index 99999) - both are position:fixed and otherwise sit
     on top of whatever renders at the very top of the page, clipping the tabs strip. */
  margin: 130px auto 20px;
  padding: 0 16px;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

@media (max-width: 640px) {
  .ts-agent-wrap {
    /* The sticky promo bar doesn't render at mobile widths - only the ~65px fixed nav
       needs to be cleared here. */
    margin-top: 90px;
  }
}

/* Animated gradient border */
.ts-agent-border-outer {
  position: relative;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(135deg, #4824fb, #1e3a8a, #2563eb);
  background-size: 300% 300%;
  animation: ts-grad 2s ease-in-out infinite;
}

/* Light inner card. overflow stays visible (not hidden) so absolutely-positioned
   dropdown menus that extend past the card's edges aren't clipped. */
.ts-agent-border-inner {
  background: #ffffff;
  border-radius: 14px;
  padding: 0;
  overflow: visible;
}

.ts-tabs {
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}

.ts-body { padding: 8px; }

/* ── Tabs ── */
.ts-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
}

.ts-tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

.ts-tab:hover { color: #374151; }

.ts-tab.ts-tab-active {
  color: #111827;
  border-bottom-color: #111827;
}

/* ── Generic upload stub (no real upload — redirects to app) ── */
.ts-upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  color: #9ca3af;
  cursor: pointer;
  gap: 3px;
  font-family: inherit;
  transition: background 0.15s;
}

.ts-upload-btn:hover { background: #e5e7eb; }

.ts-upload-label {
  font-size: 9px;
  color: #6b7280;
  line-height: 1.2;
  max-width: 56px;
  text-align: center;
}

/* ── Assets row ── */
.ts-assets-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.ts-assets-row:empty { display: none; }

.ts-asset-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ts-asset-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: visible;
  flex-shrink: 0;
}

.ts-asset-thumb-inner {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
}

.ts-asset-thumb-inner img,
.ts-asset-thumb-inner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ts-asset-audio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ts-asset-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
  z-index: 2;
}

.ts-asset-thumb:hover .ts-asset-remove { opacity: 1; }

.ts-asset-name {
  font-size: 10px;
  color: #6b7280;
  margin-top: 3px;
}

/* ── Textarea ── */
.ts-textarea-wrap { position: relative; }

.ts-textarea {
  width: 100%;
  min-height: 80px;
  background: transparent;
  color: #111827;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px;
  box-sizing: border-box;
  font-family: inherit;
  caret-color: #111827;
}

/* Typing-animation overlay */
.ts-placeholder {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 14px;
  color: #9ca3af;
  pointer-events: none;
  line-height: 1.5;
}

.ts-placeholder.ts-hide { display: none; }

.ts-cursor {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: #9ca3af;
  margin-left: 1px;
  vertical-align: middle;
  animation: ts-blink 1s step-end infinite;
}

@keyframes ts-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Controls row ──
   Desktop: every dropdown + Send sits on one single line. #ts-row-1/#ts-row-2 are
   collapsed with display:contents so their children become direct flex items of
   .ts-controls instead of two stacked sub-rows.
   Mobile: reverts to two stacked, wrapping rows so it stays usable on small screens. */
.ts-controls {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.ts-row {
  display: contents;
}

.ts-dd,
.ts-send-wrap,
.ts-upload-btn {
  flex-shrink: 0;
}

.ts-send-wrap { margin-left: auto; }

@media (max-width: 640px) {
  .ts-controls {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
  }

  /* Each row stays on exactly one line (nowrap) and scrolls horizontally instead of
     wrapping into extra lines - guarantees a max of 2 rows total on mobile regardless
     of how many controls a row holds. */
  .ts-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .ts-row::-webkit-scrollbar { display: none; }

  .ts-row .ts-dd,
  .ts-row .ts-upload-btn {
    flex-shrink: 0;
  }

  .ts-send-wrap { margin-left: 0; flex-shrink: 0; }
}

/* ── Model dropdown trigger ── */
.ts-model-logo {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.ts-model-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Model dropdown menu (search + list) ── */
.ts-model-menu {
  min-width: 260px;
  max-width: 280px;
  padding: 0;
  display: none;
  flex-direction: column;
  z-index: 999999;
}

.ts-model-menu.ts-open { display: flex; }

.ts-model-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #9ca3af;
  flex-shrink: 0;
}

.ts-model-search {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: #111827;
  width: 100%;
  font-family: inherit;
}

.ts-model-list {
  overflow-y: auto;
  max-height: 260px;
  padding-bottom: 6px;
}

.ts-model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}

.ts-model-item:hover,
.ts-model-item.ts-sel { background: #f3f4f6; }

.ts-model-item-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
}

.ts-model-item-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ts-model-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ts-model-item-name {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-model-item-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #9ca3af;
}

.ts-model-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
}

/* ── Credits (on send button) ── */
.ts-credits {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ts-send-btn { gap: 8px; }

/* Base control button – light style */
.ts-ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #374151;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: inherit;
  line-height: 1;
  height: 36px;
}

@media (min-width: 640px) { .ts-ctrl-btn { padding: 6px 14px; font-size: 13px; } }

.ts-ctrl-btn:hover:not(:disabled) { background: #e5e7eb; }
.ts-ctrl-btn:disabled { opacity: 0.45; pointer-events: none; }

/* Hide label text on mobile */
.ts-label-sm { display: none; }
@media (min-width: 640px) { .ts-label-sm { display: inline; } }

/* Send button active */
.ts-send-btn.ts-active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.ts-send-btn.ts-active:hover { background: #1f2937; }

/* Chevron */
.ts-chevron { flex-shrink: 0; transition: transform 0.15s; }
.ts-chevron.ts-open { transform: rotate(180deg); }

/* ── Dropdowns ── */
.ts-dd { position: relative; }

.ts-dd-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  /* Higher than this theme's fixed sticky promo bar (z-index: 99999) and any other
     page chrome, so the menu never renders behind something else on the page. */
  z-index: 999999;
  min-width: 100px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.ts-dd-menu.ts-open { display: block; }

.ts-dd-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  font-family: inherit;
  box-sizing: border-box;
  white-space: nowrap;
}

.ts-dd-item:hover,
.ts-dd-item.ts-sel { background: #f3f4f6; color: #111827; }

.ts-dd-item-desc {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
  white-space: normal;
  max-width: 260px;
  display: block;
}

/* ── Spinner ── */
.ts-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: #111;
  border-radius: 50%;
  animation: ts-spin 0.6s linear infinite;
}

@keyframes ts-spin { to { transform: rotate(360deg); } }

/* Backdrop */
.ts-backdrop { position: fixed; inset: 0; z-index: 999998; }
