/* Custom scrollbar styling */
@font-face {
    font-family: 'Calibri Arabic';
    src: url('../fonts/calibiri/alfont_com_كاليبري-عادي.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
  }
  
  /* Apply the font where Arabic text will be used */
  [lang="ar"] {
    font-family: 'Calibri Arabic', Arial, sans-serif;
  }
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #0064e4;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #145ca7;
}

.chat-container {
    display: flex;
    height: calc(100vh - 100px);
    margin-top: 120px;
    font-family: 'Poppins', Arial, sans-serif;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    position: relative;
}

.chat-sidebar {
    width: 280px;
    background: linear-gradient(to bottom, #f8f9fa, #f0f2f5);
    padding: 20px;
    transition: all 0.3s ease;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-left: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 0; /* Remove extra padding since we're using position:sticky */
}

.chat-sidebar.hidden {
    margin-left: -280px;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(222, 226, 230, 0.7);
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.sidebar-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center; /* Centre le texte */
    font-family: 'Calibri Arabic', Arial, sans-serif;
    width: 100%; /* Assure que l'élément prend toute la largeur */
    margin-bottom: 15px; /* Espace entre le titre et le bouton */
}

.sidebar-header:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0,100,228,0.3), transparent);
}

.new-chat-btn {
    width: 100%;
    padding: 10px 15px;
    background: linear-gradient(135deg, #0073e6, #0064e4);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 100, 228, 0.2);
    font-family: 'Calibri Arabic', Arial, sans-serif; /* Police arabe */
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, #0064e4, #0055c4);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 100, 228, 0.3);
}

.new-chat-btn i {
    font-size: 0.85rem;
}

.chat-history {
    padding: 12px 15px;
    margin: 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    border-radius: 10px;
    position: relative; /* Ensure proper positioning context */
}

.chat-history:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
}

.chat-history.active {
    background-color: #d5eaff;
    border-left: 3px solid #0064e4;
    /* font-weight: bold; */
    color: #333; /* Change from white to a dark color for better readability */
}
/* .chat-history.active {
    background-color: #e0e0e0;
    border-left: 3px solid #0064e4;
    font-weight: bold;
} */

.chat-history i {
    color: #0064e4;
    margin-right: 1px;
    font-size: 96%;
}

.chat-history span {
    color: #444;
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-actions {
    display: none;
    gap: 5px;
}

.chat-history:hover .chat-actions {
    display: flex;
}

.chat-history.editing .chat-actions {
    display: flex;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.edit-title-btn,
.delete-chat-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    margin: 0 2px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.edit-title-btn:hover,
.delete-chat-btn:hover {
    background: #dee2e6;
    color: #0064e4;
}

.edit-title-input {
    flex: 1;
    border: 1px solid #0064e4;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.9rem;
    outline: none;
    background: white;
    color: #333; /* Explicitly set text color to dark */
    width: calc(100% - 70px); /* Leave space for buttons */
    max-width: 60%;
    box-shadow: 0 0 0 2px rgba(0, 100, 228, 0.1);
    margin-right: 5px; /* Add some space between input and buttons */
}

/* Fix text color for active conversation title editing */
.chat-history.active .edit-title-input {
    color: #333; /* Ensure text is dark even when parent has white text */
    background-color: white; /* Reinforce white background */
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-left: 20px;
    margin-right: 20px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #f9fafc;
}

.message {
    max-width: 75%;
    padding: 12px 43px;
    border-radius: 18px;
    margin: 5px 0;
    word-wrap: break-word;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    overflow-wrap: break-word; /* Ensure text wraps properly */
    word-break: break-word; /* Allow words to break if needed */
}

.message-hidden {
    opacity: 0;
    transform: translateY(20px);
}

.message:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
}

.message-bot {
    background-color: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    background: linear-gradient(to right bottom, #ffffff, #f8f9fa);
    width: auto; /* Ensure width is based on content */
    direction: rtl; /* Add RTL direction for the bot messages */
    text-align: right; /* Right-align text for RTL languages */
}

.message-bot p {
    margin: 0 0 12px 0;
    white-space: normal; /* Ensure text wraps */
    overflow-wrap: break-word;
}

.message-bot p:last-child {
    margin-bottom: 0;
}

.message-bot ul {
    margin: 10px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.message-bot ol {
    margin: 10px 0;
    padding-left: 20px;
    list-style-type: decimal;
}

.message-bot img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    object-fit: contain; /* Maintain aspect ratio while fitting container */
}

.message-bot h1,
.message-bot h2,
.message-bot h3 {
    margin: 12px 0;
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.message-bot strong {
    font-weight: 600;
    color: #333;
}

.message-bot em {
    font-style: italic;
}

.message-bot:before {
    content: '';
    position: absolute;
    left: auto;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-left: 8px solid #ffffff;
    border-bottom: 8px solid transparent;
}

.message-bot code {
    white-space: pre-wrap; /* Ensure code blocks wrap properly */
    overflow-x: auto; /* Allow horizontal scrolling only within code blocks if needed */
    max-width: 100%;
    display: block;
    padding: 10px;
    background-color: #f5f7fa;
    border-radius: 8px;
    margin: 10px 0;
    font-family: monospace;
}

/* Special style for RTL direction in bot messages */
.message-bot p, 
.message-bot h1, 
.message-bot h2, 
.message-bot h3, 
.message-bot ul, 
.message-bot ol {
    direction: rtl;
    text-align: right;
}

/* Preserve line breaks in bot messages */
.message-bot p,
.message-bot div {
  white-space: pre-wrap;
}

.message-user {
    background: linear-gradient(135deg, #0073e6, #0064e4);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 100, 228, 0.2);
    position: relative;
    background: linear-gradient(135deg, #0064e4, #0057c3);
}

.message-user:after {
    content: '';
    position: absolute;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-left: 8px solid #0064e4;
    border-bottom: 8px solid transparent;
}

.message-image-preview {
    width: 20%;
    height: auto;
    margin-bottom: 8px;
    border-radius: 8px;
    display: block;
    margin-left: 79%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message-user .message-image-preview {
    margin-left: auto;
}

.message-bot .message-image-preview {
    margin-right: auto;
}

.chat-input-area {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.chat-form {
    display: flex;
    gap: 10px;
}

.input-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 5px 15px;
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 0;
    font-size: 14px;
}

.chat-input-icons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-icon {
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chat-icon:hover {
    color: #0064e4;
    background-color: #f0f2f5;
}

.chat-form button {
    background: #0064e4;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chat-form button:hover {
    background: #0073e6;
}

.image-preview-container {
    margin-bottom: 10px;
    position: relative;
    display: inline-block;
}

.image-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
}

.delete-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.toggle-sidebar {
    position: absolute;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toggle-sidebar:hover {
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-sidebar.hidden + .toggle-sidebar {
    left: 0;
    background: #0064e4;
    color: white;
    border-color: #0064e4;
    box-shadow: 0 2px 8px rgba(0, 100, 228, 0.3);
}

.chat-sidebar.hidden + .toggle-sidebar {
    left: 0;
}


.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f5f7fa;
    border-radius: 18px;
    width: fit-content;
    margin: 8px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #90a4ae;
    border-radius: 50%;
    animation: bounce 1.3s ease infinite, pulse 1.3s ease infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

.source-container {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
    font-size: 0.9rem;
    direction: rtl; /* Set direction for Arabic text */
    text-align: right;
}

.source-title {
    font-weight: 600;
    color: #333;
}

.source-origin {
    display: block;
    color: #555;
    font-weight: 500;
    margin: 3px 0 5px 0;
    font-size: 0.9em;
}

.source-filename {
    font-size: 0.85em;
    color: #444;
    font-style: italic;
    margin-top: 3px;
    margin-bottom: 3px;
    padding-left: 5px;
    border-left: 2px solid #ddd;
}

.source-filename a.pdf-link {
    color: #0064e4;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.source-filename a.pdf-link:hover {
    text-decoration: underline;
    color: #0057c3;
}

.source-filename a.pdf-link:before {
    content: "\f1c1"; /* PDF icon from Font Awesome */
    font-family: FontAwesome;
    margin-right: 5px;
    font-size: 0.9em;
}

.source-score {
    color: #888;
    font-size: 0.8em;
}

.source-header {
    font-weight: 600;
    color: #0064e4;
    margin-bottom: 8px;
    font-family: 'Calibri Arabic', Arial, sans-serif;
    direction: rtl;
}

/* Style for Arabic source labels */
.source-header, .source-filename, .source-score {
  font-family: 'Calibri Arabic', Arial, sans-serif;
  direction: rtl;
}

.source-preview {
    margin-top: 6px;
    padding: 8px 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    font-style: italic;
    color: #555;
    font-size: 0.85em;
    border-left: 2px solid #0064e4;
    white-space: pre-line;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.source-item {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dotted #eee;
}

.source-item:last-child {
    border-bottom: none;
}

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

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

.message-bot:not(.message-hidden) {
    animation: fadeIn 0.5s ease-out;
}

.message-user:not(.message-hidden) {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.chat-history-container {
    max-height: 470px; /* Limite la hauteur pour environ 7 conversations */
    overflow-y: auto; /* Active le défilement vertical */
    padding-right: 5px; /* Espace pour la barre de défilement */
    margin-right: -5px; /* Compense le padding pour éviter le décalage */
    scrollbar-width: thin; /* Pour Firefox */
    flex: 1; /* Take up all available space */
    overflow-y: auto;
    padding-bottom: 10px; /* Extra padding to prevent content being hidden behind token usage */
}

/* Media queries */
@media (max-width: 1024px) {
    .chat-sidebar {
        width: 240px;
    }
    
    .toggle-sidebar {
        left: 240px;
    }
    
    .message {
        max-width: 85%;
    }
}
  
/* For mobile devices (screen width below 768px) */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 80px);
        margin-top: 80px;
        overflow: hidden; /* Prevent any overflow */
    }
    
    .chat-sidebar {
        width: 100%;
        margin: 0 0 10px 0;
        max-height: 30vh;
        overflow-x: hidden;
        padding-bottom: 40px; /* Slightly less padding needed on mobile */
    }
    
    .toggle-sidebar {
        top: calc(30vh + 60px);
        left: auto;
        right: 10px;
        width: 40px;
        height: 40px;
        background-color: #0064e4;
        color: white;
    }
    
    .message {
        max-width: 90%;
        padding: 10px 12px;
    }
    
    .typing-indicator {
        padding: 8px 12px;
    }
    
    .message-bot {
        margin-right: 10%;
    }
    
    .message-user {
        margin-left: 10%;
    }
    
    .chat-input-area {
        padding: 12px;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
    }
    
    .chat-icon {
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .chat-form button {
        width: 42px;
        height: 42px;
    }
    
    .input-group {
        padding: 5px 15px;
    }
    
    #user-input {
        padding: 8px 0;
        font-size: 16px; /* Better for mobile touch */
    }
    
    .sidebar-token-usage {
        width: 100%;
        position: absolute; /* Use absolute instead of fixed on mobile */
        bottom: 0;
        left: 0;
    }
    
    .chat-sidebar.collapsed .sidebar-token-usage {
        visibility: hidden; /* Hide when sidebar is collapsed on mobile */
    }
}

/* Styles de scrollbar spécifiques pour le conteneur d'historique de chat */
.chat-history-container::-webkit-scrollbar {
    width: 4px; /* Plus fine que la scrollbar principale */
}

.chat-history-container::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.chat-history-container::-webkit-scrollbar-thumb {
    background: #0064e4;
    border-radius: 4px;
}

.chat-history-container::-webkit-scrollbar-thumb:hover {
    background: #0050b8;
}

/* Amélioration du style pour l'historique des conversations */
.chat-history.active {
    background-color: #d5eaff;
    border-left: 3px solid #0064e4;
    /* font-weight: bold; */
    color:white
}

/* Animation de pulse pour mettre en évidence la conversation sélectionnée */
@keyframes pulse-highlight {
    0% { background-color: #e0e0e0; }
    50% { background-color: #cce1ff; }
    100% { background-color: #e0e0e0; }
}

.chat-history.pulse-highlight {
    animation: pulse-highlight 1s ease;
}

/* Style pour l'horodatage des messages */
.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.message-user .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-bot .message-time {
    color: rgba(0, 0, 0, 0.5);
}

/* Style pour le bouton "Charger plus de messages" */
.load-more-messages-btn {
    align-self: center;
    background-color: #f0f2f5;
    border: none;
    border-radius: 15px;
    padding: 5px 15px;
    margin: 10px 0;
    color: #0064e4;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.load-more-messages-btn:hover {
    background-color: #e1e5eb;
}

/* Indicateur de chargement pour les conversations */
.loading-conversation {
    align-self: center;
    padding: 10px 20px;
    background-color: #f0f2f5;
    border-radius: 15px;
    margin: 20px 0;
    color: #666;
    font-size: 0.9rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Message d'erreur pour les échecs de chargement */
.error-message {
    align-self: center;
    padding: 10px 20px;
    background-color: #ffebee;
    border-radius: 15px;
    margin: 20px 0;
    color: #d32f2f;
    font-size: 0.9rem;
}

/* Add styles for loading and error messages in chat history container */
.chat-loading, .chat-error {
    padding: 10px 15px;
    border-radius: 10px;
    margin: 10px 0;
    text-align: center;
    font-size: 0.9rem;
}

.chat-loading {
    background-color: #f5f7fa;
    color: #666;
    animation: pulse 1.5s infinite;
}

.chat-error {
    background-color: #ffebee;
    color: #d32f2f;
}

@media (max-width: 1024px) {
    #user-input {
        flex: 1;
        border: none;
        outline: none;
        padding: 8px 0;
        font-size: 14px;
    }
  }
  
  /* For mobile devices (screen width below 768px) */
  @media (max-width: 768px) {
    #user-input {
        flex: 1;
        border: none;
        outline: none;
        padding: 8px 0;
        width: 0;
        font-size: 14px;
    }
  }

/* Custom Popup Styles */
.custom-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
}

.custom-popup {
  background-color: #fff;
  border-radius: 16px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 450px;
  overflow: hidden;
  transform: translateY(0);
  animation: slideIn 0.3s ease-out;
}

.custom-popup-header {
  padding: 20px;
  background: linear-gradient(135deg, #0064e4, #0057c3);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-popup-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: white;
}

.custom-popup-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.custom-popup-content {
  padding: 25px 20px;
  font-size: 1rem;
  color: #333;
}

.custom-popup-footer {
  padding: 15px 20px;
  background-color: #f8f9fa;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.custom-popup-footer .btn {
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-popup-footer .btn-light {
  background-color: #e2e6ea;
  color: #333;
}

.custom-popup-footer .btn-light:hover {
  background-color: #d2d6da;
}

.custom-popup-footer .btn-primary {
  background: linear-gradient(135deg, #0073e6, #0064e4);
  color: white;
  border: none;
}

.custom-popup-footer .btn-primary:hover {
  background: linear-gradient(135deg, #0064e4, #0055c4);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Styles for suggested questions */
.suggested-questions-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin: 20px auto;
  max-width: 80%;
  text-align: center;
}

.welcome-header {
  margin-bottom: 25px;
  padding: 15px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0064e4, #0057c3);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 100, 228, 0.2);
  width: 100%;
}

.welcome-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: white;
}

.welcome-header p {
  font-size: 1rem;
  opacity: 0.9;
}

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  width: 100%;
}

.question-bubble {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 18px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  margin-bottom: 10px;
}

.question-bubble:hover {
  background: #f0f8ff;
  border-color: #0064e4;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 100, 228, 0.1);
}

.question-bubble:active {
  transform: translateY(0);
}

/* Animation for suggested questions */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.question-bubble {
  animation: fadeInUp 0.6s ease-out forwards;
}

.question-bubble:nth-child(1) { animation-delay: 0.1s; }
.question-bubble:nth-child(2) { animation-delay: 0.2s; }
.question-bubble:nth-child(3) { animation-delay: 0.3s; }
.question-bubble:nth-child(4) { animation-delay: 0.4s; }
.question-bubble:nth-child(5) { animation-delay: 0.5s; }
.question-bubble:nth-child(6) { animation-delay: 0.6s; }

/* Fix for suggested questions visibility */
.suggested-questions-container {
  display: flex ;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin: 20px auto;
  max-width: 85%;
  text-align: center;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 100, 228, 0.1);
}

/* Make questions more visible */
.question-bubble {
  background: white;
  border: 1px solid #0064e4;
  border-radius: 18px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 100, 228, 0.1);
  margin-bottom: 12px;
  max-width: 90%;
  text-align: left;
}

/* Fix for suggested questions visibility with extremely high specificity */
body .chat-container .chat-main #chat-messages .suggested-questions-container,
#suggested-questions-container,
.suggested-questions-container {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 20px auto;
    max-width: 85%;
    width: 85%;
    min-height: 300px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 100, 228, 0.2);
    position: relative;
    border: 2px solid #e0e0ff;
}

/* Make welcome header more visible */
.welcome-header {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0064e4, #0057c3);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 100, 228, 0.3);
    width: 100%;
    text-align: center;
}

.welcome-header h3 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: white;
}

.welcome-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Make the questions more visible and interactive */
.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    width: 100%;
}

.question-bubble {
    background: white;
    border: 2px solid #0064e4;
    border-radius: 18px;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 100, 228, 0.2);
    margin-bottom: 15px;
    max-width: 90%;
    text-align: left;
    color: #333;
    display: block !important;
    visibility: visible !important;
}

.question-bubble:hover {
    background: #f0f8ff;
    border-color: #0064e4;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 100, 228, 0.2);
}

/* Enhanced Suggested Questions Container with modern design */
.suggested-questions-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    margin: 30px auto;
    max-width: 85%;
    text-align: center;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95));
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 100, 228, 0.15);
    z-index: 5;
    position: relative;
    border: 1px solid #e0e8ff;
    transition: all 0.3s ease;
}

/* Improved welcome header styling */
.welcome-header {
    margin-bottom: 30px;
    padding: 25px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0073e6, #0057c3);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 100, 228, 0.25);
    width: 100%;
    text-align: center;
    transform: translateY(-10px);
}

.welcome-header h3 {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: white;
    letter-spacing: 0.5px;
}

.welcome-header p {
    font-size: 1.1rem;
    opacity: 0.95;
    line-height: 1.5;
}

/* Beautiful question bubbles with better layout */
.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    width: 100%;
}

.question-bubble {
    background: #ffffff;
    color: #333;
    border-radius: 16px;
    padding: 16px 22px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 100, 228, 0.1);
    margin-bottom: 15px;
    max-width: 90%;
    text-align: left;
    border-left: 4px solid #0064e4;
    display: block;
    position: relative;
    overflow: hidden;
}

.question-bubble:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 100, 228, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.question-bubble:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 100, 228, 0.2);
    background: #f8fbff;
}

.question-bubble:hover:before {
    opacity: 1;
}

.question-bubble:active {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 100, 228, 0.15);
}

/* Animation for question bubbles - staggered entrance */
.question-bubble {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
}

.question-bubble:nth-child(1) { animation-delay: 0.1s; }
.question-bubble:nth-child(2) { animation-delay: 0.2s; }
.question-bubble:nth-child(3) { animation-delay: 0.3s; }
.question-bubble:nth-child(4) { animation-delay: 0.4s; }
.question-bubble:nth-child(5) { animation-delay: 0.5s; }
.question-bubble:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    0% { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Add specific styles for Arabic questions with improved font */
.question-bubble[dir="rtl"] {
    font-family: 'Calibri Arabic', Arial, sans-serif;
    text-align: right;
    padding-right: 25px;
    padding-left: 15px;
    font-weight: 500;
    line-height: 1.6;
}

/* Style Arabic text in the welcome header */
.welcome-header h3:lang(ar),
.welcome-header p:lang(ar),
.welcome-header h3[lang="ar"],
.welcome-header p[lang="ar"] {
    font-family: 'Calibri Arabic', Arial, sans-serif;
}

/* Style any Arabic text throughout the interface */
[dir="rtl"],
[lang="ar"],
:lang(ar) {
    font-family: 'Calibri Arabic', Arial, sans-serif;
}

/* Ensure immediate hiding of questions container */
#suggested-questions-container.hidden,
.suggested-questions-container.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
    pointer-events: none !important;
}

/* Ensure containers are completely hidden with this class */
.completely-hidden,
#suggested-questions-container.completely-hidden,
.suggested-questions-container.completely-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    z-index: -999 !important;
    pointer-events: none !important;
    transition: none !important;
    animation: none !important;
}

/* Add this rule for quick show/hide transitions without animations */
.suggested-questions-container {
    transition: all 0.15s ease-out !important;
}

/* Override any display:flex with !important for hidden elements */
.completely-hidden.suggested-questions-container {
    display: none !important;
}

/* Target the specific container with maximum specificity */
body .chat-container .chat-main #chat-messages #suggested-questions-container.completely-hidden,
html body #chat-messages .suggested-questions-container.completely-hidden {
    display: none !important;
    visibility: hidden !important;
    max-height: 0 !important;
    min-height: 0 !important;
}

/* Language-specific message styling */
.message-bot.arabic-text {
    text-align: right;
    direction: rtl;
}

.message-bot.latin-text {
    text-align: left;
    direction: ltr;
}

/* Override RTL settings for non-Arabic messages */
.message-bot.latin-text p, 
.message-bot.latin-text h1, 
.message-bot.latin-text h2, 
.message-bot.latin-text h3, 
.message-bot.latin-text ul, 
.message-bot.latin-text ol {
    direction: ltr;
    text-align: left;
}

/* Message bubble visual adjustments for different text directions */
.message-bot.arabic-text:before {
    right: -8px;
    left: auto;
    border-right: 8px solid transparent;
    border-left: 8px solid #ffffff;
}

.message-bot.latin-text:before {
    left: -8px;
    right: auto;
    border-left: 8px solid transparent;
    border-right: 8px solid #ffffff;
}

/* Sources section should follow the main text direction */
.source-container[dir="ltr"] {
    text-align: left;
}

.source-container[dir="ltr"] .source-header,
.source-container[dir="ltr"] .source-filename,
.source-container[dir="ltr"] .source-score {
    direction: ltr;
}

/* Update source styling to support bidirectional text */
.source-origin {
    display: block;
    color: #555;
    font-weight: 500;
    margin: 3px 0 5px 0;
    font-size: 0.9em;
}

/* Source containers should adapt to language */
.latin-text .source-container {
    direction: ltr;
    text-align: left;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 80px);
        margin-top: 80px;
        overflow: hidden;
    }
    
    .chat-sidebar {
        width: 100%;
        margin: 0 0 10px 0;
        max-height: 40vh; /* Increased from 30vh for better visibility */
        overflow-y: auto;
        border-radius: 0;
        padding: 10px 15px; /* Reduced padding */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        transition: max-height 0.3s ease;
    }
    
    .chat-sidebar.collapsed {
        max-height: 60px; /* Collapsed height to show just the header */
        overflow: hidden;
    }
    
    .sidebar-header {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    
    .new-chat-btn {
        padding: 12px 15px; /* Larger touch target */
        border-radius: 8px;
        margin-bottom: 5px;
    }
    
    .toggle-sidebar {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: auto;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        z-index: 1050;
        box-shadow: 0 3px 12px rgba(0, 100, 228, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        background: #0064e4;
        color: white;
        font-size: 1.2rem;
    }
    
    .chat-main {
        margin: 0;
        border-radius: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .chat-messages {
        padding: 15px; /* Reduced padding */
    }
    
    .message {
        max-width: 90%;
        padding: 12px 16px; /* Better padding for mobile */
        margin: 5px 0;
        font-size: 0.95rem; /* Slightly smaller text */
        border-radius: 12px;
    }
    
    .message-bot {
        margin-right: 10%;
    }
    
    .message-user {
        margin-left: 10%;
    }
    
    .chat-input-area {
        padding: 10px;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    }
    
    .chat-form {
        gap: 8px;
    }
    
    .input-group {
        padding: 3px 12px;
    }
    
    #user-input {
        padding: 12px 5px;
        font-size: 16px; /* Native size for iOS to prevent zoom */
        min-height: 24px;
    }
    
    .chat-form button {
        width: 46px; /* Larger touch target */
        height: 46px; /* Larger touch target */
    }
    
    .chat-form button i {
        font-size: 1.2rem; /* Larger icon */
    }
    
    .chat-icon {
        padding: 10px; /* Larger touch targets */
        min-width: 40px;
        min-height: 40px;
    }
    
    /* Sources section */
    .source-container {
        padding: 8px;
        margin-top: 8px;
    }
    
    .source-item {
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    
    /* Fix for welcome message in mobile view */
    .suggested-questions-container {
        max-width: 95%;
        padding: 15px;
    }
    
    .welcome-header {
        padding: 15px;
    }
    
    .question-bubble {
        width: 100%;
        max-width: 100%;
        margin-bottom: 10px;
    }
    
    /* Fix for suggested questions on mobile */
    .suggested-questions {
        width: 100%;
        gap: 10px;
    }
    
    /* Better touch area for chat history items */
    .chat-history {
        padding: 15px;
        margin: 5px 0;
    }
    
    /* Fix for custom popup on mobile */
    .custom-popup {
        width: 95%;
        max-width: 95%;
    }
}

/* iPhone SE and other small devices */
@media (max-width: 375px) {
    .message {
        max-width: 95%;
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .welcome-header h3 {
        font-size: 1.5rem;
    }
    
    .welcome-header p {
        font-size: 0.95rem;
    }
    
    .chat-input-area {
        padding: 8px;
    }
    
    .source-container {
        font-size: 0.8rem;
    }
    
    /* Adjust font sizes for very small screens */
    .source-title {
        font-size: 0.85rem;
    }
}

/* Fix for bottom safe area on newer iPhones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-input-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}

/* Fix for landscape mode */
@media (max-width: 896px) and (orientation: landscape) {
    .chat-container {
        margin-top: 60px;
        height: calc(100vh - 60px);
    }
    
    .chat-sidebar {
        max-height: 30vh;
    }
    
    .chat-messages {
        max-height: calc(100vh - 170px);
    }
    
    .welcome-header {
        padding: 10px;
    }
}

/* Language-specific message styling */
/* Token Usage UI */
.token-usage-container {
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.token-usage-info {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
}

.token-progress-outer {
    height: 4px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.token-progress-inner {
    height: 100%;
    background-color: #4CAF50;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.token-usage-warning .token-usage-info {
    color: #FFC107;
    font-weight: 600;
}

.token-usage-exceeded .token-usage-info {
    color: #F44336;
    font-weight: 600;
}

.upgrade-button-container {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    width: 100%;
}

.upgrade-premium-button {
    background: linear-gradient(135deg, #0073e6, #0064e4);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.upgrade-premium-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #0064e4, #0055c4);
}

/* Mobile responsiveness for token usage UI */
@media (max-width: 768px) {
    .token-usage-container {
        padding: 6px 10px;
    }
    
    .token-usage-info {
        font-size: 11px;
    }
    
    .token-progress-outer {
        height: 3px;
    }
    
    .upgrade-button-container {
        margin: 10px 0;
    }
}

/* Add styles for the sidebar token usage */
.sidebar-token-usage {
    padding: 10px 15px;
    background-color: #f0f4f8;
    border-top: 1px solid #e9ecef;
    position: sticky;
    bottom: 0;
    width: 100%; /* Full width of the sidebar */
    z-index: 100;
    margin-top: auto; /* Push to bottom of flex container */
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
}

/* Adjust the existing token usage styles for sidebar placement */
.sidebar-token-usage .token-usage-info {
    font-size: 11px;
    font-weight: 500;
    color: #555;
}

.sidebar-token-usage .token-progress-outer {
    height: 3px;
    margin-top: 5px;
}

/* Mobile responsiveness for sidebar token usage */
@media (max-width: 768px) {
    .sidebar-token-usage {
        padding: 5px 10px;
        position: absolute; /* Use absolute instead of sticky on mobile */
        bottom: 0;
    }
    
    /* Handle collapsed sidebar on mobile */
    .chat-sidebar.collapsed .sidebar-token-usage {
        visibility: hidden; /* Hide when sidebar is collapsed on mobile */
    }
}

/* Style for Arabic text in the token info */
.sidebar-token-usage .token-usage-info {
    font-family: 'Calibri Arabic', Arial, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #555;
    text-align: right;
    direction: rtl;
    margin-bottom: 5px; /* Space between text and progress bar */
}

/* Adjust for hidden sidebar */
.chat-sidebar.hidden .sidebar-token-usage {
    display: none; /* Hide when sidebar is hidden */
}

/* --- Mobile Enhancements --- */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 60px); /* Adjust based on actual header height on mobile */
        margin-top: 60px; /* Adjust based on actual header height on mobile */
        overflow: hidden; /* Prevent scrolling the whole container */
    }

    .chat-sidebar {
        position: fixed; /* Change to fixed for overlay */
        top: 60px; /* Position below header */
        left: 0;
        bottom: 0;
        width: 80%; /* Adjust width as needed */
        max-width: 300px;
        height: calc(100vh - 60px); /* Full height below header */
        transform: translateX(-100%); /* Start hidden */
        transition: transform 0.3s ease-in-out;
        z-index: 1050; /* Ensure it's above chat content */
        background-color: #f8f9fa; /* Ensure background */
        border-right: 1px solid #dee2e6;
        display: flex;
        flex-direction: column;
        overflow-y: auto; /* Allow sidebar content to scroll */
    }

    .chat-sidebar.open { /* New class to show sidebar */
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .chat-sidebar.hidden {
         /* Keep hidden state consistent with new logic */
        transform: translateX(-100%);
    }

    .sidebar-header {
        padding: 10px 15px; /* Adjust padding */
    }

    .sidebar-header .arabic-title {
        font-size: 1rem; /* Adjust font size */
    }

    .new-chat-btn {
        padding: 8px 12px; /* Adjust padding */
        font-size: 0.9rem;
    }

    .chat-history-container {
        padding: 5px; /* Reduce padding */
        flex-grow: 1; /* Allow container to fill space */
        overflow-y: auto; /* Ensure scrolling within container */
    }

    .chat-history {
        padding: 10px 12px; /* Increase tap area */
        margin-bottom: 5px;
    }

    .chat-history .chat-title {
        font-size: 0.9rem;
    }

    .chat-history .chat-actions button {
        padding: 5px 8px; /* Adjust button size */
    }

    .toggle-sidebar {
        /* Adjust positioning if needed, ensure it's accessible */
        left: 5px; /* Example adjustment */
        top: 70px; /* Example adjustment below header */
        z-index: 1051; /* Above sidebar */
        background-color: rgba(0, 100, 228, 0.8);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

     /* Overlay for when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1049; /* Below sidebar, above content */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }


    .chat-main {
        width: 100%; /* Take full width */
        margin-left: 0; /* Remove margin */
        height: 100%; /* Take full height of container */
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent chat-main from scrolling */
    }

    .chat-messages {
        padding: 10px; /* Adjust padding */
        flex-grow: 1; /* Allow messages to fill space */
        overflow-y: auto; /* Enable scrolling for messages only */
    }

    .message {
        padding: 8px 12px; /* Adjust padding */
        max-width: 85%; /* Slightly wider messages */
        font-size: 0.95rem;
    }

    .message-time {
        font-size: 0.7rem;
    }

    .source-container {
        font-size: 0.8rem;
    }

    .chat-input-area {
        padding: 8px; /* Adjust padding */
        background-color: #fff; /* Ensure background */
        border-top: 1px solid #eee;
        /* Sticky input area - basic */
        position: sticky;
        bottom: 0;
        width: 100%;
    }

    .chat-form {
        align-items: center; /* Align items vertically */
    }

    .chat-form .input-group {
        flex-grow: 1;
        margin-right: 5px; /* Space before send button */
    }

    #user-input {
        padding: 10px 15px; /* Increase padding for easier typing */
        font-size: 1rem;
        height: auto; /* Allow input to grow slightly if needed */
        min-height: 40px; /* Ensure minimum height */
    }

    .chat-input-icons {
        right: 5px; /* Adjust position */
    }

    .chat-icon {
        padding: 0 5px; /* Adjust spacing */
    }

    .chat-icon i {
        font-size: 1.2rem; /* Slightly larger icons */
    }

    .chat-form button[type="submit"] {
        padding: 8px 12px; /* Adjust padding */
        font-size: 1rem; /* Adjust icon size */
        min-width: 40px; /* Ensure minimum tap area */
        height: 40px;
        margin-top: 0; /* Remove top margin */
    }

    /* Suggested Questions on Mobile */
    #suggested-questions-container {
        padding: 15px 10px;
    }
    .welcome-header h3 {
        font-size: 1.1rem;
    }
     .welcome-header p {
        font-size: 0.9rem;
    }
    .suggested-questions {
        flex-direction: column; /* Stack questions vertically */
        align-items: stretch; /* Make bubbles full width */
    }
    .question-bubble {
        padding: 12px 15px; /* Increase padding */
        margin: 5px 0; /* Adjust margin */
        font-size: 0.9rem;
        text-align: right; /* Ensure text aligns right */
    }

    /* Mobile Sidebar Toggle Button (if using the one added in JS) */
    .mobile-sidebar-toggle {
        display: block; /* Ensure it's visible */
        position: absolute;
        top: 10px;
        right: 10px;
        background: none;
        border: none;
        font-size: 1.2rem;
        color: #fff; /* Adjust color if needed */
        z-index: 10;
    }

    /* Adjustments for when virtual keyboard might be open */
    /* This is tricky and might need JS, but CSS can help */
    body:has(#user-input:focus) .chat-container {
       /* Potentially adjust height, but often better handled by browser */
    }

    body:has(#user-input:focus) .chat-messages {
        /* Ensure scroll position is maintained or adjusted */
    }
}

/* Add a class for when keyboard is potentially active (can be toggled with JS) */
body.keyboard-active .chat-container {
    /* Example: Try reducing height if header is fixed */
    /* height: calc(100vh - 40px); */ /* Adjust value */
}

body.keyboard-active .chat-input-area {
    /* Ensure it remains visible */
}

/* ... rest of existing styles ... */