/* Go-LLama Frontend CSS - Responsive & Mobile-Optimized */

/*--- GLOBAL RESET & BASE ---*/
html {
    font-size: clamp(20px, 1.5vw, 20px);
    height: 100%;
    background: #f5f7fb;
    font-family: system-ui, Arial, sans-serif;
}
body {
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background: #f5f7fb;
    overflow: hidden;
}

/*--- TOP BAR ---*/
.topbar-fixed {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    z-index: 100;
    width: 100vw;
    box-shadow: 0 4px 24px rgba(0,0,0,0.35);
    background: #fff;
}

/*--- MAIN LAYOUT ---*/
.main-layout {
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: auto;
    background: transparent;
    overflow: hidden;
}

/*--- HISTORY SIDEBAR ---*/
.history-sidebar {
    width: min(80vw, 580px);
    min-width: 400px;
    max-width: 580px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.35);
    padding: 1rem 0.5rem 1rem 1rem;
    overflow-y: auto;
    height: 100%;
}
#historySidebar h5 {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}
#chatHistory {
    max-height: 100%;
    overflow-y: auto;
    margin-bottom: 0;
    padding-bottom: 4.2rem;
}

/*--- CHAT AREA & WINDOW ---*/
.chat-area {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    height: 100%;
}
.chat-window {
    flex: 1 1 auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    border-radius: 12px;
    background: #f8f9fa;
    position: relative;
    overflow-y: auto;
    width: 100%;
    padding: 1rem;
    margin-bottom: 3.5rem;
    height: 100%;
}

/*--- PROMPT BOX (FIXED) ---*/
.prompt-box-fixed {
    position: fixed;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 90;
    background: #fff;
    box-shadow: 0 0 32px 12px rgba(0,0,0,0.35), 0 -4px 24px rgba(0,0,0,0.35);
    border-radius: 0;
    padding: 0.5rem 0.5rem 14px 0.5rem;
    width: 100vw;
    max-width: 100vw;
    display: flex;
    align-items: flex-end;
    transition: height 0.15s;
}

/*--- INPUT & BUTTONS ---*/
.prompt-textarea:focus,
.input-group .form-control:focus,
.input-group .btn:focus,
.input-group button:focus {
    box-shadow: 0 2px 16px rgba(0,0,0,0.4) !important;
    border-color: #bdbdbd;
    outline: none;
}
.input-group .form-control,
.input-group .btn,
.input-group button {
    border-radius: 0 8px 8px 0;
    font-size: 1em;
    background: #ffffff !important;
    color: #212529 !important;
    margin-left: 4px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.9);
    border: 2px solid #e0e0e0 !important;
}

/* BUTTON: Send, Websearch, Stop */
#sendBtn, #webSearchToggleBtn, #stopBtn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    border-radius: 8px;
    margin-left: 4px;
    background: #fff !important;
    border: 2px solid #e0e0e0 !important;
    box-shadow: 0 2px 16px rgba(0,0,0,0.60);
    color: #212529 !important;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
#sendBtn:hover, #sendBtn:focus,
#stopBtn:hover, #stopBtn:focus,
#webSearchToggleBtn:focus {
    background: #f2f2f2 !important;
    color: #212529 !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
#webSearchToggleBtn.btn-info,
#webSearchToggleBtn.btn-info:focus,
#webSearchToggleBtn.btn-info:hover {
    background: #2196f3 !important;
    color: #fff !important;
    border-color: #1565c0 !important;
    box-shadow: 0 6px 32px 0 rgba(33,150,243,0.30) !important;
}
#webSearchToggleBtn.btn-info .bi-globe {
    color: #fff !important;
}
#webSearchToggleBtn.btn-outline-secondary,
#webSearchToggleBtn.btn-outline-secondary:focus,
#webSearchToggleBtn.btn-outline-secondary:hover {
    background: #fff !important;
    color: #bdbdbd !important;
    border-color: #e0e0e0 !important;
}
#webSearchToggleBtn.btn-outline-secondary .bi-globe {
    color: #bdbdbd !important;
}

/*--- PROMPT TEXTAREA ---*/
.prompt-textarea {
    min-height: 40px;
    max-height: 180px;
    line-height: 1.4;
    padding-top: 8px;
    padding-bottom: 8px;
    resize: none;
    overflow-y: auto;
    transition: min-height 0.1s, max-height 0.1s;
    box-sizing: border-box;
}
.prompt-textarea[rows="5"] {
    overflow-y: auto;
}
.input-group > .btn, .input-group > button {
    align-self: flex-end;
}

/*--- BANNER, ONLINE BAR ---*/
.model-online-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/*--- CHAT BUBBLES ---*/
#chatMessages .user {
    text-align: right;
}
#chatMessages .llm {
    text-align: left;
}
#chatMessages .message {
    margin-bottom: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 25px;
    display: inline-block;
    max-width: 95%;
    box-shadow: 0 5px 20px rgba(0,0,0,0.8);
    font-size: 1em;
    transition: background 0.2s, box-shadow 0.2s;
}
#chatMessages .user .message {
    background: #f2f2f2;
    color: #212529;
}
#chatMessages .llm .message {
    background: #fff;
    color: #212529;
}
#chatMessages .fade-in {
    animation: fadeIn 0.8s;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px);}
    to { opacity: 1; transform: translateY(0);}
}

/*--- TYPEWRITER AND DOTS ANIMATION ---*/
.typewriter-anim {
  font-size: 1em;
  font-weight: bold;
  letter-spacing: 2px;
  display: inline-block;
  white-space: pre;
}
.typewriter-anim .letter {
  opacity: 0;
  animation: typewriterLetter 0.06s linear forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes typewriterLetter {
  to { opacity: 1; }
}
.dots-anim span {
  animation: blinkDot 1.2s infinite steps(1, end);
  opacity: 0.2;
  margin-left: 2px;
}
.dots-anim span:nth-child(2) { animation-delay: 0.4s; }
.dots-anim span:nth-child(3) { animation-delay: 0.8s; }
@keyframes blinkDot {
  50% { opacity: 1; }
}

/*--- HISTORY PANEL BUTTONS ---*/
.chat-history-btns {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    align-items: flex-end;
}
.chat-history-btns .chat-history-btn {
    width: 1.5em;
    height: 1.5em;
    min-width: 1.5em;
    min-height: 1.5em;
    font-size: 1.5em;
    border-radius: 8px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
}

/*--- THINKING BUBBLE ---*/
.thinking-bubble {
    background: #f5f7fb;
    border: 1px dashed #bdbdbd;
    border-radius: 12px;
    color: #555;
    font-size: clamp(0.9em, 1.2vw, 1.05em);
    font-family: 'Inter', Arial, sans-serif;
    padding: 0.3em 0.9em;
    margin: 1em 0;
    white-space: pre-wrap;
    word-break: break-word;
    opacity: 0.95;
    max-height: 70px;
    overflow-y: auto;
    box-sizing: border-box;
}

/*--- RESPONSIVE SCALING SECTIONS ---*/

/* Max width 2000px: Large desktops, minimal scaling needed ---*/
@media (max-width: 2000px) {
    html { font-size: 19px; }
    .history-sidebar { width: min(70vw, 480px); min-width: 340px; max-width: 480px; }
    .chat-window { padding: 1rem; }
    .chat-history-btns .chat-history-btn { width: 1.5em; height: 1.5em; font-size: 1.5em; }
    #sendBtn, #webSearchToggleBtn, #stopBtn { font-size: 1.5em; min-width: 45px; min-height: 45px; }
}

/* Max width 1500px: Small desktops, minimal scaling needed ---*/
@media (max-width: 1500px) {
    html { font-size: 18px; }
    .history-sidebar { width: min(75vw, 480px); min-width: 300px; max-width: 480px; }
    .chat-window { padding: 0.9rem; }
    .chat-history-btns .chat-history-btn { width: 1.5em; height: 1.5em; font-size: 1.5em; }
    #sendBtn, #webSearchToggleBtn, #stopBtn { font-size: 1.5em; min-width: 43px; min-height: 43px; }
}

/* Max width 1100px: Very large phones/tablets */ 
@media (max-width: 1100px) {
    html { font-size: 17px; }
    .history-sidebar { width: min(85vw, 480px); min-width: 200px; max-width: 480px; }
    .chat-window { padding: 0.7rem; }
    .chat-history-btns .chat-history-btn { width: 1.4em; height: 1.4em; font-size: 1.5em; }
    #sendBtn, #webSearchToggleBtn, #stopBtn { font-size: 1.5em; min-width: 40px; min-height: 40px; }
}

/* Max width 900px: Large phones/tablets */
@media (max-width: 900px) {
    html { font-size: 16px; }
    .history-sidebar { width: min(97vw, 480px); min-width: 80px; max-width: 480px; }
    .chat-window { padding: 0.5rem; }
    .chat-history-btns .chat-history-btn { width: 1.5em; height: 1.5em; font-size: 1.5em; }
    #sendBtn, #webSearchToggleBtn, #stopBtn { font-size: 1.5em; min-width: 36px; min-height: 36px; }
}

/* Max width 700px: Small phones */
@media (max-width: 700px) {
    html { font-size: 15px; }
    .history-sidebar { width: min(100vw, 480px); min-width: 40px; max-width: 480px; }
    .chat-window { padding: 0.3rem; }
    .chat-history-btns .chat-history-btn { width: 1.5em; height: 1.5em; font-size: 1.5em; }
    #sendBtn, #webSearchToggleBtn, #stopBtn { font-size: 1.5em; min-width: 30px; min-height: 30px; }
}

@media (pointer: coarse) and (min-resolution: 2dppx) {
  html {
    font-size: 30px !important; /* boost for high-DPI mobiles */
  }
}

/*--- END ---*/
