/* Floating Chat CSS */
.floating-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #FF69B4, #FF1493);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 105, 180, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-chat-button.minimized {
    width: 200px;
    border-radius: 30px;
    font-size: 14px;
    padding: 0 20px;
    justify-content: flex-start;
    gap: 10px;
}

.floating-chat-button.minimized::after {
    content: "Auspex Chat";
    font-weight: 500;
}

.floating-chat-button.minimized i {
    font-size: 18px;
}

.floating-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 105, 180, 0.6);
}

.floating-chat-button.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 20px rgba(255, 105, 180, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(255, 105, 180, 0.8); }
    100% { box-shadow: 0 4px 20px rgba(255, 105, 180, 0.4); }
}

.chat-modal .modal-dialog {
    max-width: 90vw;
    width: 800px;
    height: 80vh;
    margin: 5vh auto;
}

.chat-modal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
}

.chat-modal .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.floating-chat-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, #FF69B4, #FF1493);
    color: white;
    border-radius: 0;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-shrink: 0;
    min-height: 85px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.floating-chat-header h5 {
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    font-weight: 600 !important;
}

.floating-chat-header small {
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    font-weight: 500 !important;
}

.floating-chat-header select {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #333 !important;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.floating-chat-header input.custom-limit-input {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #333 !important;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.floating-chat-header select:focus,
.floating-chat-header input:focus {
    background: white !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    outline: none;
}

.floating-chat-header select option {
    background: white !important;
    color: #333 !important;
}

.floating-chat-header .floating-chat-controls {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.floating-chat-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.floating-chat-controls select,
.floating-chat-controls input {
    flex-shrink: 0;
    font-size: 0.875rem;
}

.floating-chat-icon-btn {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white !important;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.floating-chat-icon-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.floating-chat-icon-btn.tools-toggle {
    position: relative;
}

.floating-chat-icon-btn.tools-toggle.active {
    background: rgba(0, 255, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.5);
}

.floating-chat-icon-btn.tools-toggle.active:hover {
    background: rgba(0, 255, 0, 0.4);
}

.floating-chat-icon-btn.tools-toggle:not(.active) {
    background: rgba(255, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.5);
}

.floating-chat-icon-btn.tools-toggle:not(.active):hover {
    background: rgba(255, 0, 0, 0.4);
}

.floating-message-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #666;
}

.floating-message:hover .floating-message-copy {
    opacity: 1;
}

.floating-message-copy:hover {
    background: #FF69B4;
    color: white;
}

.floating-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
}

.floating-quick-queries {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.floating-quick-queries label {
    font-size: 0.75rem;
    color: #666;
    margin-right: 8px;
    font-weight: 500;
}

.floating-quick-btn {
    background: white;
    border: 1px solid #FF69B4;
    color: #FF69B4;
    padding: 4px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.floating-quick-btn:hover {
    background: #FF69B4;
    color: white;
}

.floating-quick-btn.custom {
    background: #f8f9fa;
    border-color: #6c757d;
    color: #6c757d;
    position: relative;
}

.floating-quick-btn.custom:hover {
    background: #6c757d;
    color: white;
}

.floating-quick-btn.custom .remove-custom {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: none;
}

.floating-quick-btn.custom:hover .remove-custom {
    display: block;
}

.floating-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
    /* Ensure messages don't get cut off */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.floating-chat-input {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.floating-chat-input textarea {
    flex: 1;
    resize: none;
    height: 50px;
    border-radius: 25px;
    padding: 12px 20px;
    border: 1px solid #ddd;
}

.floating-chat-input button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #FF69B4;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-message.user {
    flex-direction: row-reverse;
}

.floating-message-content {
    max-width: 85%;
    padding: 15px 20px;
    border-radius: 18px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.floating-message.user .floating-message-content {
    background: #FF69B4;
    color: white;
}

.floating-message.assistant .floating-message-content {
    background: white;
    border: 1px solid #e9ecef;
    color: #333;
}

.floating-message.streaming .floating-message-content {
    border-left: 3px solid #FF69B4;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% { border-left-color: #FF69B4; }
    50% { border-left-color: #FF1493; }
    100% { border-left-color: #FF69B4; }
}

.floating-message.welcome .floating-message-content {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid #FF69B4;
    border-radius: 8px;
}

.floating-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.floating-message.user .floating-message-avatar {
    background: #FF1493;
    color: white;
}

.floating-message.assistant .floating-message-avatar {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #e9ecef;
}

.floating-chat-loading {
    text-align: center;
    padding: 10px;
    color: #666;
}

.floating-chat-loading i {
    animation: spin 1s linear infinite;
}

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

/* Chat container layout */
.chat-container {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.chat-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    transition: all 0.5s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.chat-sidebar.shown {
    width: 280px;
    opacity: 1;
    min-width: 280px;
    max-width: 280px;
}

.chat-sidebar.hidden {
    width: 0 !important;
    opacity: 0;
    overflow: hidden;
    border-right: none;
    min-width: 0 !important;
    max-width: 0 !important;
}

.chat-sidebar-header {
    padding: 15px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sidebar-header h6 {
    margin: 0;
    font-size: 0.875rem;
    color: #666;
}

.chat-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-session-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-session-item:hover {
    background: #f0f0f0;
    border-color: #FF69B4;
}

.chat-session-item.active {
    background: #FF69B4;
    color: white;
    border-color: #FF1493;
}

.chat-session-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-session-info {
    font-size: 0.75rem;
    opacity: 0.7;
}

.chat-session-content {
    flex: 1;
    cursor: pointer;
}

.chat-session-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-session-item:hover .chat-session-actions {
    opacity: 1;
}

.chat-session-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-main-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
    display: flex;
    gap: 8px;
}

.chat-main-controls .floating-chat-icon-btn {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0,0,0,0.2);
    color: #333 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
}

.chat-main-controls .floating-chat-icon-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Context Info - Enhanced for header */
.context-info {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    margin: 0 6px;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.context-info small {
    font-size: 11px;
    color: #333;
    font-weight: 600;
    line-height: 1.2;
}

.context-info small i {
    color: #007bff;
    margin-right: 4px;
}

/* Article formatting improvements */
.floating-message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 5px 0;
}

.floating-message-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.875rem;
    border: 1px solid #e9ecef;
}

.floating-message-content code {
    background: #f8f9fa;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    border: 1px solid #e9ecef;
}

.floating-message-content h1,
.floating-message-content h2,
.floating-message-content h3,
.floating-message-content h4,
.floating-message-content h5,
.floating-message-content h6 {
    margin-top: 20px;
    margin-bottom: 12px;
    line-height: 1.3;
}

.floating-message-content h1:first-child,
.floating-message-content h2:first-child,
.floating-message-content h3:first-child,
.floating-message-content h4:first-child,
.floating-message-content h5:first-child,
.floating-message-content h6:first-child {
    margin-top: 0;
}

.floating-message-content p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.floating-message-content ul,
.floating-message-content ol {
    padding-left: 24px;
    margin-bottom: 12px;
}

.floating-message-content li {
    margin-bottom: 4px;
}

.floating-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.875rem;
}

.floating-message-content th,
.floating-message-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.floating-message-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.floating-message-content blockquote {
    border-left: 4px solid #FF69B4;
    padding: 10px 15px;
    margin: 15px 0;
    background: #f8f9fa;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chat-modal .modal-dialog {
        width: 95vw;
        height: 90vh;
        margin: 5vh auto;
    }
    
    .floating-chat-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    .floating-chat-button.minimized {
        width: 160px;
        font-size: 12px;
        padding: 0 15px;
    }
    
    .chat-sidebar.shown {
        width: 250px;
    }
    
    .chat-sidebar.hidden {
        width: 0;
    }
}

/* Modal fullscreen adjustments using Bootstrap's native classes */
.chat-modal .modal-dialog.modal-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.chat-modal .modal-dialog.modal-fullscreen .modal-content {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
}

.chat-modal .modal-dialog.modal-fullscreen .modal-body {
    height: calc(100vh - 80px) !important;
    padding: 0 !important;
}

.chat-modal .modal-dialog.modal-fullscreen .chat-container {
    height: 100% !important;
}

.chat-modal .modal-dialog.modal-fullscreen .floating-chat-messages {
    height: calc(100vh - 200px) !important;
    max-height: none !important;
}

/* Ensure proper transitions for modal resize */
.chat-modal .modal-dialog {
    transition: all 0.3s ease;
}

/* Tools Configuration Modal */
.tool-config-item {
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.tool-config-item:hover {
    border-color: #007bff;
    background: #f0f4ff;
}

.tool-config-item .form-check {
    margin-bottom: 8px;
}

.tool-config-item .form-check-label {
    font-size: 14px;
    color: #333;
}

.tool-config-item small {
    display: block;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 4px;
}

.form-check-input:checked + .form-check-label {
    color: #007bff;
}

.modal-lg .modal-body {
    padding: 2rem;
}

/* Sample Size Controls */
#floatingCustomLimit {
    transition: all 0.3s ease;
}

#floatingSampleSizeMode {
    min-width: 120px;
}

/* Tool config button */
#toolsConfigBtn {
    position: relative;
}

#toolsConfigBtn.has-custom-config::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #28a745;
    border-radius: 50%;
    border: 1px solid white;
}

/* Responsive adjustments for tools modal */
@media (max-width: 768px) {
    .tool-config-item {
        margin-bottom: 1rem;
    }
    
    .modal-lg .modal-body {
        padding: 1rem;
    }
    
    .floating-message-content {
        max-width: 95%;
        padding: 12px 16px;
    }
    
    .chat-sidebar.shown {
        width: 250px;
        min-width: 250px;
        max-width: 250px;
    }
}

/* Animation for tool toggles */
.form-check-input {
    transition: all 0.2s ease;
}

.form-check-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Tool groups styling */
.col-md-6 h6 {
    border-bottom: 2px solid;
    padding-bottom: 8px;
    margin-bottom: 1rem;
}

.text-primary {
    border-color: #007bff !important;
}

.text-success {
    border-color: #28a745 !important;
}

.text-warning {
    border-color: #ffc107 !important;
}

/* Sampling controls */
.sampling-select {
    width: 120px;
    min-width: 120px;
}

.custom-limit-input {
    width: 70px;
    min-width: 70px;
    display: none;
    transition: all 0.3s ease;
}

.custom-limit-input.show {
    display: block;
}

/* Citation controls */
.citation-select {
    width: 90px;
    min-width: 90px;
}

.custom-citation-input {
    width: 70px;
    min-width: 70px;
    display: none;
    transition: all 0.3s ease;
}

.custom-citation-input.show {
    display: block;
}

/* Improve header layout for when custom field is shown */
@media (max-width: 1200px) {
    .floating-chat-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        min-height: auto;
        padding: 14px 18px;
    }
    
    .floating-chat-controls {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }
    
    .context-info {
        order: -1;
        margin: 0 0 4px 0;
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
        width: auto;
        max-width: 100%;
    }
    
    .context-info small {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
        font-weight: 600;
    }
}

/* Better responsive for mobile */
@media (max-width: 768px) {
    .floating-chat-header {
        padding: 12px 14px;
        gap: 8px;
    }
    
    .floating-chat-controls {
        flex-direction: column;
        gap: 6px;
        width: 100%;
    }
    
    .floating-chat-controls > div:first-child {
        display: flex;
        gap: 6px;
        width: 100%;
        flex-wrap: wrap;
    }
    
    .floating-chat-controls > div:last-child {
        display: flex;
        gap: 6px;
        justify-content: flex-end;
        width: 100%;
        flex-wrap: wrap;
    }
    
    .sampling-select {
        width: 100px;
        min-width: 100px;
        font-size: 0.8rem;
    }
    
    .custom-limit-input {
        width: 60px;
        min-width: 60px;
        font-size: 0.8rem;
    }

    .citation-select {
        width: 85px;
        min-width: 85px;
        font-size: 0.8rem;
    }

    .custom-citation-input {
        width: 60px;
        min-width: 60px;
        font-size: 0.8rem;
    }

    .context-info {
        width: 100%;
        padding: 6px 10px;
        margin: 6px 0 0 0;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(255, 255, 255, 0.9);
    }
    
    .context-info small {
        font-size: 10px;
        color: #333;
        font-weight: 600;
    }
    
    .floating-chat-icon-btn {
        min-width: 32px;
        height: 32px;
        padding: 6px 8px;
        font-size: 0.8rem;
    }
} 