/* Papico Legal Consulting — AI Triage Widget */

:root {
  --p-blue: #347de5;
  --p-blue-dark: #2568cc;
  --p-neutral: #ece8e1;
  --p-orange: #ec8953;
  --p-black: #1a1a1a;
  --p-mid: #666;
  --p-light: #999;
  --p-border: #e2ddd6;
  --p-surface: #f8f6f2;
  --p-white: #ffffff;
}

.papico-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.papico-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--p-black);
  width: 100%;
  max-width: 680px;
  background: var(--p-white);
  border: 1px solid var(--p-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */

.papico-widget-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px 0;
  min-height: 28px;
}

.papico-widget-reset {
  font-size: 12px;
  color: var(--p-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
  display: none;
}

.papico-widget-reset:hover {
  color: var(--p-mid);
}

.papico-widget-reset.visible {
  display: block;
}

/* ── Open stage ──────────────────────────────────────── */

.papico-stage-open {
  padding: 10px 20px 22px;
}

.papico-open-title {
  font-size: 21px;
  font-weight: 600;
  color: var(--p-black);
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: 14px;
}

.papico-open-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--p-black);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.55;
}

.papico-open-textarea:focus {
  border-color: var(--p-blue);
  background: var(--p-white);
}

.papico-open-textarea::placeholder {
  color: #bbb5ae;
}

.papico-open-legal {
  font-size: 11px;
  color: var(--p-light);
  margin-top: 8px;
  line-height: 1.4;
}

.papico-open-legal a {
  color: inherit;
  text-decoration: underline;
}

.papico-open-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 12px;
}

.papico-privacy {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--p-light);
}

.papico-start-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: var(--p-blue);
  color: var(--p-white);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.papico-start-btn:hover {
  background: var(--p-blue-dark);
}

.papico-start-btn:active {
  transform: scale(0.97);
}

.papico-start-btn:disabled {
  background: #a8c4f0;
  cursor: not-allowed;
}

/* ── Chat stage ──────────────────────────────────────── */

.papico-stage-chat {
  display: none;
  flex-direction: column;
  height: 500px; /* fixed — widget never grows or shrinks */
}

.papico-stage-chat.active {
  display: flex;
}

.papico-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.papico-messages::-webkit-scrollbar {
  width: 3px;
}

.papico-messages::-webkit-scrollbar-track {
  background: transparent;
}

.papico-messages::-webkit-scrollbar-thumb {
  background: var(--p-border);
  border-radius: 2px;
}

/* Messages */

.papico-msg {
  max-width: 84%;
  font-size: 15px;
  line-height: 1.55;
}

.papico-msg-ai {
  align-self: flex-start;
  color: var(--p-black);
}

.papico-msg-sender {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--p-blue);
  margin-bottom: 5px;
}

.papico-msg-ai p {
  margin-bottom: 8px;
}

.papico-msg-ai p:last-child {
  margin-bottom: 0;
}

.papico-msg-user {
  align-self: flex-end;
  background: var(--p-blue);
  color: var(--p-white);
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  word-break: break-word;
}

/* Typing indicator */

.papico-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 0;
}

.papico-typing span {
  width: 6px;
  height: 6px;
  background: #c8c0b8;
  border-radius: 50%;
  animation: p-bounce 1.3s ease-in-out infinite;
}

.papico-typing span:nth-child(2) { animation-delay: 0.18s; }
.papico-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes p-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* CTA — replaces the input area on handoff */

@keyframes p-slide-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.papico-cta-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 10px;
  animation: p-slide-up 0.28s ease;
}

.papico-cta-inline-text {
  flex: 1;
  min-width: 0;
}

.papico-cta-inline-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.papico-cta-inline.book   .papico-cta-inline-label { color: #b05828; }
.papico-cta-inline.template .papico-cta-inline-label { color: #1d56a8; }
.papico-cta-inline.refer  .papico-cta-inline-label { color: var(--p-mid); }

.papico-cta-inline-body {
  font-size: 13px;
  color: var(--p-mid);
  line-height: 1.4;
}

.papico-cta-inline-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
}

.papico-cta-inline-btn:hover  { opacity: 0.85; }
.papico-cta-inline-btn:active { transform: scale(0.97); }

.papico-cta-inline.book   .papico-cta-inline-btn { background: var(--p-orange); color: #fff; }
.papico-cta-inline.template .papico-cta-inline-btn { background: var(--p-blue);   color: #fff; }
.papico-cta-inline.refer  .papico-cta-inline-btn { background: var(--p-black);  color: #fff; }

/* Input area */

.papico-input-wrap {
  border-top: 1px solid var(--p-border);
  padding: 10px 14px 6px;
}

.papico-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.papico-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--p-black);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 10px;
  resize: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.5;
  overflow: auto;
}

.papico-chat-input:focus {
  border-color: var(--p-blue);
  background: var(--p-white);
}

.papico-chat-input::placeholder {
  color: #bbb5ae;
}

.papico-chat-input:disabled {
  opacity: 0.5;
  cursor: default;
}

.papico-send-btn-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--p-blue);
  color: var(--p-white);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.papico-send-btn-icon:hover   { background: var(--p-blue-dark); }
.papico-send-btn-icon:active  { transform: scale(0.96); }
.papico-send-btn-icon:disabled { background: #a8c4f0; cursor: not-allowed; }

.papico-disclaimer {
  font-size: 11px;
  color: var(--p-light);
  text-align: center;
  padding: 7px 0 3px;
  line-height: 1.4;
}

.papico-disclaimer a {
  color: inherit;
  text-decoration: underline;
}

/* Responsive */

@media (max-width: 700px) {
  .papico-widget {
    max-width: 100%;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .papico-widget {
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  }

  .papico-stage-chat {
    height: 420px;
  }

  .papico-msg {
    max-width: 92%;
    font-size: 15px;
  }

  .papico-open-title {
    font-size: 19px;
  }

  .papico-chat-input {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
}
