/* Inline “Card UI” forms inside bot bubbles */
.flow-card {
  margin-top: 12px;
  position: relative;
  z-index: 1;
  width: fit-content;
  max-width: 100%;
  min-width: min(100%, 16rem);
  border-radius: 16px;
  border: 1px solid rgba(46, 125, 50, 0.22);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96) 0%, rgba(232, 245, 233, 0.55) 100%);
  box-shadow: 0 8px 26px rgba(15, 35, 65, 0.08);
  padding: 14px 14px 12px;
  box-sizing: border-box;
}

/* Slide / Quiz / Flash (+ meta PDF): lấp phần còn lại sau avatar, không co như max-content */
.flow-card.flow-card-flow-wide {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.flow-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-dark);
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.flow-field {
  margin-bottom: 10px;
  min-width: 0;
}

.flow-field:last-of-type {
  margin-bottom: 0;
}

.flow-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.flow-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 3px 0 0;
  line-height: 1.35;
}

.flow-input,
.flow-select,
.flow-textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(16, 35, 58, 0.14);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.flow-select {
  min-width: 0;
  max-width: 100%;
}

.flow-mobile-select {
  position: relative;
  width: 100%;
}

.flow-select--mobile-native {
  display: none;
}

.flow-mobile-select-btn {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(16, 35, 58, 0.14);
  padding: 8px 34px 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.flow-mobile-select-btn::after {
  content: "▾";
  position: absolute;
  top: 50%;
  right: 11px;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
}

.flow-mobile-select-btn.is-placeholder {
  color: var(--muted);
}

.flow-mobile-select.is-open .flow-mobile-select-btn {
  border-color: rgba(46, 125, 50, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.flow-mobile-select-menu {
  position: relative;
  margin-top: 6px;
  max-width: 100%;
  max-height: min(240px, 52vh);
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid rgba(16, 35, 58, 0.12);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(15, 35, 65, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.flow-mobile-select-option {
  display: block;
  width: 100%;
  border: 0;
  padding: 11px 12px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}

.flow-mobile-select-option + .flow-mobile-select-option {
  border-top: 1px solid rgba(16, 35, 58, 0.06);
}

.flow-mobile-select-option.is-selected {
  background: rgba(232, 245, 233, 0.92);
  color: var(--green-dark);
  font-weight: 700;
}

.flow-input:focus,
.flow-select:focus,
.flow-textarea:focus {
  border-color: rgba(46, 125, 50, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.flow-textarea {
  min-height: 72px;
  resize: vertical;
}

.flow-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 768px) {
  .flow-card {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .flow-row-3 {
    grid-template-columns: 1fr;
  }

  .flow-select {
    font-size: 12px;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-right: 30px;
  }

  .flow-mobile-select-btn,
  .flow-mobile-select-option {
    font-size: 12px;
  }

  .flow-select--template {
    letter-spacing: -0.01em;
  }
}

.flow-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(46, 125, 50, 0.2);
}

.flow-skip-confirm {
  margin-top: 10px;
  padding: 10px 10px 8px;
  border-radius: 12px;
  background: rgba(255, 249, 196, 0.55);
  border: 1px solid rgba(189, 147, 0, 0.35);
}

.flow-skip-text {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--text);
}

.flow-skip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.flow-primary-btn {
  border: 0;
  border-radius: 12px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.25);
  transition: opacity 0.15s, transform 0.12s;
}

.flow-primary-btn:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}

.flow-primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.flow-secondary-btn {
  border: 1px solid rgba(16, 35, 58, 0.16);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
}

.flow-secondary-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
}

.flow-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.flow-file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flow-file-name {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-err {
  font-size: 12px;
  font-weight: 600;
  color: #c62828;
  margin-top: 6px;
}

.flow-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.flow-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.flow-radio input {
  accent-color: var(--green-dark);
}

.bubble.bot.bubble-has-flow-card {
  max-width: min(72%, calc(100% - 44px));
}

/* Form slide/quiz/flash trong bubble: 2/3 chiều ngang hàng chat (trừ full set) */
.msg-row.bot > .bubble.bot.bubble-has-flow-card-wide {
  flex: 0 1 auto;
  min-width: 0;
  width: calc(100% * 2 / 3);
  max-width: calc(100% - 44px);
}

/* Form card on its own row (not nested inside a glass bubble) */
.msg-flow-card-shell {
  flex: 0 1 auto;
  align-self: flex-start;
  min-width: 0;
  width: max-content;
  max-width: min(72%, calc(100% - 44px));
}

.msg-flow-card-shell.msg-flow-card-shell-wide {
  flex: 0 1 auto;
  align-self: flex-start;
  min-width: 0;
  width: calc(100% * 2 / 3);
  max-width: calc(100% - 44px);
}

.msg-flow-card-shell .flow-card {
  margin-top: 0;
}

.msg-row.bot.msg-row-flow-card {
  margin-top: 6px;
  margin-bottom: 12px;
}

.flow-autofill-btn {
  position: absolute !important;
  top: 10px !important;
  right: 12px !important;
  left: auto !important;
  width: 32px;
  height: 32px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none !important;
  background: var(--green) !important;
  color: #ffffff !important;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  z-index: 100 !important;
}

.flow-autofill-btn:hover {
  background: var(--green-dark) !important;
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 6px 20px rgba(46, 125, 50, 0.4);
}

.flow-autofill-btn:active {
  transform: translateY(0) scale(1);
}

.flow-autofill-btn svg {
  width: 16px;
  height: 16px;
}

.flow-autofill-btn.is-loading {
  cursor: wait;
  opacity: 0.8;
  transform: none !important;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3) !important;
}

.flow-autofill-spinner {
  width: 16px;
  height: 16px;
  animation: autofill-spin 0.75s linear infinite;
}

@keyframes autofill-spin {
  to { transform: rotate(360deg); }
}

.exp-shell { position: relative; }

/* ── AI Content Loading Overlay ─────────────────────────────────────────── */
.ai-loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 300px;
  padding: 64px 24px;
  width: 100%;
  box-sizing: border-box;
}

.ai-loading-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #dbeafe;
  border-top-color: #2563eb;
  animation: ai-loading-spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes ai-loading-spin {
  to { transform: rotate(360deg); }
}

.ai-loading-label {
  font-size: 15px;
  font-weight: 600;
  color: #1d4ed8;
  letter-spacing: 0.1px;
  text-align: center;
}

.ai-loading-tip {
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.55;
  max-width: 520px;
}

.ai-loading-countdown {
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  margin-top: -4px;
}

/* ── File Upload Error ───────────────────────────────────────────────────── */
.exp-upload-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 48px 24px;
  width: 100%;
  box-sizing: border-box;
}

.exp-upload-error-msg {
  font-size: 15px;
  font-weight: 500;
  color: #b91c1c;
  text-align: center;
  max-width: 480px;
  line-height: 1.6;
  margin: 0;
}


/* Flash vocab: in-textarea red highlight (mirror layer behind transparent text) */
.flow-vocab-editor-stack {
  position: relative;
  border-radius: 10px;
  border: 1px solid rgba(16, 35, 58, 0.14);
  background: rgba(255, 255, 255, 0.95);
  box-sizing: border-box;
}

.flow-vocab-editor-stack:focus-within {
  border-color: rgba(46, 125, 50, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.flow-vocab-highlight-clip {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: 10px;
  pointer-events: none;
}

.flow-vocab-highlight-inner {
  padding: 8px 10px;
  box-sizing: border-box;
  min-height: 100%;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.45;
  letter-spacing: normal;
  tab-size: 8;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  will-change: transform;
}

.flow-vocab-list-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.flow-vocab-list-header-title {
  margin: 0;
  flex: 0 0 auto;
}

.flow-vocab-auto-switch-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.03);
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: -4px;
}

.flow-vocab-auto-switch-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.flow-vocab-auto-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.flow-vocab-auto-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.flow-vocab-auto-switch-track {
  position: relative;
  display: block;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #9ca3af;
  transition: background 0.2s ease;
  box-sizing: border-box;
}

.flow-vocab-auto-switch-input:checked + .flow-vocab-auto-switch-track {
  background: #22c55e;
}

.flow-vocab-auto-switch-track::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.22s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

.flow-vocab-auto-switch-input:checked + .flow-vocab-auto-switch-track::after {
  transform: translateX(16px);
}

.flow-vocab-auto-switch:focus-within {
  border-radius: 999px;
  outline: 2px solid rgba(46, 125, 50, 0.45);
  outline-offset: 2px;
}

.flow-vocab-seg--rejected {
  color: #b91c1c;
}

.flow-vocab-seg--auto {
  color: #a16207;
  background: rgba(254, 243, 199, 0.55);
  border-radius: 2px;
}

.flow-vocab-seg--auto-pending {
  color: #b45309;
  background: rgba(254, 252, 232, 0.75);
  border-radius: 2px;
  border-bottom: 1px dashed rgba(180, 83, 9, 0.45);
}

.flow-vocab-submit-busy {
  pointer-events: none;
  opacity: 0.88;
  animation: flow-vocab-submit-pulse 0.9s ease-in-out infinite;
}

@keyframes flow-vocab-submit-pulse {
  0%,
  100% {
    opacity: 0.88;
  }
  50% {
    opacity: 1;
  }
}

.flow-err.flow-vocab-translate-wait {
  color: #166534;
  background: rgba(220, 252, 231, 0.55);
  border: 1px dashed rgba(46, 125, 50, 0.35);
}

.flow-vocab-syntax-ta.flow-textarea {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: none !important;
  border-radius: 10px;
  background: transparent !important;
  box-shadow: none !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  line-height: 1.45;
  letter-spacing: normal;
  tab-size: 8;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.flow-vocab-syntax-ta.flow-textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.flow-vocab-syntax-ta.flow-textarea::selection {
  background: rgba(76, 175, 80, 0.28);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

.flow-vocab-syntax-ta.flow-textarea::placeholder {
  color: rgba(16, 35, 58, 0.42);
  opacity: 1;
  -webkit-text-fill-color: rgba(16, 35, 58, 0.42);
  white-space: pre-wrap;
}
