body, html {
      height: 100%;
      margin: 0;
      background-color: #ffffff;
      /* font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; */
      
       /* font-family: 'Inter', sans-serif;  */
       font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    }

    .witaaigradient {
      background: linear-gradient(108deg, #0894FF, #C959DD 34%, #FF2E54 68%, #FF9004);
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  
    .chat-layout {
      display: flex;
      height: 100vh;
      overflow: hidden;
      flex-direction: row;
    }
  
    .menu-item {
      cursor: pointer;
    }

    .sidebar {
      width: 280px;
      background-color: #f1f5f9;
      color: #1e293b;
      display: flex;
      flex-direction: column;
      padding: 16px;
      transition: width 0.3s ease; /* CHANGE THIS from transform to width */
      overflow-x: hidden;           /* ADD THIS to hide text during animation */
    }
  
    .sidebar.collapsed {
        width: 80px; /* The width of the new collapsed sidebar */
    }

    .sidebar.collapsed h2,
    .sidebar.collapsed .new-chat span,
    .sidebar.collapsed .menu-item span, 
    .sidebar.collapsed .chat-title-name,/* <--- ADD THIS LINE to hide Projects/Avatars text */
    .sidebar.collapsed .chat-title-hr,
    .sidebar.collapsed .norecent-chats,
    .sidebar.collapsed .chat-list > .mt-2, /* Hides the "Chats" title */
    .sidebar.collapsed .chat-item a {
        display: none; /* Hide the text content */
    }
    /* Center the remaining icons and items */
    .sidebar.collapsed .new-chat,
    .sidebar.collapsed .menu-item, /* <--- ADD THIS LINE to center the icons */
    .sidebar.collapsed .chat-title-search,
    .sidebar.collapsed .chat-item {
        justify-content: center !important;
        padding-left: 0;
        padding-right: 0;
    }

    /* This makes sure the three-dots menu on recent chats still appears correctly */
    .sidebar.collapsed .chat-item:hover .chat-actions-btn {
        display: none;
    }

  
    .sidebar h2 {
      font-size: 1.2rem;
      margin-bottom: 20px;
    }
  
    .chat-list {
      flex: 1;
      overflow-y: hidden;
      transition: overflow 0.2s;
    }
    .chat-list:hover {
      overflow-y: auto;
    }
    .chat-list::-webkit-scrollbar {
      margin-left: 10px !important;
      padding-left: 10px !important;
      width: 6px;
      background: #f1f5f9;
    }
    .chat-list:hover::-webkit-scrollbar-thumb {
      background: #cbd5e1;
      border-radius: 8px;
    }
  
    .chat-list .chat-item {
      padding: 8px; /* 10px */
      margin-bottom: 0px; /*8px */
      border-radius: 8px;
      color: #395073ff;
      /* background-color: #e2e8f0; */
      cursor: pointer;
    }

    .new-chat {
      padding: 10px;
      margin-bottom: 8px;
      border-radius: 8px;
      background-color: #e2e8f0;
      cursor: pointer;
    }
  
    .chat-list .chat-item:hover , .new-chat:hover {
      background-color: #cbd5e1;
    }

    .new-chat:hover {
      transform: scale(1.01);
      transition: transform 0.15s;
    }

    .chat-list a{
      text-decoration: none;
      color: inherit;
    }

    /* Add this to your existing CSS */

    .chat-item {
        position: relative; /* Essential for positioning the dropdown */
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .chat-item a {
        font-size:15px;
        text-decoration: none;
        color: inherit;
        /* color:#1e1e1e; */
        flex-grow: 1; /* Allows the link to take up available space */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0; /* <<< ADD THIS LINE */
    }

    .chat-actions-btn {
        display: none; /* Hidden by default */
        cursor: pointer;
        padding: 0px;
        font-weight: bold;
        border-radius: 5px;
    }

    .chat-item:hover .chat-actions-btn {
        display: block; /* Show on hover */
    }

    .chat-actions-dropdown {
        display: none; /* Hidden by default */
        position: absolute;
        right: 15px;
        top: 30px;
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 100;
        min-width: 120px;
    }

    .chat-actions-dropdown.show {
        display: block; /* Class to show the dropdown */
    }

    .chat-actions-dropdown a {
        color: black;
        padding: 8px 12px;
        text-decoration: none;
        display: block;
        font-size: 0.9em;
    }

    .chat-actions-dropdown a:hover {
        background-color: #f1f1f1;
    }
  
    .main-chat {
      flex: 1;
      display: flex;
      flex-direction: column;
      background-color: #ffffff;
      position: relative;
      height: 100%;
    }
  
    .chat-header {
      background: linear-gradient(145deg, rgba(255, 255, 255, 0.75), rgba(240, 244, 255, 0.85));
      background: white;
      color: #1e293b;
      padding: 20px 20px;
      padding-bottom: 10px;
      font-size: 1.25rem;
      border-bottom: 0px solid #e2e8f0;

      position: sticky;
      top: 0;
      z-index: 10;
    }

    .newhead {
      display: flex;
      align-items: center;
      gap: 10px;
    }
  
    .chat-body {
      flex: 1;
      padding: 20px;
      overflow-y: auto;
      background-color: #ffffff;
      padding-left: 160px; /* 150px */
      padding-right: 160px;
      padding-top: 50px;
    }
  
    .chat-message {
      margin-bottom: 16px;
    }
  
    .user-message {
      text-align: right;
    }
  
    .user-bubble, .bot-bubble {
      display: inline-block;
      padding: 8px 16px;
      border-radius: 20px;
      max-width: 75%;
      word-wrap: break-word;
    }
  
    .user-bubble {
      background-color: #2563eb;
      color: white;
    }
  
    .bot-bubble {
      background-color: #f1f5f9;
      background-color: #ffffffff;
      color: #1e293b;
      padding-left: 42px;
      /* max-width: 84%; */
      max-width: 100%;
    }

    .first-bot-bubble {
      background-color: #f1f5f9;
      color: #1e293b;
      padding: 12px 16px !important;
    }

    /* --- 1. The Container (The white strip at the bottom) --- */
    .chat-footer {
        /* Layout */
        position: sticky; /* Or fixed, depending on your scroll behavior */
        bottom: 0;
        z-index: 10;
        width: 100%;
        
        /* Background */
        background-color: #ffffff;
        border-top: 0px solid #eee;

        /* CENTERING LOGIC: This creates the responsiveness */
        display: flex; 
        justify-content: center; /* Centers the inner box horizontally */
        
        /* Dynamic Padding: Small top/bottom, flexible sides */
        padding: 20px 20px 30px 20px; 
    }

    /* --- 2. The Input Box (The grey/white rounded box) --- */
    .chat-footerinner {
        /* Width Logic */
        width: 100%;          /* Try to take full width of the footer... */
        max-width: 780px;     /* ...BUT stop growing at 850px (Like 15.6" laptop view) */
        
        /* Styling */
        background-color: #ffffff !important; /* Keep your preferred bg */
        border: 1px solid #ddd; /* Move border from inline style to here */
        border-radius: 32px !important;
        
        /* Padding inside the box (moved from inline style) */
        padding: 14px 20px !important;
        
        /* Shadow */
        box-shadow: 0 2px 6px rgba(0,0,0,0.05) !important;
    }

/* --- 2. The Levitating Input Bar --- */
.chat-footerinner {

    /* SHADOW: Soft, diffused, multi-layered (The "Apple" Shadow) */
    /* box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.02),
        0 10px 15px -3px rgba(0, 0, 0, 0.05),
        0 0 0 1px rgba(0, 0, 0, 0.02) !important; */

    /* Smooth Transition for focus state */
    transition: box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.2s ease;
}

/* --- 3. The "Focus" State (Interactive feel) --- */
.chat-footerinner:focus-within {
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.08), 
        0 8px 10px -6px rgba(0, 0, 0, 0.01) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-1px); /* Micro-interaction: lifts up 1px */
}

/* --- 4. Typography & Icons --- */
#userInput {
    font-size: 16px; /* 16px prevents zoom on iOS */
    /* color: #1d1d1f; Apple's "Almost Black" */
    font-weight: 400;
}

#userInput::placeholder {
    color: #86868b; /* Apple's subtle text gray */
}

/* Icons refinement */
.chat-footer .btn-sm {
    transition: color 0.2s ease;
}
.chat-footer .btn-sm:hover {
    background-color: rgba(0,0,0,0.03); /* Subtle hover pill */
    border-radius: 8px;
}
  
    .send-btn {
      border-radius: 20px;
      padding: 6px 16px;
      height: 50px !important;
      width:100%;
    }
  
    .toggle-btn {
      border: none;
      background: transparent;
      font-size: 1.5rem;
      cursor: pointer;
    }

    .dropdown-menu-end {
      min-width: 200px;
    }

    
  
    /* Mobile Responsiveness */
    @media (max-width: 768px) {
      
      .chat-layout {
        flex-direction: column;
      }
  
      /* Inside your @media (max-width: 768px) block */

      .sidebar {
          position: absolute;
          z-index: 2000;
          height: 100%;
          left: 0;
          top: 0;
          transform: translateX(-100%);
          width: 75%;
          transition: transform 0.3s ease; 
      }

      .sidebar.collapsed {
          transform: translateX(0);
          width: 75%; 
      }

      .sidebar.collapsed h2,
      .sidebar.collapsed .new-chat span,
      .sidebar.collapsed .menu-item span, /* Projects/Avatars text */
      .sidebar.collapsed .chat-title-name, /* "Chats" title */
      .sidebar.collapsed .chat-list > .mt-2,
      .sidebar.collapsed .chat-item a,
      .sidebar.collapsed .chat-title-hr {
          /* This is the key change: Restore visibility */
          display: block !important; 
          /* Use !important if necessary to override the desktop rules, 
            but usually specificity is enough. 'initial' or 'block' works too. 
            I recommend using 'initial' or 'block' where possible, but if 
            your desktop rule uses a high specificity, `!important` may be needed 
            as a temporary fix. Let's stick with the original `initial` concept 
            but check the specificity for the new `.menu-item` */
          display: initial !important; /* Forces text to show up */
      }

      /* Restore alignment */
      .sidebar.collapsed .new-chat,
      .sidebar.collapsed .menu-item,
      .sidebar.collapsed .chat-item,
      .sidebar.collapsed .chat-title-search {
          justify-content: initial !important; /* Resets alignment from 'center' */
          padding-left: 8px; 
          padding-right: 8px;
      }
  
      .chat-header {
        padding-top: 10px;
      }
  
      .chat-body {
        flex: 1;
        padding: 15px 20px 120px; /* bottom padding to avoid overlap with input */
        overflow-y: auto;
        background-color: #ffffff;
      }
      
      .chat-body {
        padding-bottom: 150px; /* increase if needed */
      }

      .user-bubble {
        padding-left: 10px;
        padding-right: 10px;
        min-width: 0px;
        font-size: 15px;
      }

      .bot-bubble {
        padding-left: 6px;
        padding-right: 6px;
        font-size: 15px;
        max-width: 100%;
      }

      /* .chat-footerinner {
        border-bottom-right-radius: 0px !important;
        border-bottom-left-radius: 0px !important;

      } */
  
      .chat-footer {
        /* padding: 15px 14px;   */
        padding: 15px 14px;
        /* Gemini like UI  */
        /* padding : 0px; */

        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        z-index: 1000;
        /* border-top: 1px solid #eee; */
      }
  
      .chat-footer input {
        width: 100%;
        margin-bottom: 10px;
        /* height: 50px; */
        padding-left: 20px;
        border-radius: 20px;
      }
  
      .send-btn {
        width: 100%;
        border-radius: 20px;
        padding: 10px;
      }

      .mobiletogg{
        display: inline !important;
      }

      .chat-body::-webkit-scrollbar {
        width: 4px;
      }

      /* Add these styles inside your @media (max-width: 768px) { ... } block */

      /* 1. Reduce the space between the tool icons */
      .chat-footer .d-flex.align-items-center.gap-2.flex-wrap {
          gap: 0.45rem !important; /* Reduces space from 1rem to 0.75rem */
      }

      /* 2. Make the tool icons and their text smaller */
      .chat-footer .btn-sm,
      .chat-footer .form-select-sm {
          font-size: 0.8rem; /* Smaller text for "Tools" and model selector */
      }
      .chat-footer .bi {
          font-size: 1.02rem; /* Slightly smaller paperclip, mic, etc. */
      }

      #sendButton .send-text {
          display: none;
      }

      /* 4. Reshape the send button into a circle */
      #sendButton {
        padding: 0;
        width: 36px;   /* Fixed width */
        height: 36px;  /* Fixed height */
        border-radius: 50% !important; /* Force it to be a circle */
        
        /* Center the icon inside the new circular button */
        display: flex;
        align-items: center;
        justify-content: center;
      }



      /* 2. HEADER Shrink the AI logo image */
      .chat-header {
          margin-top: 8px;
          height: 70px !important; /* From 45px */
      }

      .headimg img {
          height: 38px !important; /* From 45px */
      }

      /* 3. Make the title text smaller */
      .chat-header .headimg span {
          font-size: 18px; /* From 1.25rem */
      }

      /* 4. Reduce the size of the user's profile picture and its 'pro' wrapper */
      .chat-header .profile-image-wrapper {
          width: 38px;  /* From 44px */
          height: 38px;
      }

      .chat-header .profile-image-wrapper img {
          width: 32px;  /* From 38px */
          height: 32px;
      }

      /* This targets the profile picture for non-pro users */
      .chat-header .dropdown > a > img.rounded-circle {
          width: 38px !important;  /* From 41px */
          height: 38px !important;
      }

      /* Hide the standalone Mic and Waveform icons in the tools list on mobile */
      #micbutton, #voicemode {
          display: none !important;
      }

      

      .chat-footerinner {
        background-color: #f6f7f9 !important;
        background-color: #f0f1f4 !important;
        min-width: 0px;
        border: 0px !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05) !important; 
        /* box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important; */
        border-radius: 24px !important;
      }


    }
    /* media end mobile res */

    .dropdown-menu .dropdown-item {
      border-radius: 8px;
      padding: 8px 12px;
      font-size: 0.9rem;
    }

    .dropdown-menu .dropdown-item:hover {
      background-color: #f1f5f9;
    }

    #userInput {
      max-height: 200px; /* prevent too-tall input */
      line-height: 1.5;
    }

    #typing-indicator .bot-bubble {
      font-style: italic;
      opacity: 0.7;
    }

    @keyframes blink {
      0%, 100% { opacity: 0.2; }
      50% { opacity: 1; }
    }

    #typing-indicator i.bi-three-dots::after {
      content: '...';
      animation: blink 1s infinite;
    }

    /* === Code Block Styling (Light Theme FIX) === */

  /* Style for the bot bubble containing code */
  .bot-bubble pre {
      /* Make the pre background transparent to show the bubble's color */
      background-color: transparent; 
      padding: 0;
      border: none;
      color: #383a42; /* Dark text for light theme */
  }

  /* We still need styles for the Copy button, but adjusted for the new context */
  .bot-bubble pre {
      position: relative;
      border-radius: 12px;

      /* ADD THESE TWO LINES TO FIX THE OVERFLOW */
      white-space: pre-wrap;    /* This allows the code to wrap to the next line */
      word-break: break-all;    /* This forces very long words/strings to break */
  }

  .bot-bubble pre::after {
      content: 'Copy';
      position: absolute;
      top: 5px;  /* Adjusted position */
      right: 5px; /* Adjusted position */
      padding: 4px 8px;
      background-color: #eaeaeb;
      color: #383a42;
      border-radius: 5px;
      font-size: 0.8em;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.2s ease-in-out;
  }

  .bot-bubble pre:hover::after {
      opacity: 1;
  }

  .bot-bubble pre.copied::after {
      content: 'Copied!';
      opacity: 1;
  }

  /* === Table Styling (ChatGPT Style) === */
  .bot-bubble table {
      width: 100%;
      border-collapse: collapse; /* Removes space between borders */
      margin: 1.5em 0; /* More vertical space around the table */
      font-size: 0.9em;
      text-align: left;
      border-radius: 8px; /* Optional: rounded corners for the container */
      overflow: hidden;   /* Ensures content respects the rounded corners */
      background-color: #ffffff; /* Light background for the table */
  }

  /* Style for table cells and headers */
  .bot-bubble th, .bot-bubble td {
      padding: 12px 15px;
      border: none; /* REMOVED all cell borders */
  }

  /* Style specifically for the table header */
  .bot-bubble th {
      background-color: transparent; /* Cleaner header background */
      color: #1e293b; /* Match your other text color */
      font-weight: 600; /* Bolder header text */
      border-bottom: 2px solid #e2e8f0; /* Thicker line under the header */
  }

  /* Style for the table body rows */
  .bot-bubble tbody tr {
      border-bottom: 1px solid #e2e8f0; /* Thin line between rows */
  }

  /* Remove the border from the very last row for a cleaner look */
  .bot-bubble tbody tr:last-of-type {
      border-bottom: none;
  }

  .profile-image-wrapper {
  width: 44px;
  height: 44px;
  /* Adjust the percentage of transparency to close the white gap */
  background: conic-gradient(from 0deg, #0894FF, #C959DD, #FF2E54, #FF9004 100%);

  /* This creates four distinct, non-blending color segments */
  /* background: conic-gradient( #DB4437 0% 25%,  #F4B400 25% 50%,  #0F9D58 50% 75%,  #4285F4 75% 100% ); */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease-in-out;
  }

  .profile-image-wrapper:hover {
    transform: scale(1.1);
  }

  .profile-image-wrapper img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    
    /* This white border is crucial for the clean separation effect */
    border: 2px solid #fff;
  }

  .typing-indicator {
    display: flex;
    align-items: center;
    white-space: nowrap; /* Keep this line */
    font-style: italic;
    color: #1e293b;
}

.typing-indicator .dot {
    height: 8px;
    width: 8px;
    background-color: #8e8e8e;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing-fade 1.4s infinite ease-in-out both;
    flex-shrink: 0; /* Add this line to prevent dots from shrinking */
}

.typing-indicator span:first-child {
    margin-right: 5px;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: .2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: .4s;
}

/* A simpler, more reliable keyframe animation using opacity */
@keyframes typing-fade {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

.preview-item {
    background-color: #f1f5f9;
    border-radius: 16px;
    padding: 6px 8px 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    max-width: 200px;
}

.preview-item .file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-item .remove-file-btn {
    background: #cbd5e1;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.preview-item img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}





/* Styles for the loading button state */
#sendButton.loading-state {
    position: relative;
}

#sendButton.loading-state .spinner-border {
    opacity: 0.4; /* Makes the spinner slightly faded */
}

#sendButton.loading-state .bi-stop-fill {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9em; /* Adjust icon size to fit */
}





/* Style for the active chat item (for visual feedback) */
.active-chat {
    background-color: #e9ecef; /* A subtle background to indicate the current chat */
    font-weight: bold;
}


.sidebar-footer a {
  color:#395073ff;
}


/* --- Dark Mode Styles (Updated & Complete) --- */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

/* General Fixes */
body.dark-mode .dropdown-menu {
    background-color: #2c2c2c;
    border-color: #444;
}
body.dark-mode .dropdown-menu .dropdown-item {
    color: #e0e0e0;
}
body.dark-mode .dropdown-menu .dropdown-item:hover {
    background-color: #3a3a3a;
}
body.dark-mode .dropdown-divider {
    border-top: 1px solid #444;
}

/* Sidebar Fixes */
body.dark-mode .sidebar {
    background-color: #1e1e1e;
    background-color: #121212;
    color: #e0e0e0;
}
body.dark-mode .sidebar h2, 
body.dark-mode .sidebar .toggle-btn {
    color: #f1f1f1 !important;
}

body.dark-mode .toggle-btn {
    color: #f1f1f1 !important;
}

body.dark-mode .new-chat {
    background-color: #2a2a2a;
    color: #f1f1f1;
}
body.dark-mode .chat-list .chat-item,
body.dark-mode .chat-list .chat-item a {
    color: #d1d5db; /* A slightly softer white for links */
}
body.dark-mode .chat-list .chat-item:hover,
body.dark-mode .new-chat:hover {
    background-color: #333333;
    color: #ffffff;
}
body.dark-mode .chat-list .chat-item:hover a {
    color: #ffffff;
}
body.dark-mode .chat-list::-webkit-scrollbar {
    background: #1e1e1e;
}
body.dark-mode .chat-list:hover::-webkit-scrollbar-thumb {
    background: #444;
}

/* Main Chat Area Fixes */
body.dark-mode .main-chat,
body.dark-mode .chat-body {
    background-color: #121212;
    background-color: #1e1e1e;
}
body.dark-mode .chat-header {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border-bottom-color: #3a3a3a;
}
/* This specifically targets the "Assistant" text */
body.dark-mode .chat-header .newhead > span:not(.witaaigradient) {
    color: #e0e0e0 !important;
}
body.dark-mode .bot-bubble {
    background-color: #2a2a2a;
    color: #f1f1f1; /* Fixes the text color inside the bot bubble */
}
body.dark-mode .bot-bubble pre {
    color: #abb2bf;
}
body.dark-mode .bot-bubble table {
    background-color: #2a2a2a;
}
body.dark-mode .bot-bubble th {
    color: #f1f1f1;
    border-bottom: 2px solid #444;
}
body.dark-mode .bot-bubble tbody tr {
    border-bottom: 1px solid #444;
}

/* Chat Footer / Input Fixes */
body.dark-mode .chat-footer {
    background-color: #1e1e1e;
    border-top-color: #3a3a3a;
}
body.dark-mode .chat-footer .bg-whiteQ {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}
body.dark-mode #userInput {
    color: #fff;
}
body.dark-mode #userInput::placeholder {
    color: #9ca3af; /* Lighter placeholder text */
}
body.dark-mode .chat-footer .text-muted,
body.dark-mode .chat-footer .btn,
body.dark-mode .chat-footer .form-select {
    color: #d1d5db !important; /* Makes all icons and buttons visible */
}


/* 1. Style the main chat area's scrollbar for dark mode */
body.dark-mode .chat-body::-webkit-scrollbar {
    width: 8px;
}
body.dark-mode .chat-body::-webkit-scrollbar-track {
    background: #1e1e1e; /* Dark track background */
}
body.dark-mode .chat-body::-webkit-scrollbar-thumb {
    background: #4a4a4a; /* Slightly lighter thumb */
    border-radius: 4px;
}

/* 2. Fix the background of the model selector dropdown */
body.dark-mode .chat-footer .form-select {
    background-color: #3a3a3a;
    border-color: #555;
    /* This replaces the default dark dropdown arrow with a light one */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e0e0e0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

body.dark-mode .sidebar-footer a {
  color:rgb(229, 236, 247);
}


/* --- Refined Minimalist Toggle Switch (v2) --- */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 54px;   /* Reduced width */
  height: 30px;  /* Reduced height */
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ced4da;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 30px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;  /* Reduced thumb size */
  width: 22px;   /* Reduced thumb size */
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

/* Icon Styles */
.slider .bi {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem; /* Slightly smaller icon */
  transition: opacity 0.4s ease;
}

.slider .bi-sun-fill {
  left: 8px;
  color: #495057;
  opacity: 1;
}

.slider .bi-moon-stars-fill {
  right: 8px;
  /* FIXED: Changed icon color to be visible on the white thumb */
  color: #495057; 
  opacity: 0;
}

/* Checked (Dark Mode) State */
input:checked + .slider {
  background-color: #343a40;
}

input:checked + .slider:before {
  /* Adjusted travel distance for new size */
  -webkit-transform: translateX(24px);
  -ms-transform: translateX(24px);
  transform: translateX(24px);
}

input:checked + .slider .bi-sun-fill {
  opacity: 0;
}

input:checked + .slider .bi-moon-stars-fill {
  opacity: 1;
}




/* === New Chat Header Styles Center Title=== */
.chat-header {
    padding: 18px 20px;
    padding-bottom: 14px;
}

.header-left, .header-right {
    flex: 0 0 auto; /* Give left and right sections a fixed base width */
}

.header-left {
    display: flex;
    justify-content: flex-start;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.header-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap; /* Prevents title from wrapping */
    font-size: 21px;
}

.header-logo {
    height: 40px;
    width: 40px;
}

.assistant-text {
    color: #333; /* Default text color for light mode */
}

/* Remove old, now-unused style */
.newhead {
    display: none;
}

/* Dark Mode specific fix for assistant text */
body.dark-mode .assistant-text {
    color: #e0e0e0 !important;
}

/* === Responsive Adjustments for Header === */
@media (max-width: 768px) {
    .chat-header {
        padding: 15px 15px;
        min-height: 60px;
    }

    .header-logo {
        height: 35px !important;
        width: 35px !important;
    }

    .header-center span {
        font-size: 20px;
    }

    /* Further reduce padding for very small screens */
    @media (max-width: 380px) {
        .header-center .witaaigradient {
            display: none; /* Hide the gradient name on very small screens */
        }
    }
}


/* === New "Stop Generation" Button Style === */
#sendButton.stop-state {
    background-color: #ef4444; /* A red color for "stop" */
    border-color: #ef4444;
}

#sendButton.stop-state:hover {
    background-color: #dc2626; /* A darker red on hover */
    border-color: #dc2626;
}

/* On mobile, ensure the stop button remains a circle */
@media (max-width: 768px) {
    #sendButton.stop-state {
        background-color: #ef4444;
        border-color: #ef4444;
    }
}

/* Citation Badge Styling */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: super;
    font-size: 0.75em;
    font-weight: 600;
    color: #1a73e8; /* Blue color */
    background-color: #e8f0fe; /* Light blue background */
    border-radius: 50%;
    width: 20px;
    height: 20px;
    text-decoration: none;
    margin-left: 2px;
    margin-right: 2px;
    transition: background-color 0.2s;
}

.citation-badge:hover {
    background-color: #d2e3fc;
    color: #174ea6;
    text-decoration: none;
}

/* Adjust Dark Mode if needed */
body.dark-mode .citation-badge {
    color: #8ab4f8;
    background-color: rgba(138, 180, 248, 0.2);
}

/* Inline Citation Pills [1] inside text */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: super;
    font-size: 0.7em;
    font-weight: 700;
    color: #fff;
    background-color: #0d6efd; /* Bootstrap Primary Blue */
    border-radius: 10px; /* Pill shape */
    padding: 2px 6px;
    margin: 0 2px;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1;
}

.citation-badge:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Container for the pills at the bottom */
.sources-container {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* The Light Grey Pill Style */
.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    
    /* Light Grey Background */
    background-color: #f0f2f5; 
    border: 1px solid #e4e6eb;
    color: #444;
    
    border-radius: 18px; /* Rounded Pill Shape */
    padding: 4px 12px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
    
    /* Ensure it doesn't break layout */
    max-width: 200px; 
}

/* Hover Effect */
.source-pill:hover {
    background-color: #e4e6eb; /* Slightly darker grey on hover */
    color: #0d6efd; /* Blue text on hover */
    border-color: #d0d2d6;
    text-decoration: none;
}

/* The small number circle [1] inside the pill */
.source-pill .source-number {
    background-color: #fff;
    color: #0d6efd;
    font-weight: 700;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Truncate text logic (requires Bootstrap or these styles) */
.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-select-drop {
    /* max-height: 200px; */
    min-width: 200px;
    overflow-y: auto;
}




/* --- AI Image Generation Styles --- */

.img-gen-container {
    width: 100%;
    min-width: 400px;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    margin-top: 10px;
}

.img-gen-loader {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 250px;
    /* Shimmer Effect */
    background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
    background-size: 200% 100%;
    animation: imgShimmer 1.5s linear infinite;
}

@keyframes imgShimmer {
    0% { background-position-x: 100%; }
    100% { background-position-x: -100%; }
}

.gen-status-text {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
    animation: pulseText 2s infinite;
}

@keyframes pulseText {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.gen-progress-wrapper {
    width: 80%;
    height: 6px;
    background-color: #d1d5db;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.gen-progress-bar {
    height: 100%;
    background-color: #333; /* Dark bar like your test */
    width: 0%;
    transition: width 0.5s ease;
}

.generated-image-result {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    animation: fadeInImg 0.8s ease-in-out;
}

@keyframes fadeInImg {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Dark Mode Adjustments */
body.dark-mode .img-gen-container {
    background-color: #2a2a2a;
    border-color: #444;
}
body.dark-mode .img-gen-loader {
    background: linear-gradient(110deg, #2a2a2a 8%, #333 18%, #2a2a2a 33%);
    background-size: 200% 100%;
}
body.dark-mode .gen-status-text {
    color: #e0e0e0;
}
body.dark-mode .gen-progress-wrapper {
    background-color: #444;
}
body.dark-mode .gen-progress-bar {
    background-color: #0d6efd; /* Blue bar for dark mode */
}