/* === CSS VARIABLES === */
:root {
  --chat-header-bg: #0A0A0B;
  --chat-bg: #121216;
  --chat-input-area-bg: #18181C;
  --chat-input-bg: #22222A;
  --chat-user-bubble: #4F46E5;
  --chat-bot-bubble: #2B2C35;
  --text-white: #f1f2f6;
  --text-color: #e5e7eb;
  --border-color: rgba(255, 255, 255, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --transition-normal: 0.25s ease;
}

/* === CHAT BUBBLES === */
.user-message,
.user-bubble {
  background: var(--chat-user-bubble);
  color: var(--text-white);
  border-radius: 18px 18px 6px 18px;
  padding: 0.8rem 1rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}


/* Bot Bubble */
.bot-bubble {
  background: var(--chat-bot-bubble);
  color: var(--text-color);
  backdrop-filter: blur(10px);
  border-radius: 20px 20px 6px 20px;
  border: 1px solid var(--border-color);
}


.chat-bubble.bot {
  background: rgba(255, 255, 255, 0.05); /* translucent white on dark bg */
  color: #e3e3ec; /* soft light gray for readability */
  border-radius: 20px 20px 20px 6px;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  font-weight: 400;
}


  .dark-mode {
    --chat-bg: #1f2937;
    --chat-user-bubble: #6366f1;
    --chat-bot-bubble: #374151;
    --chat-header-bg: #3730a3;
    --text-white: #f1f2f6;
    --text-color: #f9fafb;
    --border-color: #4b5563;
  }

/* ===== CHATBOT SIDEPANEL STYLING ===== */

/* === Sidepanel Structure === */
.chat-sidepanel {
    width: 400px;
    height: 100vh;
    background-color: var(--chat-bg);
    box-shadow: none;
    border: none;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-sidepanel.left {
    box-shadow: none;
    border: none;
}

/* === Chat Container === */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    border: none;
}

/* === Header === */
.chat-header {
    background-color: var(--chat-header-bg);
    color: var(--text-white);
    padding: 1.25rem;
    font-weight: 600;
    font-size: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    border-bottom: none;
}

.chat-position-toggle {
    background: none;
    border: none;
    color: var(--text-white);
    cursor: pointer;
    font-size: 1rem;
}

/* === Messages Area === */
.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 1.25rem;
    background-color: var(--chat-bg);
}

.message {
    margin-bottom: 1rem;
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    line-height: 1.4;
}

.user-message {
    background-color: var(--chat-primary);
    color: var(--text-white);
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.bot-message {
    background-color: var(--chat-bot-bubble);
    color: var(--text-color);
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

/* === Typing Indicator === */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background-color: #e5e7eb;
    border-radius: 1rem;
    width: fit-content;
    margin-bottom: 1rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-5px);
    }
}

/* === Input Area === */
.chat-input-container {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #e5e7eb;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    background-color: #f9fafb;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: #4f46e5;
}

/* === Input Actions === */
.input-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    background-color: transparent;
    border: none;
}

.action-btn:hover {
    background-color: #e5e7eb;
    color: #4f46e5;
}

.action-btn.active {
    color: #4f46e5;
}

/* Stop button specific styling */
#stop-btn {
    background-color: #ef4444;
    color: white;
    transition: all 0.3s ease;
}

#stop-btn:hover {
    background-color: #dc2626;
    color: white;
    transform: scale(1.05);
}

/* === File Upload === */
.file-drop-area {
    position: relative;
    overflow: visible !important;
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-preview {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.file-preview-item {
    background-color: #e5e7eb;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-preview-item button {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.8rem;
}



/* === Button Group and History Items (Dark Theme Refined) === */
.button-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background-color: #1c1c22; /* Dark surface */
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.button-group-header:hover {
  background-color: #23232b;
  border-color: rgba(255, 255, 255, 0.08);
}

.button-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #d1d5db; /* Lighter muted gray */
  display: flex;
  align-items: center;
  gap: 6px;
}

.button-group-title i {
  font-size: 0.7rem;
  color: #a3a3b3;
}

.button-group-toggle {
  background: transparent;
  border: none;
  color: #a3a3b3;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.75rem;
  opacity: 0.8;
  transition: all 0.2s ease;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.button-group-toggle span {
  font-size: 0.7rem;
  font-weight: 500;
}

.button-group-toggle:hover {
  background-color: rgba(79, 70, 229, 0.1);
  color: #c7c7d9;
  opacity: 1;
}

.button-group-toggle i {
  transition: transform 0.3s ease;
}

.button-group-toggle.collapsed i {
  transform: rotate(180deg);
}

/* === Collapse Transition === */
#chat-action-buttons,
#quick-action-buttons {
  transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  transform-origin: top;
  overflow: hidden;
}

.buttons-collapsed #chat-action-buttons,
.buttons-collapsed #quick-action-buttons {
  max-height: 0 !important;
  opacity: 0;
  transform: scaleY(0.95);
  margin: 0;
  padding: 0;
}
/* === History Items (Dark Themed) === */
.history-item {
  transition: all 0.2s ease;
  position: relative;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #c7c9d9;
}

.history-item:hover {
  background-color: #1e1e25;
}

.history-item.selected {
  background-color: rgba(79, 70, 229, 0.1) !important;
  border-left: 3px solid #4F46E5 !important;
}

.history-item.selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #4F46E5;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.history-item.selected span {
  color: #e5e7eb !important;
  font-weight: 600 !important;
}

/* === Optimized Tooltips === */
.chat-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background-color: #2b2c35; /* dark matte background */
  color: #e5e7eb; /* soft light text */
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  margin-bottom: 6px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  text-align: center;
  line-height: 1.4;
  min-width: 80px;
  max-width: 240px;
}

.chat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #2b2c35 transparent transparent transparent;
}

.group:hover .chat-tooltip,
.group:focus .chat-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Bottom positioned tooltip variant */
.chat-tooltip-down {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 4px;
}

.chat-tooltip-down::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent #1f2937 transparent;
}

/* === Undo Toast === */
.undo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.undo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.undo-toast .undo-btn {
    background-color: #57606f;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.undo-toast .undo-btn:hover {
    background-color: #57606f;
}

/* === Drop Overlay === */
.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(79, 70, 229, 0.2);
    border: 2px dashed #57606f;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #57606f;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.drop-overlay.active {
    opacity: 1;
} 

:root {
  --chat-header-bg: #0A0A0B;     /* Almost true black */
  --chat-bg: #121216;            /* Slight lift for message area */
  --chat-input-area-bg: #18181C; /* Raised surface for input zone */
  --chat-input-bg: #22222A;      /* Input field contrast */

  --chat-user-bubble: #4F46E5;   /* Vibrant brand purple */
  --chat-bot-bubble: #2B2C35;    /* Subtle soft gray-blue matte */

  --text-white: #f1f2f6;
  --text-color: #e5e7eb;

  --border-color: rgba(255, 255, 255, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --transition-normal: 0.25s ease;
}

/* === HEADER === */
.chat-header {
  background-color: var(--chat-header-bg);
  color: var(--text-white);
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 1.2rem;
  border-bottom: 1px solid var(--border-color);
}

/* === CONTAINER / SIDEPANEL === */
.chat-container,
.chat-sidepanel {
  background-color: var(--chat-bg);
  color: var(--text-color);
}

/* === MESSAGE AREA === */
.chat-messages {
  background-color: var(--chat-bg);
  padding: 1.25rem;
  overflow-y: auto;
}

/* === CHAT BUBBLES === */
.user-message,
.user-bubble {
  background: var(--chat-user-bubble);
  color: var(--text-white);
  border-radius: 18px 18px 6px 18px;
  padding: 0.8rem 1rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.bot-message,
.bot-bubble {
  background: var(--chat-bot-bubble);
  color: var(--text-color);
  border-radius: 18px 18px 18px 6px;
  padding: 0.8rem 1rem;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* === INPUT AREA === */
.chat-input-container {
  background-color: var(--chat-input-area-bg) !important;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

/* === INPUT FIELD === */
.chat-input {
  background-color: var(--chat-input-bg) !important;
  color: var(--text-white) !important;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  resize: none;
  min-height: 50px;
  max-height: 150px;
  width: 100%;
  transition: border-color var(--transition-normal);
}
.chat-input:focus {
  border-color: var(--chat-user-bubble);
  outline: none;
}

/* Input placeholder color for mobile too */
.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Force mobile Safari dark styling */
@media screen and (max-width: 768px) {
  .chat-input {
    background-color: var(--chat-input-bg) !important;
    color: var(--text-white) !important;
    -webkit-appearance: none;
  }

  input,
  textarea {
    background-color: var(--chat-input-bg) !important;
    color: var(--text-white) !important;
  }
}

/* === ACTION BUTTONS (Deep Purple Theme) === */
.chat-action-btn,
.quick-action-btn {
  background-color: #303952 !important;
  color: #dfe4ea !important;
  font-weight: 400;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease-in-out;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-action-btn:hover,
.quick-action-btn:hover {
  background-color: #596275 !important;
  color: #dfe4ea !important;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.35);
}

.chat-action-btn:active,
.quick-action-btn:active {
  transform: scale(0.96);
  background-color: #596275 !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.chat-action-btn:focus,
.quick-action-btn:focus {
  outline: 0px solid rgba(79, 70, 229, 0.4);
  outline-offset: 2px;
}


/* === SCROLLBAR === */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background-color: #2B2C35;
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-track {
  background-color: #18181C;
}

/* === Mobile Fixes for Dark Chat Input === */
@media screen and (max-width: 768px) {
  .chat-input-container {
    background-color: var(--chat-input-area-bg) !important;
  }

  .chat-input {
    background-color: var(--chat-input-bg) !important;
    color: var(--text-white) !important;
    -webkit-appearance: none;
  }

  .chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
  }

  input,
  textarea {
    background-color: var(--chat-input-bg) !important;
    color: var(--text-white) !important;
  }
}
