/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}
:root {
  --text-color: #343541;
  --icon-color: #a9a9bc;
  --icon-hover-bg: #f1f1f3;
  --placeholder-color: #6c6c6c;
  --outgoing-chat-bg: #FFFFFF;
  --incoming-chat-bg: #F7F7F8;
  --input-chat-bg: #E7E7E8;
  --outgoing-chat-border: #FFFFFF;
  --incoming-chat-border: #D9D9E3;
}
/*
.light-mode {
  --text-color: #343541;
  --icon-color: #a9a9bc;
  --icon-hover-bg: #f1f1f3;
  --placeholder-color: #6c6c6c;
  --outgoing-chat-bg: #FFFFFF;
  --incoming-chat-bg: #F7F7F8;
  --outgoing-chat-border: #FFFFFF;
  --incoming-chat-border: #D9D9E3;
}
*/

.dark-mode {
  --text-color: #FFFFFF;
  --icon-color: #ACACBE;
  --icon-hover-bg: #5b5e71;
  --placeholder-color: #dcdcdc;
  --outgoing-chat-bg: #343541;
  --incoming-chat-bg: #444654;
  --outgoing-chat-border: #343541;
  --incoming-chat-border: #444654;
}
body {
  /*background: var(--outgoing-chat-bg);*/
}

#chatbot {
	background: var(--outgoing-chat-bg);	
	max-width: 100%;
	position:fixed; 
	right:0;
	bottom:0;
	min-height: 55px;
	border: 1px solid var(--text-color);
}
#chatbot .togglable {
	max-width: 100%;  
	width: 500px;
}
#trigger-container {
	background: var(--outgoing-chat-bg);
	background-image: url("images/TQ-AI-ChatGPT.gif");
	background-repeat: none;
	background-size: contain;
	position: absolute;
	right:5px;
	width: 55px; 
	height: 55px;
	opacity: 1.0;
}
#trigger-container:hover {	
	opacity: 1.0;
}
.hide-me {
	display: none !important;
}
/* Chats container styling */
.chat-container {
  overflow-y: auto;
  /*max-height: 70vh;*/
  padding-bottom: 120px;
}
:where(.chat-container, textarea)::-webkit-scrollbar {
  width: 6px;
}
:where(.chat-container, textarea)::-webkit-scrollbar-track {
  background: var(--incoming-chat-bg);
  border-radius: 25px;
}
:where(.chat-container, textarea)::-webkit-scrollbar-thumb {
  background: var(--icon-color);
  border-radius: 25px;
}
.default-text {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 70vh;
  padding: 0 10px;
  text-align: center;
  color: var(--text-color);
}
.default-text h1 {
  font-size: 3.3rem;
}
.default-text p {
  margin-top: 10px;
  font-size: 1.0rem;
}
.chat-container .chat {
  padding: 15px 10px;
  display: flex;
  justify-content: center;
  color: var(--text-color);
}
.chat-container .chat.outgoing {
  background: var(--outgoing-chat-bg);
  border: 1px solid var(--outgoing-chat-border);
}
.chat-container .chat.incoming {
  background: var(--incoming-chat-bg);
  border: 1px solid var(--incoming-chat-border);
}
.chat .chat-content {
  display: flex;
  max-width: 1200px;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
}
span.material-symbols-rounded {
  user-select: none;
  cursor: pointer;
}
.chat .chat-content span {
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--icon-color);
  visibility: hidden;
}
.chat:hover .chat-content:not(:has(.typing-animation), :has(.error)) span {
  visibility: visible;
}
.chat .chat-details {
  display: flex;
  align-items: center;
}
.chat .chat-details img {
  width: auto;
  height: 35px;
  align-self: flex-start;
  object-fit: cover;
  border-radius: 2px;
}
.chat .chat-details p {
  white-space: pre-wrap;
  font-size: 0.80rem;
  padding: 0 50px 0 25px;
  color: var(--text-color);
  word-break: break-word;
}
.chat .chat-details p.error {
  color: #e55865;
}
.chat .typing-animation {
  padding-left: 25px;
  display: inline-flex;
}
.typing-animation .typing-dot {
  height: 7px;
  width: 7px;
  border-radius: 50%;
  margin: 0 3px;
  opacity: 0.7;
  background: var(--text-color);
  animation: animateDots 1.5s var(--delay) ease-in-out infinite;
}
.typing-animation .typing-dot:first-child {
  margin-left: 0;
}
@keyframes animateDots {
  0%,44% {
    transform: translateY(0px);
  }
  28% {
    opacity: 0.4;
    transform: translateY(-6px);
  }
  44% {
    opacity: 0.2;
  }
}

/* Typing container styling */
.typing-container {
  position: fixed;
  bottom: 0;
  max-width: 100%;  
  width: 500px;
  display: flex;
  padding: 20px 10px;
  justify-content: center;
  background: var(--outgoing-chat-bg);
  border-top: 1px solid var(--incoming-chat-border);
  position:absolute; width:100%;bottom:30px;
}
.typing-container .typing-content {
  display: grid;                         /* switch to grid */
  grid-template-columns: 1fr 165px;      /* textarea takes all space, buttons fixed width */
  gap: 10px;
  max-width: 950px;
  width: 100%;
  align-items: stretch;                  /* textarea matches buttons height */
	/*
  display: flex;
  max-width: 950px;
  width: 100%;
  align-items: flex-end;
  */
}
.typing-container .typing-textarea {
  width: 100%;
  display: flex;
  position: relative;
}
.typing-textarea textarea {
  resize: none;
  height: 100%;                          /* grow with grid height */
  resize: vertical;
  min-height:68px;
  width: 100%;
  border: none;
  padding: 15px 45px 15px 20px;
  color: var(--text-color);
  font-size: 0.90rem;
  border-radius: 4px;
  max-height: 800px;
  overflow-y: auto;
  background: var(--input-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
}
.typing-textarea textarea::placeholder {
  color: var(--placeholder-color);
}
.typing-content span {
  width: 48px;
  height: 48px;
  display: flex;
  border-radius: 4px;
  font-size: 1.35rem;
  align-items: center;
  justify-content: center;
  color: var(--icon-color);
}
.typing-textarea span {
  position: absolute;
  right: 0;
  bottom: 12px;
}
.typing-textarea textarea:valid ~ span {
  color:#ffffff !important;
  background-color: #2EB67D !important;
}

#send-btn.active {
  color: #ffffff !important;
  background-color: #2EB67D !important;
}

.typing-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 48px;                  /* each button row same height */
  gap: 7px;
}

.typing-controls span {
  font-size: 1.4rem;
  background: var(--incoming-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
  cursor: pointer;
}
/*
.typing-controls {
  display: flex;
}
.typing-controls span {
  margin-left: 7px;
  font-size: 1.4rem;
  background: var(--incoming-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
}
*/

.typing-controls span:hover {
  background: var(--icon-hover-bg);
}


.button-sm {
  padding: 2px 10px;
  font-size: 0.9em;
}

/*
#chatbot {
	position: relative; 
	min-height: 840px; 
	max-width: 98%;
}
#chatbot #chat-container {
	min-height:540px;
	max-height:540px;
	border-bottom: 1px solid var(--incoming-chat-border);
}
*/

/* New CSS for Drag */

#chatbot-section {
  max-width: 960px;
  margin: 0 auto;          /* center horizontally */
}

/* -------------------------- */
/* Chatbot container */
/* -------------------------- */
#chatbot {
  position: relative;
  max-width: 98%;
  width: 98%;
  display: flex;
  flex-direction: column;
  height: 840px;             /* initial height */
  background: var(--outgoing-chat-bg);
  border: 1px solid var(--text-color);
  box-sizing: border-box;
  font-family: sans-serif;
}

/* -------------------------- */
/* Chat container (top area) */
/* -------------------------- */
#chatbot #chat-container {
  flex: none;               /* height controlled by JS */
  height: 670px;            /* initial height */
  min-height: 150px;        /* min height for resizing */
  max-height: 670px;        /* max height for resizing */
  overflow-y: auto;
  border-bottom: 1px solid var(--incoming-chat-border);
  padding: 10px;
  background: var(--incoming-chat-bg);
  box-sizing: border-box;
}

/* -------------------------- */
/* Drag bar (#chat-area) */
/* -------------------------- */
#chatbot #chat-area {
  height: 6px;
  background: #ccc;
  cursor: row-resize;
  width: 100%;
  z-index: 10;
  flex-shrink: 0;
  position: relative;
}

/* -------------------------- */
/* Typing container (outer, single column) */
/* -------------------------- */
#chatbot .typing-container {
  display: flex;
  flex-direction: column;   /* one column: allows stacking if needed */
  width: 100%;
  min-height: 68px;
  padding: 10px;
  background: var(--outgoing-chat-bg);
  border-top: 1px solid var(--incoming-chat-border);
  box-sizing: border-box;
}

/* -------------------------- */
/* Typing content (inner, two columns) */
/* -------------------------- */
#chatbot .typing-container .typing-content {
  display: grid;
  grid-template-columns: 1fr 165px;  /* textarea left, controls right */
  gap: 10px;
  width: 100%;
  align-items: stretch;
  box-sizing: border-box;
}

/* -------------------------- */
/* Textarea wrapper (left column) */
/* -------------------------- */
#chatbot .typing-container .typing-textarea {
  display: flex;
  width: 100%;
}

/* Textarea itself */
#chatbot .typing-textarea textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  resize: vertical;
  min-height: 68px;
  max-height: 800px;
  padding: 15px 20px;
  border: none;
  border-radius: 4px;
  outline: 1px solid var(--incoming-chat-border);
  background: var(--input-chat-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  overflow-y: auto;
  box-sizing: border-box;
}

/* -------------------------- */
/* Typing controls (right column, 3x2 grid) */
/* -------------------------- */
#chatbot .typing-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns */
  grid-template-rows: repeat(2, 48px);   /* 2 rows */
  gap: 7px;
  width: 100%;
  justify-items: stretch;
  align-items: stretch;
}

/* Controls buttons */
#chatbot .typing-controls span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--incoming-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

#chatbot .typing-controls span {
    width: 36px;
  height: 36px;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--incoming-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
  cursor: pointer;
  border-radius: 4px;
}






/* FULLSCREEN MODE ROOT */
#chatbot.fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  height: 100vh !important;
  width: 100% !important;
  max-width: 100% !important;
  z-index: 9999;
  background: #fff;
  
  display: flex;
  flex-direction: column;
  min-height: 0px;
}

#chatbot.fullscreen #chat-container {
  height: 70%;          /* initial size */
  min-height: 20%;      /* resizing limits */
  max-height: 80%;
  overflow-y: auto;
}

#chatbot.fullscreen #chat-area {
  height: 4px;
  background: #ddd;
  cursor: row-resize;
  flex-shrink: 0;
}

#chatbot.fullscreen #footnote-button {
	display: none !important;
}

#chatbot.fullscreen .typing-container {
  position: relative !important;  /* override fixed/absolute */
  bottom: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 30% !important;         /* fixed ratio */
  padding: 10px !important;

  display: flex;
  flex-direction: column;
  background: var(--outgoing-chat-bg);
}


#chatbot.fullscreen .typing-container {
  flex-grow: 1;
  min-height: 20%;
  max-height: 80%;
  
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  padding: 10px;
  background: var(--outgoing-chat-bg);
}


#chatbot.fullscreen .typing-content {
  display: flex !important;
  flex-direction: column;
  width: 100% !important;
  max-width: 100% !important;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

/* textarea wrapper fills available height above controls */
#chatbot.fullscreen .typing-textarea {
  flex: 1;                 /* ← VERY IMPORTANT */
  display: flex;
  min-height: 0;         /* <-- REQUIRED */
}

#chatbot.fullscreen .typing-textarea textarea {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 0;         /* <-- REQUIRED */
  resize: none;
}

#chatbot.fullscreen .typing-controls {
  flex-shrink: 0;        /* <-- THIS MAKES CONTROLS ALWAYS VISIBLE */
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 0;
  overflow-x: auto;
}

#chatbot.fullscreen .typing-controls span {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--incoming-chat-bg);
  outline: 1px solid var(--incoming-chat-border);
  cursor: pointer;
  border-radius: 4px;
}

/* Reponsive Media Query */
@media screen and (max-width: 600px) {
  .default-text h1 {
    font-size: 2.3rem;
  }
  :where(.default-text p, textarea, .chat p) {
    font-size: 0.95rem!important;
  }
  .chat-container .chat {
    padding: 20px 10px;
  }
  .chat-container .chat img {
    height: 32px;
    width: 32px;
  }
  .chat-container .chat p {
    padding: 0 20px;
  }
  .chat .chat-content:not(:has(.typing-animation), :has(.error)) span {
    visibility: visible;
  }
  .typing-container {
    padding: 15px 10px;
  }
  .typing-textarea textarea {
    height: 45px;
    padding: 10px 40px 10px 10px;
  }
  .typing-content span {
    height: 45px;
    width: 45px;
    margin-left: 5px;
  }
  span.material-symbols-rounded {
    font-size: 1.25rem!important;
  }
}


/* Login Popup Styles */
.login-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.login-popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    color: white;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: popupSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-popup h2 {
    margin-bottom: 20px;
    font-size: 2rem;
}

.login-popup p {
    margin-bottom: 30px;
    line-height: 1.6;
    font-size: 1.1rem;
    opacity: 0.9;
}

.login-popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.login-popup-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-popup-btn-login {
    background: white;
    color: #667eea;
}

.login-popup-btn-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.login-popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Small screen adjustments */
@media (max-width: 600px) {
    .login-popup-buttons {
        flex-direction: column;
    }
    
    .login-popup-btn {
        width: 100%;
    }
}