/* v2 chat CSS for GPT Chat plugin. Ensure accessibility and modern UI. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

:root {
  /* Colors */
  --main:               #38d3d5;
  --accent:             #ff914d;
  --assistant-border:   var(--accent);
  --user-border:        var(--main);
  --assistant-bg: #f4f6f8;
  --assistant-text: #333333;
  --user-bg: rgba(255,255,255,0.15);
  --user-text: #ffffff;
  --link:               #004aa3;
  --bg:                 #f8fafe;
  /* Sizing */
  --radius:             24px;
  --shadow-light:       0 4px 16px rgba(27,50,117,0.05);
  --container-height:   80vh;
  --container-min-height: 600px;
  --mobile-break:       540px;
  --header-height:      110px; /* adjust to your real header/footer */
  --footer-height:      110px;
  /* Send button */
  --send-size:          56px  !important;
  --icon-size:          32px  !important;
  --send-shadow:        0 4px 12px rgba(0,0,0,0.08);
  --chat-gradient-start: #061429;
  --chat-gradient-end:   #00326f;
}

.gpt-chat-container {
  background: linear-gradient(
    180deg,
    var(--chat-gradient-start) 0%,
    var(--chat-gradient-end)   100%
  );
  box-shadow: var(--shadow-light);
  border-radius: var(--radius);
  max-width: 600px; width: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column;
  height: var(--container-height);
  min-height: var(--container-min-height);
  overflow: hidden;
  font-family: 'Inter', Arial, sans-serif;
}

.chat-header {
  text-align: center;
  padding: 20px 0 10px;
  background: rgba(255,145,77,0.05);
}

.chat-logo {
  width: 52px;
  height: 52px;
  padding: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 50% !important;
  box-shadow: var(--shadow-light);
  object-fit: contain;
}

/* Messages */
.chat-messages {
  flex: 1;
  padding: 0 16px 16px;
  overflow-y: auto;
}

.chat-msg {
  display: flex; align-items: flex-end;
  margin-bottom: 13px;
  opacity: 0; transform: translateY(18px);
  animation: bubbleIn .37s cubic-bezier(.7,.05,.36,1.02) forwards;
}

@keyframes bubbleIn { 
  to { opacity:1; transform:none; } 
}

.chat-user  { flex-direction: row-reverse; }
.chat-assistant { flex-direction: row; }

/* Avatars */
.avatar {
  width:36px; height:36px;
  border-radius:50%;
  background:#fff;
  border:2.5px solid var(--border);
  box-shadow:0 2px 8px #1231ad11;
  margin:0 8px;
  display:flex; align-items:center; justify-content:center;
}

/* Bubble */
.bubble {
  background:#fff;
  color: var(--text-main);
  border-radius: var(--radius);
  box-shadow: var(--shadow-light);
  padding: 12px 18px;
  font-size:1.09rem; line-height:1.54;
  max-width:94vw; word-break:break-word; white-space:pre-line;
  border:2px solid transparent; position:relative;
  transition: border-color .14s, background .13s;
}

/* User bubble */
.chat-user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  max-width: 75%;
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 20px 0px 20px 20px;
  font-size: 16px;
  line-height: 1.4;
  display: inline-block;
  float: right;
  clear: both;
}

.chat-assistant .bubble {
  background: var(--assistant-bg);
  color: var(--assistant-text);
  max-width: 75%;
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 20px 20px 20px 0px;
  font-size: 16px;
  line-height: 1.4;
  display: inline-block;
}

.bubble a {
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

.bubble a:hover, .bubble a:focus {
  text-decoration: underline;
  outline: 2px dashed #1e5ad7;
  outline-offset: 2px;
}

.bubble ol, .bubble ul {
  margin: 0 0 0 1.2em;
  padding-left: 0.8em;
}

.bubble ol li,
.bubble ul li {
  margin-bottom: 0.8em;
}

/* Input bar */
.chat-form {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: transparent;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 30px;
  color: #595959;
  font-size: 16px;
  outline: none;
}

.chat-input:focus {
  background:#fffafa;
  border:2px solid var(--main);
  outline:2px solid var(--main);
}

.chat-form button {
  background: none;
  border: none;
  margin-left: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50%;
  background: transparent;
}

.chat-form button svg {
  fill: #fff;
  width: 40px !important;
  height: 40px !important;
  color: #fff;
}

/* UNIFIED TYPING INDICATOR */
.chat-assistant.typing .bubble {
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.chat-assistant.typing .thinking-text {
  font-style: italic;
  font-weight: 500;
  font-size: 15px;
  color: #fff;
}

.chat-assistant.typing .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.3;
  animation: typingBlink 1.5s infinite ease-in-out;
  vertical-align: baseline;
  position: relative;
  top: 5px;
  margin-left: 4px;
}

.chat-assistant.typing .dot.one { animation-delay: 0s; }
.chat-assistant.typing .dot.two { animation-delay: 0.2s; }
.chat-assistant.typing .dot.three { animation-delay: 0.4s; }

@keyframes typingBlink {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.3);
  }
}

/* Custom scrollbars for the chat window */
.chat-messages {
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--chat-gradient-start);
}

/* WebKit (Chrome, Safari, Edge) */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--chat-gradient-start);
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 4px;
  border: 2px solid var(--chat-gradient-start);
}

/* Force the button to use the new size */
.chat-form button[type="submit"] {
  width:   var(--send-size) !important;
  height:  var(--send-size) !important;
  padding: 0 !important;
  margin:  0 !important;
  box-sizing: content-box !important;
}

.chat-form button[type="submit"] svg {
  width:  var(--icon-size) !important;
  height: var(--icon-size) !important;
}

/* Responsive mobile */
@media (max-width: var(--mobile-break)) {
  .gpt-chat-container {
    position:fixed;
    top: var(--header-height);
    bottom: var(--footer-height);
    left:0; right:0;
    width:100vw !important; max-width:none !important;
    margin:0 !important; border-radius:0 !important;
    box-shadow:none !important; z-index:999;
  }
  .chat-messages {
    height:calc(100% - 64px - env(safe-area-inset-bottom));
    max-height:none !important;
  }
  .chat-form {
    padding-bottom:calc(13px + env(safe-area-inset-bottom));
  }
}