/* agent.css — AI Application Agent page */

.agent-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 16px 16px;
  box-sizing: border-box;
  gap: 0;
}

/* ── Hero header ── */
.agent-hero {
  margin-bottom: 10px;
  flex-shrink: 0;
  background: linear-gradient(130deg, #eef2ff 0%, #f5f7ff 55%, #fff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 18px 22px 0;
}

.agent-hero-inner {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.agent-hero-text {
  flex: 1;
  padding-bottom: 16px;
}

.agent-ai-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4f46e5;
  background: rgba(79, 70, 229, 0.09);
  border: 1px solid rgba(79, 70, 229, 0.22);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 8px;
}

.agent-hero h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: #1e1b4b;
  line-height: 1.25;
}

.agent-subtitle {
  margin: 0;
  font-size: 14.5px;
  color: #475569;
  line-height: 1.55;
}

.agent-hero-note {
  flex-shrink: 0;
  margin: 0;
  padding: 12px 18px 14px;
  border-left: 1px solid rgba(99, 102, 241, 0.18);
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.55;
  max-width: 280px;
  background: rgba(99, 102, 241, 0.03);
  border-radius: 0 14px 14px 0;
}

/* ── Sample buttons card ── */
.agent-samples-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 18px;
}

.agent-samples-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.agent-samples-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-sample-btn {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #4f46e5;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.agent-sample-btn:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

/* ── PDF Sample Modal ── */
.agent-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.agent-modal.open {
  display: flex;
}

.agent-modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.agent-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}

.agent-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color .15s, background .15s;
}

.agent-modal-close:hover {
  color: #1e293b;
  background: #f1f5f9;
}

.agent-modal-body {
  flex: 1;
  overflow: hidden;
}

.agent-sample-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.agent-body {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

/* ── Left: chat ── */
.agent-chat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}

#agentThinkingOverlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
}

.agent-thinking-inner {
  text-align: center;
  color: #64748b;
  font-size: 13.5px;
}

.agent-thinking-dots {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 10px;
  border: 3px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: agentSpin 0.8s linear infinite;
}

@keyframes agentSpin {
  to { transform: rotate(360deg); }
}

.agent-restart-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: inherit;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

.agent-restart-btn:hover { color: #ef4444; border-color: #fca5a5; }

.agent-skip-btn-wrap {
  padding: 4px 0 4px 42px;
}

.agent-skip-btn {
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, border-color .15s;
}

.agent-skip-btn:hover { color: #1e293b; border-color: #94a3b8; }

.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgIn .18s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.agent-msg.bot  { align-self: flex-start; }
.agent-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.agent-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: #f1f5f9;
}

.agent-msg.bot  .agent-msg-avatar {
  background-color: #0e2247;
  background-image: url('/images/logo_transparent.png');
  background-repeat: no-repeat;
  background-size: auto 30px;
  background-position: -1px center;
}
.agent-msg.user .agent-msg-avatar { background: #dbeafe; color: #1d4ed8; }

.agent-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.agent-msg.bot  .agent-msg-bubble { background: #f8fafc; border: 1px solid #e2e8f0; color: #1e293b; border-top-left-radius: 4px; }
.agent-msg.user .agent-msg-bubble { background: #4f46e5; color: #fff; border-top-right-radius: 4px; }

.agent-msg.typing .agent-msg-bubble { color: #94a3b8; font-style: italic; }

.agent-input-row {
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #f8fafc;
  align-items: center;
}

.agent-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color .15s;
}

.agent-input:focus { border-color: #6366f1; }
.agent-input:disabled { opacity: .55; cursor: not-allowed; }

.agent-send-btn {
  padding: 10px 22px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  font-family: inherit;
}

.agent-send-btn:hover:not(:disabled) { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.55); }
.agent-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Right: draft panel ── */
.agent-draft-col {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-draft-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.agent-draft-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.agent-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  background: #ede9fe;
  color: #6d28d9;
  letter-spacing: .03em;
}

.agent-draft-fields {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.agent-field-row {
  margin-bottom: 10px;
  animation: fieldIn .2s ease;
}

@keyframes fieldIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.agent-field-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}

.agent-field-star { font-style: normal; }
.agent-field-star-red   { color: #ef4444; }
.agent-field-star-green { color: #22c55e; }

.agent-field-value {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
  word-break: break-word;
}

.agent-draft-empty {
  color: #cbd5e1;
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

/* Pre-conversation draft preview */
.agent-draft-preview {
  padding: 8px 4px 12px;
}
.agent-draft-preview ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-draft-preview ul li {
  font-size: 13px;
  color: #475569;
  padding-left: 20px;
  position: relative;
  line-height: 1.4;
}
.agent-draft-preview ul li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #6366f1;
  font-weight: 600;
}
.agent-preview-note {
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}

/* Save Draft / Save Changes button */
.agent-save-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .45);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.agent-save-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 24px rgba(37, 99, 235, .6);
}
.agent-save-btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.agent-save-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Create Application button (shown when done) */
.agent-create-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .45);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.agent-create-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 24px rgba(37, 99, 235, .6);
}
.agent-create-btn:active { transform: translateY(0) scale(.98); }

/* Another Application button */
.agent-another-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  color: rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  font-family: inherit;
}

.agent-another-btn:hover {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
}

/* Progress bar */
.agent-progress-wrap {
  padding: 10px 16px 6px;
  flex-shrink: 0;
}

.agent-progress-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.agent-progress-bar {
  height: 4px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.agent-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 4px;
  transition: width .4s ease;
}

/* Done state */
.agent-done-notice {
  padding: 12px 16px;
  background: #f0fdf4;
  border-top: 1px solid #dcfce7;
  font-size: 13px;
  color: #15803d;
  font-weight: 600;
  flex-shrink: 0;
}

/* Draft col reveal */
.agent-draft-col.draft-hidden { display: none; }
@keyframes draftReveal {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}
.agent-draft-col.draft-reveal { animation: draftReveal .28s ease forwards; }

/* Responsive */
@media (max-width: 700px) {
  .agent-body { flex-direction: column; }
  .agent-draft-col { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .agent-draft-card { flex: 1; min-width: 200px; }
  .agent-wrap { height: auto; }
  .agent-hero h1 { font-size: 18px; }
  .agent-samples-card { flex-direction: column; align-items: flex-start; }
  .agent-modal-box { height: 80vh; }
  .agent-hero-inner { flex-direction: column; }
  .agent-hero-note { max-width: 100%; border-left: none; border-top: 1px solid rgba(99,102,241,0.18); border-radius: 0 0 14px 14px; padding: 10px 0 14px; background: none; }
}
