/* === CSS Variables === */
:root {
    --primary-color: #4d61fc;
    --primary-dark: #3a4cd1;
    --secondary-color: #6c7aff;
    --accent-color: #ff9f43;
    --light-color: #f0f3ff;
    --dark-color: #2d3748;
    --success-color: #38c172;
    --danger-color: #e3342f;
    --warning-color: #ffce54;
    --info-color: #3498db;
    --gray-100: #f8f9fc;
    --gray-200: #edf2f7;
    --gray-300: #e2e8f0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --border-radius: 12px;
    --card-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0 15px 30px rgba(77, 97, 252, 0.15);
    --content-shadow: 0 3px 15px rgba(0, 0, 0, 0.04);
    --box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
    --primary-rgb: 77, 97, 252;
}

/* === General Styles === */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

body {
    font-family:ui-sans-serif,-apple-system,system-ui,Segoe UI,Helvetica,Apple Color Emoji,Arial,sans-serif,Segoe UI Emoji,Segoe UI Symbol;
    font-weight: 400;
    background-color: var(--gray-100);
    color: var(--dark-color);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

p {
    margin-bottom: 0 !important;
}

/* === Main Layout === */
.main-content {
    padding: 30px 0 105px;
    transition: all var(--transition-speed) ease;
    overflow-y: auto;
    position: relative;
    height: 97vh;
    width: 100%;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    border-radius: 2rem;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    position: relative;
    width: 65vw;
    margin: 0 auto;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* === Chat Input === */
.chat-input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    bottom: 0;
    width: 65vw;
    z-index: 10;
    border: 1px solid #00000026;
    border-radius: 2rem;
    background-color: #fff;
    padding: 10px;
    box-sizing: border-box;
    transition: height 0.2s ease-in-out;
    box-shadow: var(--card-shadow);
    max-height: 400px;
    height: 103px;
}

.button-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.right-buttons {
    display: flex;
    gap: 10px;
}

#questionInput {
    flex: 1;
    border: none;
    padding: 10px 15px;
    border-radius: 2rem;
    resize: none;
    width: 100%;
    transition: height 0.2s ease-in-out;
    min-height: 40px;
}

#questionInput:focus {
    outline: none;
}

/* === Buttons === */
#sendIcon,
#attachBtn,
#clearHistoryBtn {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

#sendIcon,
#attachBtn {
    color: var(--primary-color);
    background-color: white;
    border: 1px solid var(--primary-color);
}

#sendIcon:hover,
#attachBtn:hover {
    color: white;
    background-color: var(--primary-color);
}

#clearHistoryBtn {
    color: #e74c3c;
    background-color: white;
    border: 1px solid #e74c3c;
}

#clearHistoryBtn:hover {
    background-color: #e74c3c;
    color: white;
}

/* === Messages === */
.bot-message {
    max-width: 100%;
    padding: 15px;
    border-radius: 18px;
    position: relative;
    line-height: 2.2;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    color: #000;
    align-self: flex-start;
}

.message-content {
    width: 100%;
}

.bot-message table, th, tr, td {
    padding: 7px;
    border: 1px solid #00000026;
}

.user-message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 15px;
    line-height: 2.2;
}

.user-message-text {
    max-width: 75%;
    padding: 8px 15px;
    border-radius: 1.5rem;
    background-color: #e9e9e980;
    word-wrap: break-word;
    color: #000;
}

/* === Code Blocks === */
.bot-message pre {
    border-radius: 1rem;
    margin-top: 1rem;
}

.bot-message pre code {
    background-color: #f9f9f9;
}

.bot-message code {
    font-size: inherit;
    font-family: inherit;
    background-color: #ececec;
    padding: 0 .3rem 0.1rem;
    border-radius: .25rem;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    font-weight: inherit;
    color: #0d0d0d;
}

/* === Image Modal === */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10000;
    overflow: auto;
    animation: fadeIn 0.3s ease;
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: 5vh auto;
    display: block;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    transition: color 0.3s ease;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.image-modal-close:hover {
    color: #ccc;
}

.user-message-image {
    max-width: 300px;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Typing Indicator === */
.loading-message {
    background-color: #f0f2f5;
    opacity: 0.8;
}

.typing-indicator {
    display: flex;
    align-items: center;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 1px;
    background-color: #606060;
    border-radius: 50%;
    display: inline-block;
    animation: typing-bubble 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bubble {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* === Responsive Design === */
@media (max-width: 991.98px) {
    .chat-container {
        width: 100%;
    }

    .chat-input-container {
        width: 100%;
    }

    .button-container {
        padding: 0 10px;
    }
}

strong, th {
    font-weight: 600;
}

.container-fluid {
    padding: 0;
}