/* Chat Container & Messages */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-width: 800px;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #fafafa;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    position: relative;
}
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: #ffffff;
}
.message {
    display: flex;
    margin-bottom: 20px;
    transition: transform 0.2s ease;
}
.message:hover {
    transform: translateY(-2px);
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid #ddd;
}
.message-content {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 16px;
    word-break: break-word;
    line-height: 1.5;
    white-space: pre-wrap;
    position: relative;
}
.user-message {
    justify-content: flex-end;
}
.user-message .message-content {
    background-color: transparent;
    color: #000000;
    border: 1px solid #81d4fa;
    border-bottom-right-radius: 0;
}
.ai-message .message-content {
    background-color: transparent;
    color: #33691e;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border: 1px none #c5e1a5;
    border-left-style: solid;
    box-shadow: 0 2px rgba(0, 0, 0, 0.05);
}
.text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.text p {
    margin: 0.5em 0;
}
.loading-dots {
    padding: 16px 24px;
    display: inline-block;
}
.loading-dots span {
    animation: dotPulse 1.4s infinite;
    opacity: 0;
    font-size: 24px;
    color: #0277bd;
}
.message-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #757575;
    gap: 4px;
}
.timestamp {
    font-size: 0.75rem;
}
.download-button,
.reload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid #81d4fa;
    color: #0277bd;
    border-radius: 6px;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
    margin-left: -2px;
}
.download-icon,
.reload-icon {
    width: 14px;
    height: 14px;
    transform: scale(0.8);
}
.download-button:hover,
.reload-button:hover {
    background-color: #e1f5fe;
    transform: translateY(-1px) scale(1.05);
}
.download-icon,
.reload-icon {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* Chat Input */
.chat-input {
    border-top: 1px solid #e0e0e0;
    background: #ffffff;
    padding: 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.03);
}

.upload-row {
    margin-bottom: 2px;
    padding-bottom: 2px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

textarea {
    flex: 1;
    resize: none;
    border: 2px solid #cfd8dc;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    min-height: 48px;
    transition: all 0.2s ease;
}
textarea:focus {
    border-color: #81d4fa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(129, 212, 250, 0.3);
}
.submit-button {
    background: #81d4fa;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    height: 48px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.submit-button:hover:not(:disabled) {
    background: #4fc3f7;
    transform: translateY(-1px);
}
.submit-button:disabled {
    background: #b0bec5;
    cursor: not-allowed;
}
.interrupt-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
.interrupt-icon {
    width: 16px;
    height: 16px;
}

/* File Upload & Previews */
.simple-file-upload {
    position: relative;
    margin-right: 12px;
}
.upload-row .simple-upload-button {
    background: none;
    border: none;
    color: #81d4fa;
    cursor: pointer;
    padding: 8px;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.upload-row .simple-upload-button:hover:not(:disabled) {
    transform: rotate(-45deg);
}

.simple-upload-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.file-previews {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 24px 12px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
}

.file-preview {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 8px;
    max-width: 200px;
}
.preview-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}
.file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e1f5fe;
    border-radius: 4px;
}
.file-info {
    display: flex;
    flex-direction: column;
}
.file-name {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.file-size {
    font-size: 0.7rem;
    color: #757575;
}
.remove-file {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    border: none;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.6rem;
}

/* Scroll to Bottom Button */
.scroll-to-bottom-container {
    position: absolute;
    bottom: 80px;
    right: 24px;
    z-index: 10;
}
.scroll-to-bottom-button {
    background-color: #81d4fa;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, transform 0.2s;
}
.scroll-to-bottom-button:hover {
    background-color: #4fc3f7;
    transform: translateY(-2px);
}

.file-previews-area {
    padding: 12px 24px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.horizontal-previews {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 0;
}

.horizontal-previews::-webkit-scrollbar {
    height: 6px;
}

.horizontal-previews::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.horizontal-previews::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Override ImagePreview width for horizontal layout */
.horizontal-previews .image-preview-card {
    width: 80px;
    flex-shrink: 0;
}

.horizontal-previews .image-container {
    height: 60px;
}

@keyframes dotPulse {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
.uploaded-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.user-image-links {
    margin-bottom: 8px;
}
.user-uploaded-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 4px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subject-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 10px;
}

.subject-label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.subject-dropdown {
    padding: 6px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    color: #495057;
    min-width: 120px;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.subject-dropdown:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.subject-dropdown:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Add styles for the QA type selector */
.qa-type-selector {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qa-type-label {
    font-weight: bold;
    color: #333;
    min-width: 80px;
}

.qa-type-dropdown {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    min-width: 150px;
}

.qa-type-dropdown:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Adjust existing subject selector if needed */
.subject-selector {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-label {
    font-weight: bold;
    color: #333;
    min-width: 80px;
}

.subject-dropdown {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    min-width: 200px;
}

.subject-dropdown:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}