:root {
    --primary: #0073aa;
    --primary-dark: #005d87;
    --primary-darker: #003e5c;
    --bot-bg: #e0f7fa;
    --user-bg: #dcedc8;
    --header-bg: linear-gradient(135deg, var(--primary), var(--primary-dark));
    --header-bg-hover: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
    --tag-border: var(--primary);
    --tag-bg: #fff;
    --tag-hover-bg: var(--primary);
    --tag-hover-color: #fff;
}

/* Bubble Button */
#ai-chat-bubble {
    width: 64px;
    height: 64px;
    background: var(--header-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    transition: transform 0.3s ease, background 0.3s ease;
}
#ai-chat-bubble:hover, #ai-chat-bubble:focus {
    transform: scale(1.1);
    background: var(--header-bg-hover);
    outline: 2px solid var(--primary);
}
#ai-chat-bubble img {
    width: 36px;
    height: 36px;
}

/* Chat Box */
#ai-chatbox {
    width: 370px;
    max-height: 600px;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    font-family: 'Poppins', sans-serif;
    z-index: 10000;
    transition: all 0.3s ease;
}
#ai-chatbox.hidden {
    display: none;
}

/* Chat Header */
#ai-chat-header {
    background: var(--header-bg);
    color: #fff;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ai-header-left {
    display: flex;
    align-items: center;
}
.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    margin-right: 12px;
}
.ai-name {
    display: flex;
    flex-direction: column;
    font-size: 14px;
}
.ai-name strong {
    font-size: 16px;
}
.ai-name small {
    font-size: 12px;
    opacity: 0.8;
}
#ai-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
}
#ai-close:focus {
    outline: 2px solid var(--primary);
    background: rgba(0,0,0,0.08);
}

/* Messages */
#ai-messages {
    flex: 1;
    background: #f4f6f8;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -ms-overflow-style: none;  /* Hide scrollbar in IE and Edge */
    scrollbar-width: none;     /* Hide scrollbar in Firefox */
}

#ai-messages::-webkit-scrollbar {
    display: none;             /* Hide scrollbar in Chrome, Safari and Opera */
}

/* Message Container */
#all-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;               /* Take full width of container */
    height: 400px;              /* <-- Hardcoded fixed height for now */
    overflow-y: auto;
    padding-right: 8px;         /* Small padding to avoid hidden scroll */
    flex: 1 1 auto;
    -ms-overflow-style: none;   /* Hide scrollbar in IE and Edge */
    scrollbar-width: none;      /* Hide scrollbar in Firefox */
}

#all-messages::-webkit-scrollbar {
    display: none;              /* Hide scrollbar in Chrome, Safari and Opera */
}

/* Message Styles */
.ai-msg {
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    width: fit-content;
    max-width: 80%;
    display: inline-block;
    word-break: break-word;
    line-height: 1.4;
    transition: all 0.3s;
    white-space: normal;
    text-align: left;
    overflow-wrap: break-word;
}

.ai-msg-bot {
    background: var(--bot-bg);
    align-self: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.ai-msg-bot a {
    display: inline-block;
    word-break: break-all;
    color: var(--primary);
    text-decoration: underline;
}

.ai-msg-user {
    background: var(--user-bg);
    align-self: flex-end;
}

/* Fix for the multi-column issue in messages with breaks */
.ai-msg br {
    display: block;
    content: "";
    margin-top: 8px;
}

.ai-msg p {
    margin: 0 0 8px 0;
}

.ai-msg p:last-child {
    margin-bottom: 0;
}

.ai-msg ul, .ai-msg ol {
    margin-top: 4px;
    margin-bottom: 4px;
    padding-left: 20px;
}

.ai-msg li {
    margin-bottom: 4px;
}

/* Typing container inside messages */
.ai-msg > div {
    width: 100%;
}

/* Quick Tags */
.ai-quick-tags {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.ai-quick-tags::-webkit-scrollbar {
    display: none;
}
.ai-tag {
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    color: var(--primary);
    font-size: 11px;
    padding: 8px 14px;
    border-radius: 20px;
    white-space: nowrap;
    flex: 0 0 auto;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    height: 30px;
}
.ai-tag:hover, .ai-tag:focus {
    background: var(--tag-hover-bg);
    color: var(--tag-hover-color);
    outline: 2px solid var(--primary);
}

/* Input Section - Completely Redesigned */
#ai-input-row {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
}

/* File Preview Area */
.ai-file-preview-area,
#ai-file-preview {
    display: none;
    margin-bottom: 10px;
    width: 100%;
}

.ai-file-preview-area > div,
#ai-file-preview > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: #e7f3ff;
    border: 1px solid #90caf9;
    border-radius: 8px;
}

.ai-file-preview-area span,
#ai-file-preview span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border-radius: 16px;
    font-size: 12px;
    color: #424242;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-width: 180px;
}

.ai-file-preview-area .remove-file,
#ai-file-preview .remove-file {
    margin-left: 4px;
    padding: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #f44336;
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    border-radius: 50%;
}

.ai-file-preview-area .remove-file:hover,
#ai-file-preview .remove-file:hover {
    background: rgba(244, 67, 54, 0.1);
    color: #d32f2f;
}

/* Input Wrapper - 10-80-10 Layout */
.ai-input-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.ai-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.08);
}

/* Upload Button - 10% */
#ai-upload-btn {
    background: #f5f5f5;
    border: none;
    border-right: 1px solid #e0e0e0;
    color: #757575;
    padding: 0;
    width: 10%;
    min-width: 48px;
    height: 48px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#ai-upload-btn svg {
    width: 20px;
    height: 20px;
}

#ai-upload-btn:hover {
    background: var(--primary);
    color: white;
}

#ai-upload-btn:active {
    transform: scale(0.96);
}

/* Text Input - 80% */
#ai-input {
    flex: 1;
    width: 80%;
    border: none;
    background: transparent;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    color: #212121;
    outline: none;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#ai-input::-webkit-scrollbar {
    display: none;
}

#ai-input::placeholder {
    color: #bdbdbd;
}

/* Send Button - 10% Square */
#ai-send {
    background: var(--primary);
    border: none;
    border-left: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0;
    width: 10%;
    min-width: 48px;
    height: 48px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

#ai-send svg {
    width: 20px;
    height: 20px;
}

#ai-send:hover {
    background: var(--primary-dark);
}

#ai-send:active {
    transform: scale(0.96);
}

#ai-send:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
    opacity: 0.6;
}
/* Thinking Typing Message */
.thinking-msg {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 20px;
    background: var(--bot-bg);
    max-width: 70%;
    font-size: 14px;
    animation: fadeSlideIn 0.5s forwards;
}

.typing-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.typing-dots {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    height: 24px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Keyframes for blinking effect */
@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}
#ai-popup-msg {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 24px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: fadeSlideUp 0.4s ease-out;
}
#ai-popup-msg:focus {
    outline: 2px solid var(--primary);
}
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 500px) {
    #ai-chatbox {
        width: 98vw;
        max-height: 90vh;
        border-radius: 12px;
    }
    #all-messages {
        height: 220px;
    }
    #ai-chat-bubble {
        width: 52px;
        height: 52px;
    }
    .ai-avatar {
        width: 32px;
        height: 32px;
    }
}

/* Additional styling for special content */
.ai-msg table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 12px;
}

.ai-msg table td, 
.ai-msg table th {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: left;
}

.ai-msg table th {
    background-color: rgba(0,115,170,0.1);
}

/* Improve mobile layout */
@media (max-width: 500px) {
    .ai-msg {
        max-width: 92%;
        font-size: 13px;
    }
    
    .ai-msg table {
        font-size: 11px;
    }
    
    .ai-msg table td, 
    .ai-msg table th {
        padding: 4px;
    }
}

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