/* Chat Toggle Button */
#chat-toggle-button {
    position: fixed;
    bottom: 20%;
    right: 0;
    width: 76px;
    height: 76px;
    padding: 18px;
    background: radial-gradient(115% 95% at 30% 70%, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 30%, rgba(255, 255, 255, 0) 64%),
                radial-gradient(90% 80% at 24% 88%, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 55%),
                linear-gradient(219.17deg, #5D33FB 1.28%, rgba(93, 51, 251, 0) 126.57%);
    box-shadow: 0px 2px 32px 3px rgba(155, 114, 255, 0.18), 0px 1px 6px 3px rgba(155, 114, 255, 0.1);
    border-radius: 999px 0 0 999px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 999;
    border: none;
    color: white;
    transform: none;
}

#chat-toggle-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.toggle-icon {
    width: 24px;
    height: 24px;
    color: white;
}

/* Ensure inline SVG scales nicely inside the pill */
#chat-toggle-button svg {
    width: 32px;
    height: 32px;
    display: block;
}

/* Remove duplicate toggle button styles */
.chat-toggle {
    display: none;
}

/* Chat Sidebar - Hidden by default */
#deep-chat-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background-color: var(--primary-color) !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    border-left: 1px solid #e5e7eb;
}

/* Chat Container for messages list - Hidden by default */
.chat-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background-color: var(--primary-color) !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-left: 1px solid #e5e7eb;
}

/* Draggable Dock Resizer */
.chat-dock-resizer {
    position: absolute;
    left: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    cursor: ew-resize;
    z-index: 1001;
    display: none; /* Hidden by default, shown only on desktop */
    transition: background 0.2s ease;
}

.chat-dock-resizer:hover {
    background: rgba(255, 255, 255, 0.4);
}

.chat-dock-resizer:active {
    background: rgba(255, 255, 255, 0.6);
}

.chat-dock-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: white;
    border-radius: 1px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.chat-dock-resizer:hover::before {
    opacity: 1;
}

/* Show resizer only on desktop */
@media (min-width: 769px) {
    .chat-dock-resizer {
        display: block;
    }
}

/* Top Container Header */
.top-container-header {
    background: transparent;
    padding: 10px 0px 0px 10px;
    flex-shrink: 0;
}

#deep-chat-container .top-container-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: transparent !important;
    padding: .2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: #FCFBFF;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin: 0;
    text-align: center;
    flex: 1;
}

/* Chat Interface Container */
.chat-interface-container {
    flex: 1;
    background: white;
    margin: 0px 10px 10px 10px;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Ensure main content wrapper doesn't interfere with sidebar */
.main-content-wrapper {
    position: relative;
    z-index: 1;
}

/* Ensure sidebar is above main content */
#deep-chat-container,
.chat-container {
    z-index: 1000;
}

/* Chat Header - Legacy styles for backward compatibility */
.chat-header {
    background: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

#chat-close-button {
    background: none;
    border: none;
    font-size: 20px;
    color: white;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.2s ease;
}

#chat-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Chat Content */
.chat-content {
    flex: 1;
    overflow: hidden;
    padding: 0px;
    background: white;
    margin: 0px 10px 10px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 10px;
}

.welcome-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0 0 30px;
    max-width: 280px;
    line-height: 1.5;
}

.new-chat-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* History Header */
.history-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    margin-bottom: 0;
    flex-shrink: 0;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    flex-direction: row;
}

.history-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-title svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

.history-title span {
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

/* Conversation List - Updated to match new image */
.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    padding-top: 0px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.conversation-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
    border: none;
    background: transparent;
}

.conversation-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.conversation-text .history-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-text .history-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.conversation-title {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    flex: 1;
    color: rgba(0, 0, 0, 0.72);
}

.conversation-time {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

.conversation-arrow {
    color: #9ca3af;
    margin-left: 12px;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

/* Deep Chat Styles */
deep-chat {
    flex: 1;
    height: 100% !important;
    width: 100% !important;
    min-height: 0 !important;
    --deep-chat-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --deep-chat-border-radius: 0;
    --deep-chat-input-border-radius: 20px;
    --deep-chat-input-background-color: #f8f9fa;
    --deep-chat-input-padding: 12px 16px;
    --deep-chat-input-box-shadow: none;
    --deep-chat-input-border: 1px solid #e9ecef;
    --deep-chat-messages-padding: 16px;
    --deep-chat-message-border-radius: 12px;
    --deep-chat-user-message-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --deep-chat-assistant-message-background: #f0f2f5;
}

/* Ensure deep-chat takes full height in sidebar */
#deep-chat-container deep-chat {
    height: 100% !important;
    border-radius: 12px;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

/* Chat Loader */
.chat-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #6C5CE7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.chat-loader p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

/* Chat Error */
.chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-error p {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
    max-width: 280px;
}

.retry-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.retry-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom scrollbar styles */
deep-chat::-webkit-scrollbar {
    width: 8px;
}

deep-chat::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

deep-chat::-webkit-scrollbar-thumb {
    background: #c5c5c5;
    border-radius: 4px;
}

deep-chat::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Styles for the messages container inside deep-chat */
deep-chat::part(messages-container) {
    height: calc(100% - 80px) !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: #c5c5c5 #f1f1f1;
    padding-bottom: 0 !important;
    flex: 1;
}

deep-chat::part(input-container) {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px;
    border-top: 1px solid #e9ecef;
    z-index: 10;
    border-radius: 0 0 12px 12px;
    margin-top: auto;
}

/* DeepChat Camera Styles */
deep-chat::part(camera-container) {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

deep-chat::part(camera-button) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: opacity 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

deep-chat::part(camera-button):hover {
    opacity: 0.9 !important;
}

deep-chat::part(camera-preview) {
    border-radius: 8px !important;
    overflow: hidden !important;
    margin: 8px 0 !important;
}

deep-chat::part(camera-capture-button) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 48px !important;
    height: 48px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

deep-chat::part(camera-capture-button):hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.4) !important;
}

deep-chat::part(camera-cancel-button) {
    background: #6b7280 !important;
    color: white !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    cursor: pointer !important;
    transition: opacity 0.2s ease !important;
}

deep-chat::part(camera-cancel-button):hover {
    opacity: 0.9 !important;
}

/* DeepChat Speech-to-Text Styles */
deep-chat::part(speech-button) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

deep-chat::part(speech-button):hover {
    opacity: 0.9 !important;
}

deep-chat::part(speech-button):active {
    transform: scale(0.95) !important;
}

deep-chat::part(speech-listening) {
    background: #dbeafe !important;
    border: 2px solid #3b82f6 !important;
    border-radius: 20px !important;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 8px 0 !important;
}

deep-chat::part(speech-listening-indicator) {
    width: 12px !important;
    height: 12px !important;
    background: #3b82f6 !important;
    border-radius: 50% !important;
    animation: pulse 1.5s infinite !important;
}

deep-chat::part(speech-stop-button) {
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

deep-chat::part(speech-stop-button):hover {
    transform: scale(1.05) !important;
}

deep-chat::part(speech-text) {
    font-size: 14px !important;
    color: #1f2937 !important;
    font-style: italic !important;
    margin-left: 8px !important;
}

/* DeepChat File Attachment Styles */
deep-chat::part(file-button) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

deep-chat::part(file-button):hover {
    opacity: 0.9 !important;
}

deep-chat::part(file-input) {
    display: none !important;
}

deep-chat::part(file-preview) {
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    padding: 12px !important;
    margin: 8px 0 !important;
    background: #f9fafb !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

deep-chat::part(file-icon) {
    width: 24px !important;
    height: 24px !important;
    color: #6b7280 !important;
}

deep-chat::part(file-name) {
    font-size: 14px !important;
    color: #374151 !important;
    font-weight: 500 !important;
    flex: 1 !important;
}

deep-chat::part(file-remove-button) {
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
}

deep-chat::part(file-remove-button):hover {
    transform: scale(1.05) !important;
}

/* Audio pulse animation */
@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #deep-chat-container {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .chat-container {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    #chat-toggle-button {
        bottom: 16px;
        right: 16px;
        top: auto;
        transform: none;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        padding: 0;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
    
    .top-container-header {
        padding: 14px 16px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    .chat-interface-container {
        margin: 12px;
        border-radius: 8px;
    }
    
    .chat-content {
        padding: 16px;
        margin: 12px;
        border-radius: 8px;
    }
    
    .conversation-item {
        padding: 12px;
    }
    
    .new-chat-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
}
#dropup-container {
  right: 1.3em !important;
  bottom: 1.3em !important;
}

.history-header, .conversation-list {
    padding: 16px;
}

.conversation-list {
    padding-top: 0px;
}

.sub-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  border-top-right-radius: 12px;
  border-top-left-radius: 12px;
}

.sub-header-actions .sub-actions-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0; /* allow title to shrink */
}

.sub-header-actions .sub-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto; /* pin to right, prevent shrinking */
}

.sub-header-actions .back-btn svg {
  width: 18px;
  height: 18px;
}

.sub-header-actions .thread-title {
  font-size: 14px;
  color: #374151;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.sub-header-actions .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f7f7f8;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  color: #1f2937;
  white-space: nowrap; /* keep button compact */
  flex: 0 0 auto;
}

.sub-header-actions .action-btn:hover {
  background: #efeff1;
}

.sub-header-actions .action-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 420px) {
  .sub-header-actions .thread-title {
    max-width: 55%;
  }
}

.sub-header-actions span {
    font-size: 14px;
    color: #000000;
}
