/* Force light-mode rendering */
html {
  color-scheme: light;
}

/* 1) Define theme variables */
:root {
  /* Accent */
  --accent-color: #1684bb;
  --accent-text: white;

  /* Overlay */
  --overlay-bg: rgba(0, 0, 0, 0.1);

  /* Container */
  --container-bg: rgba(250, 250, 250, 1); 
  --container-border: rgba(255, 255, 255, 0.4);

  /* Header */
  --header-bg: rgba(255, 255, 255, 0.6);
  --header-border: rgba(0, 0, 0, 0.06);
  --header-text: #1a1a1a;

  /* Messages */
  --you-bg: #1684bb;
  --you-text: white;

  --bot-bg: rgba(255, 255, 255, 0.7);
  --bot-border: rgba(0, 0, 0, 0.06);
  --bot-text: #1a1a1a;

  --system-bg: rgba(0, 0, 0, 0.05);
  --system-border: rgba(0, 0, 0, 0.06);
  --system-text: #666;

  /* Typing */
  --typing-bg: rgba(255, 255, 255, 0.7);
  --typing-text: #666;

  /* Input */
  --input-bg: rgba(255, 255, 255, 0.7);
  --container-bg: rgba(250, 250, 250, 1); 
  --input-text: #1a1a1a;
  --input-placeholder: #717171;

  /* Send button */
  --container-bg: rgba(250, 250, 250, 1); 
}

/* 2) Chat Button */
#openChat {
  position: fixed !important;
  bottom: 2rem;
  right: 2rem;
  width: 65px;
  height: 65px;
  border: none;
  border-radius: 50px;
  background: var(--accent-color);
  color: var(--accent-text);
  cursor: pointer;
  z-index: 9998 !important;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transform: scale(1);
  will-change: transform;
  overflow: hidden;
  position: relative;
}

#openChat::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#openChat::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

#openChat > * {
  position: relative;
  z-index: 2;
}

#openChat:hover {
  transform: scale(1.02) translateY(-2px);
}

#openChat:active {
  transform: scale(0.98);
}

/* 3) Overlay */
#chatOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  z-index: 9999 !important;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatOverlay.open {
  opacity: 1;
  visibility: visible;
}

/* 4) Container */
#chatContainer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 1200px;
  height: 105vh;
  max-height: 1200px;
  background: var(--container-bg);
  border: 0.5px solid var(--container-border);
  border-radius: 25px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 6px 6px rgba(0, 0, 0, 0.2),
    0 0 20px rgba(0, 0, 0, 0.1),
    inset 2px 2px 1px rgba(255, 255, 255, 0.2),
    inset -1px -1px 1px rgba(255, 255, 255, 0.2);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000 !important;
}

#chatOverlay.open #chatContainer {
  transform: translate(-50%, -50%) scale(1);
}

/* 5) Header */
#chatHeader {
  padding: 1.25rem 1.5rem 0.75rem;
  background: var(--header-bg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  z-index: 10;
}

#chatHeader h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--header-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 7) Controls */
.header-controls { display: block !important; }
.header-controls .model-selector,
.header-controls .tools-selector,
.header-controls .info-btn {
  display: inline-block !important;
  vertical-align: middle !important;
}
.header-controls .model-selector { width: 220px !important; }
.header-controls .tools-selector { width: 120px !important; }
.header-controls .info-btn      { width: 40px  !important; }

/* 8) Model Selector */
.model-selector { position: relative; z-index: 11; }
.model-selector-btn {
  padding: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 100%;
  width: 100%;
  min-width: 100px;
}

/* 9) Tools Selector */
.tools-selector { position: relative; z-index: 11; }
.tools-selector-btn {
  padding: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 100%;
  width: 100%;
  min-width: 100px;
}


.model-selector-btn,
.tools-selector-btn {
  border: none;
  cursor: pointer;
  border-radius: 3px;
  background: #fff;                         /* match the header strip */
  transition: all 0.15s ease;
}

/* 11) Export Chat Tool */
.tool-option[data-action="export-chat"] { position: relative !important; }
.export-submenu {
  position: absolute;
  top: 0;
  left: 100%;
  border-radius: 12px;
  padding: 0.5rem;
  width: 80%;
  margin-left: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-70px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100004 !important;
}
.export-submenu.open {
  opacity: 1 !important;
  visibility: visible !important;
}
.tool-option[data-action="export-chat"]:hover .export-submenu,
.tool-option[data-action="export-chat"]:focus .export-submenu,
.export-submenu:hover {
  opacity: 1!important;
  visibility: visible!important;
  transform: translateX(0)!important;
  background-color: #FFFFFF !important;
}
.export-format {
  display: flex;
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  font-weight: 500;
}
.export-format:hover {
  background: rgba(244,249,255,0.08) !important;
  border-color: rgba(0,122,255,0.2) !important;
}
.export-format:active {
  transform: translateY(0) !important;
  background: rgba(0,122,255,0.15) !important;
}

.format-icon {
  width: 100%;
  height: 40px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.format-icon:hover {
  background: rgba(0,122,255,0.08);
  box-shadow:
    0 4px 4px rgba(0,0,0,0.2),
    0 0 18px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.1),
    inset -1px -1px 1px rgba(255,255,255,0.1);
}

.tool-option[data-action="export-chat"]:hover .tool-info .tool-name::after { transform:translateX(2px); }
.tools-dropdown { overflow: visible!important; justify-content: space-between;}

/* 12) Responsive */
@media (max-width: 768px) {
  .export-submenu {
    position: fixed; top:50%; left:50%; transform:translate(-50%,-50%); margin:0;
    width:280px; max-width:90vw;
  }
  .tool-option[data-action="export-chat"]:hover .export-submenu {
    transform:translate(-50%,-50%);
  }
  .export-submenu::before {
    content:''; position:fixed; top:0; left:0; width:100vw; height:100vh;
    background:rgba(0,0,0,0.3);
  }
}

.model-selector-btn span,
.tools-selector-btn span {
  text-align:left; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.dropdown-arrow {
  flex-shrink:0; transition:transform 0.15s ease; color:#717171; width:14px; height:14px;
}
.model-selector-btn.open .dropdown-arrow,
.tools-selector-btn.open .dropdown-arrow { transform:rotate(180deg); }

/* 13) Dropdown Menus */
.model-dropdown,
.tools-dropdown {
  position:absolute; top:calc(100%+0.25rem); left:0; right:0;
  background: rgba(255,255,255,0.98);
  border:0.5px solid rgba(0,0,0,0.1);
  border-radius:15px;
  box-shadow:
    0 6px 6px rgba(0,0,0,0.2),
    0 0 20px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.3),
    inset -1px -1px 1px rgba(255,255,255,0.3);
  opacity:0; visibility:hidden; transform:translateY(-4px);
  transition:all 0.15s ease; z-index:11; overflow:hidden; padding:0.5rem;
}
.model-dropdown.open,
.tools-dropdown.open { opacity:0.98; visibility:visible; transform:translateY(0); cursor: pointer;}

.model-option {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0.375rem 0.625rem;
  margin: -0.5rem -0.5rem 0;
  margin-top: 0.25rem;
  cursor: pointer;
  transition: all 0.1s ease;
  border-radius: 8px;
  min-height: 40px;
}

.model-option:hover:not(.disabled),
.tool-option:hover:not(.disabled) {
  background: rgba(0, 122, 255, 0.08);
  box-shadow:
    0 4px 4px rgba(0, 0, 0, 0.2),
    0 0 18px rgba(0, 0, 0, 0.1),
    inset 2px 2px 1px rgba(255, 255, 255, 0.1),
    inset -1px -1px 1px rgba(255, 255, 255, 0.1);
}

/* ✅ Checkmark to the right */
.model-option.active::after {
  content: "✔";
  color: black; /* <-- black checkmark */
  font-size: 0.875rem;
  margin-left: 8px;
  position: absolute;
  right: 0.75rem; /* aligns right side */
}

/* ✅ Remove background and left padding for active */
.model-option.active {
  background: transparent !important;
  box-shadow: none !important;
}

/* ✅ Prevent left shift */
.model-option .model-info {
  padding-left: 0;
  font-weight: 500;
}

.model-option .model-name {
  font-weight: 500;
  color: inherit;
  padding-left: 0;
}

.model-option.active .model-name {
  font-weight: 600;
  color: #007AFF;
}

/* ✅ Hide model descriptions if you're keeping the HTML */
.model-desc {
  display: none;
}
.model-option.disabled,
.tool-option.disabled { opacity:0.4; cursor:not-allowed; }
.model-option svg,
.tool-option svg { color:#666; width:16px; height:16px; }
.model-option.active svg { color:#007AFF; }
.model-info,
.tool-info {min-width:0; }
.model-name,
.tool-name { font-weight:500; font-size:0.875rem; color:inherit; letter-spacing:-0.01em; }
.model-desc,
.tool-desc { font-size:0.75rem; color:#717171; margin-top:0.125rem; }

/* 14) Close Button */
#closeChat {
  position:absolute; top:1rem; right:1rem;
  width:30px; height:30px; border:none; border-radius:8px;
  background:rgba(0,0,0,0.04); color:#666; cursor:pointer;
  transition:all 0.15s ease; display:flex; align-items:center; justify-content:center;
}
#closeChat:hover { background:rgba(0,0,0,0.08); color:#333; }
#closeChat:active { transform:scale(0.95); }
#closeChat svg { width:16px; height:16px; }

/* 15) Chat Log */
#chatLog {
  flex:1; padding:1rem; overflow-y:auto;
  display:flex; flex-direction:column; gap:0.75rem;
}
#chatLog::-webkit-scrollbar { width:6px; }
#chatLog::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.15); border-radius:3px; }
#chatLog::-webkit-scrollbar-thumb:hover { background:rgba(0,0,0,0.25); }

/* 16) Messages */
.message { display:flex; flex-direction:column; margin:0.25rem 0; animation:messageSlideIn 0.1s cubic-bezier(0.4,0,0.2,1); }
@keyframes messageSlideIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.message.you { align-items:flex-end; }
.message.bot { align-items:flex-start; }
.message.system { align-items:center; }

.message-content {
  max-width:85%; padding:0.3rem 0.8rem; border-radius:20px;
  word-wrap:break-word; font-size:0.9375rem; line-height:1.5; letter-spacing:-0.01em;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}
.message.you .message-content { background:var(--you-bg); color:var(--you-text); border-bottom-right-radius:4px; font-weight:500; }
.message.bot .message-content { background:var(--bot-bg); border:0.5px solid var(--bot-border); color:var(--bot-text); border-bottom-left-radius:4px; }
.message.system .message-content { background:var(--system-bg); border:0.5px solid var(--system-border); color:var(--system-text); font-size:0.875rem; max-width:90%; text-align:center; border-radius:12px; padding:0.625rem 1rem; font-weight:500; }

.message.system .message-content.success { background:rgba(16,185,129,0.1); border-color:rgba(16,185,129,0.2); color:#059669; }
.message.system .message-content.warning { background:rgba(245,158,11,0.1); border-color:rgba(245,158,11,0.2); color:#D97706; }
.message.system .message-content.info    { background:rgba(59,130,246,0.1); border-color:rgba(59,130,246,0.2); color:#2563EB; }
.message.system .message-content.loading { background:rgba(99,102,241,0.1); border-color:rgba(99,102,241,0.2); color:#5B21B6; }

/* 17) Typing Indicator */
.typing-indicator {
  display:flex; align-items:center; gap:0.5rem;
  background:var(--typing-bg); border:0.5px solid rgba(0,0,0,0.06);
  border-radius:16px; border-bottom-left-radius:4px;
  padding:0.75rem 1rem; color:var(--typing-text);
  box-shadow:0 1px 3px rgba(0,0,0,0.04); max-width:85%; font-size:0.875rem; font-weight:500;
}
.typing-dots { display:flex; gap:0.25rem; }
.typing-dots span { width:7px; height:7px; background:#717171; border-radius:50%; animation:typing 1.1s infinite; }
.typing-dots span:nth-child(2) { animation-delay:0.2s; }
.typing-dots span:nth-child(3) { animation-delay:0.4s; }
@keyframes typing { 0%,60%,100% { transform:scale(1); opacity:0.4; } 30% { transform:scale(1.3); opacity:1; } }

/* 18) Input Form */
#chatForm { padding:0.75rem 1rem 0; position:relative; }
.chat-warning { position:absolute; bottom:0.375rem; left:50%; transform:translateX(-50%); font-size:0.6875rem; color:#717171; white-space:nowrap; letter-spacing:-0.01em; }
.input-container { display:flex; gap:0.5rem; align-items:flex-end; position:relative; }
#chatInput {
  flex:1; border:none; border-radius:20px; padding:0.625rem 1rem;
  background:var(--input-bg); 
  border:0.5px solid var(--input-border); color:var(--input-text);
  font-size:0.9375rem; line-height:1.4; resize:none; outline:none;
  transition:all 0.15s ease;
  box-shadow:
    0 5px 5px rgba(0,0,0,0.2),
    0 0 20px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.1),
    inset -1px -1px 1px rgba(255,255,255,0.1);
  overflow-y:auto; scrollbar-width:none;
  min-height: 2.5rem;    /* starting height */
  max-height: 100vh;    /* limit so it doesn’t overflow the viewport */
}
#chatInput::-webkit-scrollbar { display:none; }
#chatInput:focus { background:rgba(255,255,255,0.9); box-shadow:
    0 6px 6px rgba(0,0,0,0.2),
    0 0 20px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.5),
    inset -1px -1px 1px rgba(255,255,255,0.5);
}
#chatInput::placeholder { color:var(--input-placeholder); }

#sendButton {
  width:46px; height:46px; border:none; border-radius:50px;
  background: #fff !important;   cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 0.15s ease;
  flex-shrink:0; overflow:hidden; position:relative;
}
#sendButton svg { width:40px; height:40px; }
#sendButton::before { content:""; position:absolute; inset:0; z-index:0; pointer-events:none; }
#sendButton::after { content:""; position:absolute; inset:0; z-index:1; background:rgb(39, 39, 39); pointer-events:none; }
#sendButton > * { position:relative; z-index:2; }
#sendButton:hover:not(:disabled) { transform:scale(1.05); }
#sendButton:active { transform:scale(0.95); }
#sendButton:disabled { opacity:0.5; cursor:not-allowed; }

/* 19) Guiding Questions */
.guiding-questions { max-width:100%!important; box-shadow:
    0 5px 5px rgba(0,0,0,0.2),
    0 0 20px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.1),
    inset -1px -1px 1px rgba(255,255,255,0.1);
}
.question-item {
  cursor:pointer; padding:0.5rem 0.75rem; margin:0.25rem 0;
  border-radius:15px; background:rgba(0,0,0,0.03);
  transition:all 0.15s ease; border:0.5px solid;
  font-size:0.875rem; line-height:1.4;
  box-shadow:
    0 5px 5px rgba(0,0,0,0.2),
    0 0 20px rgba(0,0,0,0.1),
    inset 2px 2px 1px rgba(255,255,255,0.1),
    inset -1px -1px 1px rgba(255,255,255,0.1);
}
.question-item:hover { background:rgba(0,122,255,0.08)!important; transform:translateX(2px); border-color:rgba(0,122,255,0.2); }
.question-item.used { background:rgba(16,185,129,0.08)!important; border-color:rgba(16,185,129,0.2); opacity:0.7; }
.question-item.used::after { content:' ✓'; color:#10B981; font-weight:600; }

/* 20) Mobile responsive */
@media (max-width: 640px) {
  #chatContainer { width:95%; height:90vh; max-width:420px; border-radius:16px; }
  #chatHeader { padding:1rem 1.25rem 0.625rem; }
  #chatHeader h2 { font-size:1rem; }
  .header-controls { gap:0.5rem; }
  .model-selector-btn,
  .tools-selector-btn { height:32px; padding:0.375rem 0.625rem; font-size:0.8125rem; }
  .info-btn { width:32px; height:32px; }
  .model-option,
  .tool-option { min-height:36px; padding:0.375rem 0.625rem; }
  .model-name,
  .tool-name { font-size:0.8125rem; }
  .model-desc,
  .tool-desc { font-size:0.6875rem; }
  .message-content { font-size:0.875rem; padding:0.625rem 0.875rem; }
  #chatInput { font-size:0.875rem; padding:0.5rem 0.875rem; min-height:36px; }
  #sendButton { width:34px; height:34px; }
  .chat-warning { font-size:0.625rem; }
}

/* 21) Footer */
#chatFooter {
  font-size:0.75rem;
  color:#373737;
  text-align:center;
  padding:10px;
}



/* ── Model-dropdown header row ─────────────────────────────────────── */
/* Label + tooltip row inside modelDropdown */
.model-info-row {
  align-items: center;
  gap: 3px;
  padding: 0.4rem 0.75rem 0.3rem;
  margin: -0.5rem -0.5rem 0;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

/* Reuse your existing class */
.model-dropdown-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1a1a1a;
}

.model-info-tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.model-info-icon {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.model-info-tooltip-text {
  position: absolute;
  transform: translateX(7%);
  background-color: #1a1a1a;
  padding: 0rem 0.1rem;
  color: #fff;
  font-size: 0.5875rem;
  font-weight: 500;
  border-radius: 3px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.model-info-tooltip-wrapper:hover .model-info-tooltip-text {
  opacity: 1;
  visibility: visible;
}

.message-content p {
  margin: 0 0 0 0;
  font-size: 0.9375rem;
}
.progress-bar {
  background: #ececec;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  max-width: 400px;
  margin: 0.5rem auto;
  height: 8px;
}

.progress-inner {
  background: #2264a5;
  height: 100%;
  transition: width 0.2s ease;
}

/* float+fade out animation */
@keyframes floatAway {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* when this class is added, the message will play the floatAway animation */
.message.float-away {
  animation: floatAway 0.6s ease-out forwards;
}