/**
 * Ask tab — AI query + SSE streaming styles (v5-mini-app-4-2)
 */

/* ── Ask tab root ───────────────────────────────────────────────── */
.ask-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--cl-bg);
  overflow: hidden;
}

/* ── Scrollable answer area ─────────────────────────────────────── */
.ask-answer-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Recent queries list ─────────────────────────────────────────── */
.ask-recents {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ask-recents__label {
  font-size: 12px;
  color: var(--cl-hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.ask-recent-item {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--cl-secondary-bg);
  border-radius: 8px;
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  color: var(--cl-text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.ask-recent-item:active {
  opacity: 0.75;
}

.ask-recent-item__icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  color: var(--cl-hint);
}

.ask-recent-item__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Answer bubble ───────────────────────────────────────────────── */
.ask-answer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ask-answer__text {
  font-size: 15px;
  line-height: 1.55;
  color: var(--cl-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Typing indicator ────────────────────────────────────────────── */
.ask-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.ask-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cl-hint);
  animation: ask-dot-bounce 1.2s ease-in-out infinite;
}

.ask-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.ask-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ask-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Source reference chips ─────────────────────────────────────── */
.ask-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.ask-ref-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* LOW-1: meet 44px touch-target guideline */
  padding: 8px 12px;
  background: rgba(36, 129, 204, 0.15); /* LOW-3: fallback for old WebView */
  background: color-mix(in srgb, var(--cl-link) 15%, transparent);
  border: 1px solid rgba(36, 129, 204, 0.40); /* LOW-3: fallback */
  border: 1px solid color-mix(in srgb, var(--cl-link) 40%, transparent);
  border-radius: 20px;
  font-size: 13px;
  color: var(--cl-link);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  gap: 4px;
}

.ask-ref-chip:active {
  opacity: 0.75;
}

.ask-ref-chip__type {
  font-weight: 600;
  text-transform: capitalize;
}

.ask-ref-chip__date {
  color: rgba(36, 129, 204, 0.85); /* LOW-3: fallback */
  color: color-mix(in srgb, var(--cl-link) 75%, var(--cl-text));
  font-size: 12px;
}

/* ── Error state ─────────────────────────────────────────────────── */
.ask-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: rgba(229, 62, 62, 0.10); /* LOW-3: fallback */
  background: color-mix(in srgb, var(--cl-destructive, #e53e3e) 10%, transparent);
  border-radius: 8px;
  text-align: center;
}

.ask-error__msg {
  color: var(--cl-destructive, #e53e3e);
  font-size: 14px;
}

.ask-error__retry {
  min-height: 44px;
  padding: 0 20px;
  background: var(--cl-link);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* ── Input bar (fixed at bottom of Ask tab) ──────────────────────── */
.ask-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--cl-bg);
  border-top: 1px solid rgba(128, 128, 128, 0.20); /* LOW-3: fallback */
  border-top: 1px solid color-mix(in srgb, var(--cl-hint) 20%, transparent);
}

.ask-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 14px;
  background: var(--cl-secondary-bg);
  color: var(--cl-text);
  border: 1px solid rgba(128, 128, 128, 0.30); /* LOW-3: fallback */
  border: 1px solid color-mix(in srgb, var(--cl-hint) 30%, transparent);
  border-radius: 22px;
  font-size: 15px;
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
  font-family: inherit;
  line-height: 1.4;
}

.ask-input::placeholder {
  color: var(--cl-hint);
}

.ask-input:focus {
  outline: none;
  border-color: var(--cl-link);
}

.ask-submit-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cl-link);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.ask-submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ask-submit-btn__icon {
  width: 20px;
  height: 20px;
  color: #fff;
}
