/* ============================================================
   SentryTitle AI Chat Widget
   ============================================================ */

#st-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1f4d2b;
  color: #f8f6f3;
  border: 2px solid #143a1f;
  box-shadow: 0 4px 14px rgba(31, 77, 43, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
}

#st-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(31, 77, 43, 0.45);
}

#st-chat-launcher svg {
  width: 26px;
  height: 26px;
  fill: #f8f6f3;
}

#st-chat-launcher.hidden { display: none; }

#st-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 48px);
  background: #f8f6f3;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(61, 40, 23, 0.25);
  border: 1px solid #ece5d8;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: 'Roboto', Arial, sans-serif;
  color: #2a1a0e;
}

#st-chat-panel.open {
  display: flex;
  animation: stChatSlideUp 0.25s ease-out;
}

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

.st-chat-header {
  background: #1f4d2b;
  color: #f8f6f3;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid #143a1f;
  flex-shrink: 0;
}

.st-chat-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.st-chat-title small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.85;
  margin-top: 2px;
  letter-spacing: 0;
}

.st-chat-reset,
.st-chat-close {
  background: transparent;
  color: #f8f6f3;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
  font-family: inherit;
}
.st-chat-reset:hover,
.st-chat-close:hover {
  opacity: 1;
  background: rgba(248, 246, 243, 0.15);
}
.st-chat-close {
  font-size: 20px;
  line-height: 1;
  margin-left: 4px;
  padding: 2px 8px;
}

.st-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8f6f3;
}

.st-chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.st-chat-msg.user {
  align-self: flex-end;
  background: #1f4d2b;
  color: #f8f6f3;
  border-bottom-right-radius: 4px;
}
.st-chat-msg.user a { color: #f8f6f3; }

.st-chat-msg.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #2a1a0e;
  border: 1px solid #ece5d8;
  border-bottom-left-radius: 4px;
}

.st-chat-msg strong { font-weight: 600; }
.st-chat-msg em { font-style: italic; }
.st-chat-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.st-chat-typing {
  align-self: flex-start;
  background: #ffffff;
  color: #5c3a1f;
  border: 1px solid #ece5d8;
  padding: 9px 13px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 13px;
  font-style: italic;
}
.st-chat-typing .dots span {
  display: inline-block;
  animation: stChatBlink 1.3s infinite;
}
.st-chat-typing .dots span:nth-child(2) { animation-delay: 0.15s; }
.st-chat-typing .dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes stChatBlink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

.st-chat-attachment {
  background: #ece5d8;
  border-top: 1px solid #d4c8b3;
  padding: 8px 14px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-shrink: 0;
}
.st-chat-attachment.shown { display: flex; }
.st-chat-attachment .filename {
  flex: 1;
  color: #3d2817;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-chat-attachment .remove {
  background: transparent;
  border: none;
  color: #3d2817;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  font-family: inherit;
}
.st-chat-attachment .remove:hover { color: #1f4d2b; }

.st-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px;
  background: #ffffff;
  border-top: 1px solid #ece5d8;
  flex-shrink: 0;
}

.st-chat-attach,
.st-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.st-chat-attach {
  background: transparent;
  border: 1px solid #d4c8b3;
  color: #5c3a1f;
}
.st-chat-attach:hover {
  background: #ece5d8;
  border-color: #5c3a1f;
}
.st-chat-send {
  background: #1f4d2b;
  color: #f8f6f3;
  border: 1px solid #143a1f;
}
.st-chat-send:hover { background: #143a1f; }
.st-chat-send:disabled {
  background: #b5b0a8;
  border-color: #b5b0a8;
  cursor: not-allowed;
}

.st-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #d4c8b3;
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Roboto', Arial, sans-serif;
  font-size: 14px;
  color: #2a1a0e;
  background: #ffffff;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
  box-sizing: border-box;
}
.st-chat-input:focus {
  outline: none;
  border-color: #1f4d2b;
  box-shadow: 0 0 0 2px rgba(31, 77, 43, 0.15);
}

.st-chat-error {
  align-self: stretch;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 13px;
}

.st-chat-footer-note {
  padding: 6px 12px;
  background: #ece5d8;
  color: #5c3a1f;
  font-size: 10.5px;
  text-align: center;
  border-top: 1px solid #d4c8b3;
  line-height: 1.3;
  flex-shrink: 0;
}

/* Mobile: full-screen takeover */
@media (max-width: 480px) {
  #st-chat-launcher {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  #st-chat-launcher svg { width: 24px; height: 24px; }
  #st-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
}

/* Don't print the widget */
@media print {
  #st-chat-launcher, #st-chat-panel { display: none !important; }
}
