/* CSS Variables for Easy Theme Management */
:root {
    --primary-color: #6C63FF;
    --secondary-color: #F0F0F0;
    --background-color: #FFFFFF;
    --user-message-color: #6C63FF;
    --assistant-message-color: #E0E0E0;
    --text-color: #333333;
    --timestamp-color: #888888;
    --modal-bg-color: #F9F9F9;
    --alert-success-bg: #D4EDDA;
    --alert-danger-bg: #F8D7DA;
    --alert-warning-bg: #FFF3CD;
    --alert-info-bg: #D1ECF1;
}

/* Dark Theme Variables */
body.dark-theme {
    --background-color: #1E1E1E;
    --secondary-color: #2C2C2C;
    --text-color: #E0E0E0;
    --assistant-message-color: #3A3A3A;
    --modal-bg-color: #2C2C2C;
    --alert-success-bg: #155724;
    --alert-danger-bg: #721C24;
    --alert-warning-bg: #856404;
    --alert-info-bg: #0C5460;
}

/* Global Styles */
body, html {
    height: 100%;
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    animation: fadeIn 1s ease-in;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #A18CD1 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* ✅ Added for proper alignment */
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: slideDown 0.5s ease-out;
}

.chat-header h4 {
    margin: 0;
    /* Removed invalid 'justify-content: start;' */
}

.chat-header .header-buttons {
    display: flex;
    gap: 10px;
    /* justify-content: end; */ /* ✅ Removed since 'space-between' handles alignment */
}

.search-bar {
    /* Ensure search bar is visually separated */
    border-bottom: 1px solid #ddd;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--secondary-color);
    position: relative;
}

.chat-input {
    padding: 15px 20px;
    background-color: var(--background-color);
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
    animation: slideUp 0.5s ease-out;
}

/* Message Styles */
.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: fadeInUp 0.5s ease-out;
}

.message.user .message-content {
    background-color: var(--user-message-color);
    color: white;
    align-self: flex-end;
    border-top-right-radius: 0;
}

.message.assistant .message-content {
    background-color: var(--assistant-message-color);
    color: var(--text-color);
    align-self: flex-start;
    border-top-left-radius: 0;
}

.message-content {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 80%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    transition: transform 0.2s;
    word-wrap: break-word;
}

.message-content:hover {
    transform: scale(1.02);
}

.message .timestamp {
    font-size: 0.75rem;
    color: var(--timestamp-color);
    margin-top: 5px;
    align-self: flex-end;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background-color: rgba(0,0,0,0.05);
}

/* Modal Styles */
.modal-content {
    border-radius: 15px;
    background-color: var(--modal-bg-color);
    animation: fadeIn 0.3s ease-in-out;
}

.btn{
    border-radius: 50px;
}

/* Button Styles */
.btn-primary {
    background-color: var(--primary-color);
    border: none;
    transition: background-color 0.3s, transform 0.2s;
    border-radius: 50px;
}

.btn-primary:hover {
    background-color: #574B90;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #CCCCCC;
    border: none;
    transition: background-color 0.3s, transform 0.2s;
    border-radius: 50px;
}

.btn-secondary:hover {
    background-color: #AAAAAA;
    transform: translateY(-2px);
}

/* Alert Styles */
.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 250px;
    z-index: 2000;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: slideIn 0.5s ease-out;
}

/* Message Action Buttons */
.message-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.message:hover .message-actions {
    opacity: 1;
}

.copy-button,
.delete-button {
    padding: 4px 6px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.copy-button:hover {
    background-color: rgba(255, 255, 255, 0.8);
}

.delete-button:hover {
    background-color: rgba(255, 0, 0, 0.8);
}

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

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

@keyframes slideUp {
    from { transform: translateY(50px); }
    to { transform: translateY(0); }
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        justify-content: space-between; /* ✅ Ensure space-between is maintained */
    }

    .chat-header .header-buttons {
        width: 100%;
        justify-content: flex-end; /* ✅ Align buttons to the right on mobile */
    }

    .chat-input {
        padding: 10px 15px;
    }

    .message-content {
        max-width: 100%;
    }
}

/* Accordion Styles for Settings Modal */
.accordion-button:not(.collapsed) {
    color: var(--primary-color);
    background-color: rgba(108, 99, 255, 0.1);
}


/* Loader Styles */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

/* Group Header Styling */
.group-header {
    font-size: 0.9rem;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.group-header strong {
    background-color: #f0f0f0;
    padding: 5px 10px;
    border-radius: 15px;
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem; /* Space between buttons */
}

/* Icon Button Styling */
.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    border-radius: 2rem;
}


/* Timestamp Styling */
.timestamp {
    font-size: 0.75rem;
    color: #888;
    margin-top: 5px;
    text-align: right;
}

/* Optional: Hover Effects for Buttons */
.action-buttons .btn:hover {
    opacity: 0.8;
    cursor: pointer;
}

/* 🌟 Modern and Animated Search Highlighting */

/* 🌟 Base Highlight for All Matches */
.search-term,
mark.search-term {
  background-color: #d4f1f9; /* Soft Teal Background */
  padding: 0 4px;
  border-radius: 4px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 🌟 Active Match Highlight */
.active-highlight,
mark.search-term.active-highlight {
  background-color: #76c7c0; /* Deeper Teal for Active Match */
  box-shadow: 0 0 8px rgba(118, 199, 192, 0.6);
  border-left: 3px solid #2a9d8f; /* Accent Border */
}

/* 🌟 Pulsating Animation for Active Highlight */
@keyframes pulse {
  0% {
    box-shadow: 0 0 8px rgba(118, 199, 192, 0.6);
  }
  50% {
    box-shadow: 0 0 12px rgba(118, 199, 192, 0.8);
  }
  100% {
    box-shadow: 0 0 8px rgba(118, 199, 192, 0.6);
  }
}

mark.search-term.active-highlight {
  animation: pulse 2s infinite;
}

/* 🌟 Smooth Scroll for Active Match */
.message .active-highlight {
  scroll-margin-top: 100px; /* Adjust based on your header height */
}

/* 🌟 Tooltip Styling (Optional) */
.mark.search-term[data-bs-toggle="tooltip"] {
  cursor: pointer;
  position: relative;
}

/* 🌟 Optional: Highlight on Hover */
.mark.search-term:hover {
  background-color: #a0e7e5; /* Slightly Darker Teal on Hover */
}

/* 🌟 Remove default mark background */
mark {
  background-color: transparent; /* Remove default mark background */
  padding: 0;
  border-radius: 0;
}
/* --------------------------------------------------
   Connections Modal Styling
-------------------------------------------------- */

/* Modal Header Styling */
#connectionsModal .modal-header {
    background-color: #f8f9fa;
    border-bottom: none;
    padding-bottom: 0;
}

#connectionsModal .modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

/* Modal Body Styling */
#connectionsModal .modal-body {
    padding: 1.5rem;
    background-color: #fff;
}

/* Connection Item Container */
.connection-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
    background-color: #fafafa;
}

/* Hover effect for connection items */
.connection-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Service Info Section */
.service-info {
    display: flex;
    align-items: center;
}

.service-info .service-icon {
    margin-right: 1rem;
    color: #555;
}

/* Specific Service Icon Colors */
.google-icon {
    color: #db4437; /* Google Red */
}

.github-icon {
    color: #333; /* GitHub Black */
}

.service-details {
    display: flex;
    flex-direction: column;
}

.service-details h6 {
    margin: 0;
    font-size: 1.2rem;
    color: #555;
    display: flex;
    align-items: center;
}

.service-details h6 i {
    margin-right: 0.5rem;
    font-size: 1.2rem;
}

/* Account Info Styling */
.account-info {
    margin-top: 0.5rem;
    padding-left: 3.5rem; /* Align with the icon */
    border-left: 2px solid #e0e0e0;
}

.account-info p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: #555;
}

.account-info .actions {
    margin-top: 0.5rem;
}

.account-info .actions h6 {
    font-size: 1rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.account-info .actions ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.account-info .actions ul li {
    display: flex;
    align-items: center;
    font-size: 0.6rem;
    color: #555;
    margin-bottom: 0.3rem;
}

.account-info .actions ul li i {
    margin-right: 0.5rem;
    color: #007bff; /* Action icon color */
}

/* GitHub Avatar Styling */
.github-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-top: 0.5rem;
    border: 1px solid #ccc;
    object-fit: cover;
}

/* Action Buttons Styling */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-buttons .btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.action-buttons .btn i {
    font-size: 0.9rem;
}

/* Connect Button Styling */
.connection-item .btn-primary {
    background-color: #02ba27;
    border: none;
}

.connection-item .btn-primary:hover {
    background-color: #04c42a;
    transform: translateY(-2px);
}

/* Disconnect Button Styling */
.connection-item .btn-danger {
    background-color: #a71d2a;
    border: none;
}

.connection-item .btn-danger:hover {
    background-color: #a71d2a;
    transform: translateY(-2px);
}

/* Refresh Button Styling */
#refreshConnectionsBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#refreshConnectionsBtn i {
    transition: transform 0.3s ease;
}

#refreshConnectionsBtn:hover i {
    transform: rotate(360deg);
}

/* Responsive Design */
@media (max-width: 576px) {
    .connection-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .action-buttons {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .service-info {
        margin-bottom: 0.5rem;
    }

    .account-info {
        padding-left: 0;
        border-left: none;
        border-top: 2px solid #e0e0e0;
        width: 100%;
    }

    .account-info .actions ul li {
        font-size: 0.85rem;
    }
}

/* Optional: Smooth transitions for showing/hiding account info */
.account-info {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
}

.account-info.show {
    max-height: 500px; /* Arbitrary large value */
    opacity: 1;
}
