:root {
    --font-family-sans-serif: "Inter", sans-serif;
    --font-family-monospace: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --font-size-base: 1rem; /* 16px */
    --font-size-lg: 1.25rem; /* 20px */
    --font-size-sm: 0.875rem; /* 14px */
    --font-size-xs: 0.75rem; /* 12px */

    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-base: 1.5;
    --line-height-sm: 1.2;
}

body {
    font-family: var(--font-family-sans-serif);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-base);
    color: #212529;
    background-color: #f8f9fa;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
}

h1, .h1 { font-size: 1.5rem; } /* 24px */
h2, .h2 { font-size: 1.375rem; } /* 22px */
h3, .h3 { font-size: 1.25rem; } /* 20px */
h4, .h4 { font-size: 1.125rem; } /* 18px */

p {
    line-height: 1.6;
}

a {
    font-weight: var(--font-weight-medium);
}

.table {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-sm);
}

.table th {
    font-weight: var(--font-weight-semibold);
}

/* Ensure consistent spacing for numeric text */
.table td, .table th {
    font-variant-numeric: tabular-nums;
}

#wrapper {
    display: flex;
}

#sidebar-wrapper {
    min-height: 100vh;
    width: 250px;
    background-color: #343a40;
    transition: margin .25s ease-out;
}

#sidebar-wrapper .sidebar-heading {
    padding: 0.875rem 1.25rem;
    font-size: 1.2rem;
    font-weight: var(--font-weight-bold);
}

#sidebar-wrapper .list-group {
    width: 100%;
}

#page-content-wrapper {
    flex: 1;
    min-width: 0;
    padding-left: 0;
}

#wrapper.toggled #sidebar-wrapper {
    margin-left: -250px;
}

#menu-toggle {
    cursor: pointer;
}

.card {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.form-control, .form-select {
    border-radius: 0.5rem;
}

.btn {
    border-radius: 0.5rem;
    font-weight: var(--font-weight-semibold);
}

.list-group-item-action {
    color: #adb5bd;
    font-weight: var(--font-weight-medium);
}

.form-label,
.form-check-label {
    font-weight: var(--font-weight-medium);
}

.list-group-item-action:hover, .list-group-item-action:focus {
    color: #fff;
    background-color: #495057;
}

.sidebar-heading {
    border-bottom: 1px solid #495057;
}

@media (min-width: 768px) {
    #sidebar-wrapper {
        margin-left: 0;
    }

    #page-content-wrapper {
        min-width: 0;
        width: 100%;
    }

/* Chat page styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px); /* Adjust based on your header/footer height */
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.chat-header {
    padding: 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.chat-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 85%;
}

/* Align user messages to the right */
.message-wrapper.user-message {
    align-self: flex-end;
    justify-content: flex-end;
}

/* Align AI messages to the left */
.message-wrapper.assistant-message {
    align-self: flex-start;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px; /* Align with the top of the message bubble text */
}

.message {
    padding: 0.5rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
}

.message.user {
    background-color: #0d6efd;
    color: white;
    border-bottom-right-radius: 0;
}

.message.bot {
    background-color: #e9ecef;
    color: #333;
    border-bottom-left-radius: 0;
}

.message .sender {
    font-weight: bold;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

.chat-input-container {
    display: flex;
    padding: 1rem;
    border-top: 1px solid #ddd;
    background-color: #f8f9fa;
}

#chat-input {
    flex-grow: 1;
    margin-right: 1rem;
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: #9E9E9E;
    border-radius: 50%;
    display: inline-block;
    animation: blinking-dot 1.4s infinite both;
}

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

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

@keyframes blinking-dot {
    0% {
        opacity: 0.2;
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0.2;
    }
}

    #wrapper.toggled #sidebar-wrapper {
        margin-left: -250px;
    }
}

/* Custom styles for the app */
.container-fluid {
    padding: 14px;
}

.card-header {
    background-color: #e9ecef;
    font-weight: var(--font-weight-bold);
}

.modal-content {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

.status-span {
    font-weight: var(--font-weight-bold);
}
.status-success {
    color: #198754;
}
.status-fail {
    color: #dc3545;
}
.status-testing {
    color: #6c757d;
}

#progress-list {
    font-family: monospace;
    background-color: #212529;
    color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

#progress-list li {
    padding: 0.25rem 0;
    border-bottom: 1px solid #343a40;
}

.thumbnail-preview {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* New styles for conversation sidebar */
.conversation-sidebar {
    background-color: #f8f9fa;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dee2e6;
}

#conversation-list {
    overflow-y: auto;
    flex-grow: 1;
}

.conversation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
}

.conversation-item .conversation-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    margin-right: 1rem;
    color: #212529; /* Explicitly set dark color for title text */
}

.conversation-item .conversation-actions {
    display: none; /* Hidden by default */
    align-items: center;
}

.conversation-item:hover .conversation-actions,
.conversation-item.active .conversation-actions {
    display: flex; /* Show on hover or if active */
}

.conversation-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1;
    margin-left: 0.25rem;
}

.conversation-item.pinned {
    font-weight: bold;
}

.conversation-item.active {
    background-color: #e9ecef;
}

/* Override default list-group-item-action color inside the conversation sidebar */
.conversation-sidebar .list-group-item-action {
    color: #495057; /* A dark grey for better readability on light background */
}

.conversation-sidebar .list-group-item-action:hover,
.conversation-sidebar .list-group-item-action:focus {
    color: #000; /* Black on hover for emphasis */
    background-color: #e9ecef;
}

.chat-container.drag-over {
    border: 2px dashed #0d6efd !important;
    background-color: #f0f8ff;
}

#mic-button {
    background-color: #dc3545; /* Red for disabled */
    color: white;
    border-color: #dc3545;
}

#mic-button.listening {
    background-color: #198754; /* Green for enabled */
    color: white;
    border-color: #198754;
}

#product-choice-modal {
    z-index: 1060;
}

#main-chat-col, #conversation-sidebar-col {
    transition: all 0.3s ease-in-out;
}

.message.bot.word-highlight {
    background-color: #fff3cd; /* A pleasant yellow, similar to Bootstrap's .table-warning */
}

#tts-toggle {
    background-color: #dc3545; /* Red for disabled */
    color: white;
    border-color: #dc3545;
}

#tts-toggle.active {
    background-color: #198754; /* Green for enabled */
    color: white;
    border-color: #198754;
}
