/* ─── DeSalvo PI Chat Widget ─────────────────────────────────────────────── */

:root {
  --dpc-primary:      #1a3a5c;
  --dpc-primary-dark: #122840;
  --dpc-accent:       #c8a96e;
  --dpc-accent-dark:  #b8914e;
  --dpc-bg:           #ffffff;
  --dpc-bg-light:     #f4f6f9;
  --dpc-border:       #dde3ec;
  --dpc-text:         #1a1a2e;
  --dpc-text-light:   #5a6478;
  --dpc-bubble-user:  #1a3a5c;
  --dpc-bubble-ai:    #f0f3f8;
  --dpc-radius:       16px;
  --dpc-shadow:       0 8px 32px rgba(26,58,92,0.15);
  --dpc-font:         'Georgia', 'Times New Roman', serif;
  --dpc-font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── Wrapper ──────────────────────────────────────────────────────────────── */
.dpc-wrapper {
  font-family: var(--dpc-font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--dpc-text);
  box-sizing: border-box;
}

.dpc-wrapper *,
.dpc-wrapper *::before,
.dpc-wrapper *::after {
  box-sizing: border-box;
}

/* ─── Inline mode ──────────────────────────────────────────────────────────── */
.dpc-inline-mode .dpc-chat-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  border-radius: var(--dpc-radius);
  border: 1px solid var(--dpc-border);
  box-shadow: var(--dpc-shadow);
  display: flex;
  flex-direction: column;
  background: var(--dpc-bg);
  overflow: hidden;
}

/* ─── Bubble mode ──────────────────────────────────────────────────────────── */
.dpc-bubble-mode {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
}

.dpc-bubble-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--dpc-primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26,58,92,0.35);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--dpc-font-ui);
  transition: background 0.2s, transform 0.15s;
}

.dpc-bubble-trigger:hover {
  background: var(--dpc-primary-dark);
  transform: translateY(-2px);
}

.dpc-bubble-trigger.dpc-hidden {
  display: none;
}

.dpc-bubble-mode .dpc-chat-container {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  border-radius: var(--dpc-radius);
  border: 1px solid var(--dpc-border);
  box-shadow: var(--dpc-shadow);
  background: var(--dpc-bg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  max-height: 80vh;
}

.dpc-bubble-mode .dpc-chat-container.dpc-open {
  display: flex;
  animation: dpc-slide-up 0.25s ease;
}

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

/* ─── Header ───────────────────────────────────────────────────────────────── */
.dpc-chat-header {
  background: var(--dpc-primary);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.dpc-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dpc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--dpc-accent);
  color: var(--dpc-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.dpc-header-name {
  font-weight: 600;
  font-size: 15px;
}

.dpc-header-sub {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}

.dpc-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
  line-height: 1;
}

.dpc-close-btn:hover {
  color: #fff;
}

/* ─── Messages ─────────────────────────────────────────────────────────────── */
.dpc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 420px;
  background: var(--dpc-bg-light);
}

.dpc-message {
  display: flex;
  max-width: 85%;
}

.dpc-message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dpc-message-assistant {
  align-self: flex-start;
}

.dpc-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.dpc-message-assistant .dpc-bubble {
  background: var(--dpc-bubble-ai);
  color: var(--dpc-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--dpc-border);
}

.dpc-message-user .dpc-bubble {
  background: var(--dpc-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ─── Typing indicator ─────────────────────────────────────────────────────── */
.dpc-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.dpc-typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dpc-text-light);
  animation: dpc-bounce 1.2s ease-in-out infinite;
}

.dpc-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.dpc-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dpc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ─── Contact gate ─────────────────────────────────────────────────────────── */
.dpc-contact-gate {
  padding: 20px;
  background: var(--dpc-bg);
  border-top: 1px solid var(--dpc-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dpc-gate-intro {
  font-weight: 600;
  color: var(--dpc-primary);
  margin: 0;
  font-size: 15px;
}

.dpc-gate-reason {
  font-size: 13px;
  color: var(--dpc-text-light);
  margin: 0;
  line-height: 1.5;
}

.dpc-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--dpc-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--dpc-font-ui);
  color: var(--dpc-text);
  background: var(--dpc-bg);
  transition: border-color 0.2s;
  outline: none;
}

.dpc-input:focus {
  border-color: var(--dpc-primary);
}

.dpc-submit-btn {
  width: 100%;
  padding: 13px;
  background: var(--dpc-accent);
  color: var(--dpc-primary-dark);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--dpc-font-ui);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  letter-spacing: 0.01em;
}

.dpc-submit-btn:hover:not(:disabled) {
  background: var(--dpc-accent-dark);
  transform: translateY(-1px);
}

.dpc-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dpc-privacy {
  font-size: 12px;
  color: var(--dpc-text-light);
  text-align: center;
  margin: 0;
}

.dpc-gate-error {
  color: #c0392b;
  font-size: 13px;
  margin: 0;
  padding: 8px 12px;
  background: #fdf0ef;
  border-radius: 6px;
  border: 1px solid #f5c6c2;
}

/* ─── Input area ───────────────────────────────────────────────────────────── */
.dpc-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--dpc-bg);
  border-top: 1px solid var(--dpc-border);
  flex-shrink: 0;
}

.dpc-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--dpc-border);
  border-radius: 22px;
  font-size: 14px;
  font-family: var(--dpc-font-ui);
  color: var(--dpc-text);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.dpc-textarea:focus {
  border-color: var(--dpc-primary);
}

.dpc-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--dpc-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.dpc-send-btn:hover:not(:disabled) {
  background: var(--dpc-primary-dark);
  transform: scale(1.05);
}

.dpc-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Disclaimer ───────────────────────────────────────────────────────────── */
.dpc-disclaimer {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--dpc-text-light);
  text-align: center;
  border-top: 1px solid var(--dpc-border);
  background: var(--dpc-bg-light);
  flex-shrink: 0;
}

.dpc-disclaimer a {
  color: var(--dpc-primary);
  text-decoration: none;
}

.dpc-disclaimer a:hover {
  text-decoration: underline;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
.dpc-messages::-webkit-scrollbar { width: 4px; }
.dpc-messages::-webkit-scrollbar-track { background: transparent; }
.dpc-messages::-webkit-scrollbar-thumb { background: var(--dpc-border); border-radius: 2px; }

/* ─── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dpc-bubble-mode {
    bottom: 16px;
    right: 16px;
  }

  .dpc-bubble-mode .dpc-chat-container {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 64px;
  }

  .dpc-bubble-label {
    display: none;
  }

  .dpc-bubble-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
  }

  .dpc-messages {
    max-height: 50vh;
  }
}
