/* Go-LLama Frontend – Clean, Orientation-aware Layout */

/* =============== */
/* global + tokens */
/* =============== */

:root {
  --bg-app: #1e2227;           /* overall background */
  --bg-surface: #262b33;       /* topbar, modals, prompt bar */
  --bg-chat: #21252b;          /* chat window background */

  --border-subtle: #343a44;
  --border-strong: #404752;

  --shadow-soft: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-strong: 0 4px 20px rgba(0,0,0,0.4);

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --text-main: #e6e8eb;        /* off-white */
  --text-muted: #9ca3af;
  --text-soft: #6b7280;

  --bubble-user: #2d323a;
  --bubble-llm: #2a3038;

  --accent: #3b82f6;
  --accent-soft: rgba(59,130,246,0.15);
}


/* Base typography */

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    background: var(--bg-app);
}

body {
    background: var(--bg-app);
    color: var(--text-main);
    overflow: hidden; /* main layout handles scrolling */
}

/* ================= */
/* top navigation bar */
/* ================= */

.topbar-fixed {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 100;
  width: 100vw;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: none;
}
.material-symbols-outlined {
  font-variation-settings: 'wght' 400;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  color: var(--text-main);
}
.topbar-fixed button {
  background: none;
  border: none;
  color: var(--text-main);
  opacity: 0.85;
  padding: 6px 8px;
  border-radius: 8px;
}
.topbar-fixed button:hover {
  color: var(--accent);
  opacity: 1;
}
.topbar-fixed .btn {
    background: none !important;
    border: none !important;
    color: var(--text-main) !important;
    opacity: 0.8;
}
.topbar-fixed .btn:hover {
    color: var(--accent) !important;
    opacity: 1;
}
.topbar-fixed,
.topbar-fixed .navbar {
    background: var(--bg-surface) !important;
    color: var(--text-main);
}

.topbar-fixed .navbar {
    padding-inline: 0.75rem;
}

.model-online-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
}

#currentModel {
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

#onlineUsers {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ================== */
/* main layout & panes */
/* ================== */

.main-layout {
    position: absolute;
    left: 0;
    right: 0;
    /* Height = viewport minus top bar */
    top: 60px;
    bottom: 0;
    display: flex;
    flex-direction: row;
    width: 100vw;
    background: transparent;
    overflow: hidden;
}

/* Chat area always exists; sidebar overlays on top when visible */

.chat-area {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    height: 100%;
    padding: 0.75rem 0.75rem 0;
    box-sizing: border-box;
}

/* ============ */
/* chat window  */
/* ============ */

.chat-window {
    flex: 1 1 auto;
    background: var(--bg-chat);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow-y: auto;
    width: 100%;
    padding: 1rem 1.1rem;
    margin-bottom: 3.5rem; /* space above prompt bar */
    box-sizing: border-box;
}

/* Save banner */

#chatSavedBanner {
    border-radius: var(--radius-md);
    margin: 0.5rem 0;
}

/* ====================== */
/* history sidebar overlay */
/* ====================== */

/*
   Behaviour:
   - default: Bootstrap adds .d-none (no display)
   - visible: .history-sidebar without .d-none
   - overlay: sits on top of chat-area but doesn't push layout
*/

.history-sidebar {
    position: fixed;
    top: 60px;        /* just under the top bar */
    bottom: 0;
    left: 0;
    z-index: 120;
    width: min(360px, 80vw);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-strong);
    padding: 0.75rem 0.75rem 0.75rem 0.9rem;
    overflow-y: auto;
    box-sizing: border-box;
}

#historySidebar h5 {
    margin: 0.25rem 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
}

#chatHistory {
    max-height: 100%;
    overflow-y: auto;
    margin-bottom: 0;
    padding-bottom: 3.25rem;
}

/* History list items */

#chatHistory .list-group-item {
    border: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.4rem;
    padding: 0.45rem 0.55rem 0.45rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #2a2f37;
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}

#chatHistory .list-group-item:hover {
    background: #333842;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

.history-title {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-main);
    outline: none;
}
.history-title[contenteditable="true"] {
    border-bottom: 1px dashed var(--border-strong);
}

/* History item buttons (edit/delete) */

.chat-history-btns {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    align-items: flex-end;
}
/* Material icon styling for chat history buttons */
.chat-history-btns .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.chat-history-btns .editChatBtn:hover .material-symbols-outlined {
  color: var(--accent);
}

.chat-history-btns .deleteChatBtn:hover .material-symbols-outlined {
  color: #f87171; /* soft red for delete */
}

.chat-history-btns .chat-history-btn {
    width: 1.4em;
    height: 1.4em;
    min-width: 1.4em;
    min-height: 1.4em;
    font-size: 1.2em;
    border-radius: 0.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
/* --- Flatten chat history buttons (no Bootstrap borders or bg) --- */
.chat-history-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-history-btn:hover {
  background: rgba(255,255,255,0.05); /* subtle graphite hover glow */
}

.chat-history-btn:active {
  background: rgba(255,255,255,0.08);
}

/* ================ */
/* prompt box (fixed)
/* ================ */

.prompt-box-fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -2px 6px rgba(0,0,0,0.25);
}

/* prompt textarea */

.prompt-textarea {
  flex: 1;
  min-height: 42px;
  max-height: 200px;
  resize: none;
  overflow-y: auto;
  border-radius: var(--radius-pill);
  background: #2a2f37;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.25);
}

.prompt-textarea::placeholder {
  color: var(--text-soft);
}
.prompt-textarea:focus,
.input-group .form-control:focus {
    box-shadow: 0 0 0 1px var(--accent-soft), 0 0 0 2px rgba(37, 99, 235, 0.12);
    border-color: var(--accent);
    outline: none;
}

/* input group buttons */

.input-group .btn,
.input-group button {
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    margin-left: 0.4rem;
}

/* send / stop buttons */

#sendBtn,
#stopBtn {
  min-width: 42px;
  min-height: 42px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
}
#sendBtn {
  background: var(--accent);
  border: none;
}
#sendBtn:hover {
  background: #5a9bff;
}
#stopBtn {
  background: #f97316;
  border: none;
}
#stopBtn:hover {
  background: #fb923c;
}


#sendBtn i,
#stopBtn i {
    font-size: 1rem;
}

/* =============== */
/* chat bubbles    */
/* =============== */

#chatMessages .user {
    text-align: right;
}

#chatMessages .llm {
    text-align: left;
}

#chatMessages .message {
    margin-bottom: 0.8rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-lg);
    display: inline-block;
    max-width: 95%;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    word-wrap: break-word;
    white-space: pre-wrap;
}

#chatMessages .user .message {
    background: var(--bubble-user);
    color: var(--text-main);
}

#chatMessages .llm .message {
    background: var(--bubble-llm);
    color: var(--text-main);
}

#chatMessages .fade-in {
    animation: fadeIn 0.35s ease-out;
}

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

/* ======================= */
/* thinking bubble styling */
/* ======================= */

.thinking-bubble {
    background: #3f444b;
    border-radius: var(--radius-md);
    border-left: 10px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 0.5rem;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    padding: 0.45rem 0.55rem 0.45rem 0.7rem;
    margin: 0.35rem 0 1.25rem;
    white-space: pre-wrap;
    word-break: break-word;
    opacity: 0.92;
    max-height: 65px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* subtle scrollbar for thinking bubble */

.thinking-bubble::-webkit-scrollbar {
    width: 5px;
}
.thinking-bubble::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}
.thinking-bubble::-webkit-scrollbar-track {
    background: transparent;
}

/* ======================== */
/* typewriter + dots effect */
/* ======================== */

.typewriter-anim {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    display: inline-flex;
    align-items: center;
    white-space: pre;
    color: var(--text-soft);
}

.typewriter-anim .letter {
    opacity: 0;
    animation: typewriterLetter 0.08s linear forwards;
    animation-delay: var(--delay, 0s);
}

@keyframes typewriterLetter {
    to {
        opacity: 1;
    }
}

.dots-anim {
    display: inline-flex;
    margin-left: 4px;
}

.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.35s;
}
.dots-anim span:nth-child(3) {
    animation-delay: 0.7s;
}

@keyframes blinkDot {
    50% {
        opacity: 1;
    }
}

/* ======================= */
/* orientation-responsive  */
/* ======================= */

/* Portrait (phones/tablets held upright) */

@media (orientation: portrait) {
    html {
        font-size: 14px;
    }

    .main-layout {
        top: 56px;
    }

    .chat-area {
        padding-inline: 0.5rem;
    }

    .chat-window {
        margin-bottom: 3.25rem;
        padding-inline: 0.8rem;
    }

    .history-sidebar {
        width: min(100vw, 420px);
    }

    .prompt-box-fixed {
        padding-inline: 0.5rem;
    }

    #chatMessages .message {
        max-width: 100%;
    }
}

/* Landscape (desktops, laptops, landscape tablets) */

@media (orientation: landscape) {
    html {
        font-size: 16px;
    }

    .chat-area {
        padding-inline: 1rem;
    }

    .chat-window {
        padding-inline: 1.25rem;
        margin-bottom: 3.75rem;
    }

    .history-sidebar {
        width: min(360px, 70vw);
    }
}

/* Optional: coarse pointer (touch devices) subtle font boost */

@media (pointer: coarse) {
    html {
        font-size: 17px;
    }
}

/* ============ */
/* misc cleanup */
/* ============ */

/* prevent double icon CSS include collisions */
body .bi {
    vertical-align: -0.05em;
}

/* keep modals consistent with the new palette */
.modal-content {
    background: var(--bg-surface);
    color: var(--text-main);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}
.modal-header,
.modal-footer {
    background: var(--bg-chat);
    border-color: var(--border-subtle);
    color: var(--text-main);
}
.table {
    color: var(--text-main);
}
.table thead {
    background: #2a3038;
}
.table tbody tr:nth-child(even) {
    background: #242830;
}
.table tbody tr:nth-child(odd) {
    background: #2a2f37;
}
/* Force dark theme inside all modals and tables */
.modal-content table,
.modal-content .table {
  background: var(--bg-surface);
  color: var(--text-main);
}

.modal-content thead,
.modal-content thead tr,
.modal-content thead th {
  background: #2a3038 !important;
  color: var(--text-main) !important;
  border-color: var(--border-subtle);
}

.modal-content tbody,
.modal-content tbody tr,
.modal-content tbody td {
  background: #242830 !important;
  color: var(--text-main) !important;
  border-color: var(--border-subtle);
}



/* Smooth slide animation for sidebar */
.history-sidebar {
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

.history-sidebar.showing {
    transform: translateX(0);
    opacity: 1;
}

/* Ensure hidden state is fully out of view when d-none removed momentarily */
.history-sidebar:not(.d-none):not(.showing) {
    transform: translateX(-100%);
    opacity: 0;
}
/* Sidebar overlay (dim background when history open) */
.sidebar-overlay {
    position: fixed;
    top: 60px; /* below top bar */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    z-index: 110; /* just below sidebar's 120 */
    transition: opacity 0.25s ease-out;
}

.sidebar-overlay.showing {
    opacity: 1;
}
a,
a:link,
a:visited {
    color: #60a5fa;
    text-decoration: none;
}
a:hover,
a:focus {
    color: #93c5fd;
    text-decoration: underline;
}
body,
.text-dark {
    color: var(--text-main) !important;
}
/* ============== */
/* Login / Setup  */
/* ============== */

body.login-page,
body.setup-page {
  background: var(--bg-app);
  color: var(--text-main);
}

body.login-page .card,
body.setup-page .card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  color: var(--text-main);
}

body.login-page input,
body.setup-page input,
body.login-page select,
body.setup-page select {
  background: #2d323a;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

body.login-page input::placeholder,
body.setup-page input::placeholder {
  color: var(--text-soft);
}

body.login-page a,
body.setup-page a {
  color: #60a5fa;
}

body.login-page a:hover,
body.setup-page a:hover {
  color: #93c5fd;
}
input,
select,
textarea {
  background-color: #2d323a;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
/* --- Refine online users badge for dark theme --- */
.badge.bg-success {
  background-color: rgba(34, 197, 94, 0.15) !important;   /* soft green glow */
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac !important;
}
.badge.bg-warning {
  background-color: rgba(251, 146, 60, 0.15) !important;  /* warm amber */
  border: 1px solid rgba(251, 146, 60, 0.35);
  color: #fdba74 !important;
}
.badge.bg-danger {
  background-color: rgba(239, 68, 68, 0.15) !important;   /* soft red */
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5 !important;
}
/* Ultra-compact online users badge */
#onlineUsers {
  font-size: 0.50rem !important;
  padding: 0.1rem 0.30rem !important;
  line-height: 1;
  border-radius: 0.9rem !important;
  transform: translateY(-1px); /* align visually with text */
}
#onlineUsers .material-symbols-outlined {
  font-size: 10px !important;
  vertical-align: -2px;
}

/* Refine current model label to match graphite aesthetic */
#currentModel {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
  border: 1px solid var(--border-subtle);
}
/* Left button group: tighter spacing + closer to edge */
.topbar-fixed .d-flex.align-items-center.gap-2 {
  gap: 0.1rem !important;  /* nearly touching */
  margin-left: -10px !important; /* visually align to left edge */
}
/* Right button group: tighter spacing + closer to right edge */
.topbar-fixed .d-flex.align-items-center.gap-2.ms-auto {
  gap: 0.1rem !important;
  margin-right: -10px !important;
}
