/* Chatbot Button */
.chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 0;
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.chatbot-button img {
    width: 75%;
    height: 75%;
    object-fit: cover;
}

.chatbot-button.active {
    display: none;
}

/* Chatbot Container */
.chatbot-container {
    position: fixed;
    bottom: 15px;
    right: 24px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    transition: all 0.3s ease;
    text-align: justify;
}

.chatbot-container.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

.chatbot-container.fullscreen {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100vh;
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #11b76b 0%, #1cd791 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-avatar img {
    width: 75%;
    height: 75%;
    object-fit: cover;
}

.chatbot-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: white !important;
}

.chatbot-header-info p {
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.bot .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message.user .message-content {
    background: linear-gradient(135deg, #11b76b 0%, #1cd791 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 16px;
}

.message.user .message-time {
    text-align: right;
}

/* Markdown Formatting in Messages */
.message-content strong,
.message-content b {
    font-weight: 700;
    color: #11b76b;
}

.message-content em,
.message-content i {
    font-style: italic;
    color: #555;
}

.message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.message-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message-content ol {
    margin: 10px 0;
    padding: 0px !important;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.5;
    list-style-type: none;
}

.message-content ul li {
    list-style-type: none;
    position: relative;
    padding-left: 18px;
}

.message-content ul li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #11b76b;
    font-weight: bold;
    font-size: 16px;
}

.message-content h3,
.message-content h4 {
    margin: 12px 0 8px 0;
    color: #11b76b;
    font-weight: 600;
}

.message-content h3 {
    font-size: 15px;
}

.message-content h4 {
    font-size: 14px;
}

.message-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-content blockquote {
    border-left: 3px solid #11b76b;
    padding-left: 12px;
    margin: 10px 0;
    color: #666;
    font-style: italic;
}

.message-content .stat-highlight {
    background: #e8f5e9;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: #2e7d32;
}

.message-content hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 12px 0;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing-indicator.active {
    display: block;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Quick Replies */
.quick-replies {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: white;
    border-top: 1px solid #eee;
}

.quick-replies::-webkit-scrollbar {
    height: 4px;
}

.quick-reply {
    padding: 8px 16px;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-reply:hover {
    background: #11b76b;
    color: white;
    border-color: #11b76b;
}

.quick-reply:active {
    transform: scale(0.95);
}

.quick-reply.active {
    background: #11b76b;
    color: white;
    border-color: #11b76b;
    font-weight: 600;
}

/* Input Area */
.chatbot-input {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chatbot-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input input:focus {
    border-color: #11b76b;
    box-shadow: 0 0 0 3px rgba(17, 183, 107, 0.1);
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #11b76b 0%, #1cd791 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-button:hover {
    transform: scale(1.1);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Data Results Styling */
.data-results {
    margin-top: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
}

.data-results-header {
    padding: 10px 12px;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    font-size: 13px;
    user-select: none;
}

.data-results-header:hover {
    background: #e8e8e8;
}

.data-results-header.collapsed svg {
    transform: rotate(-90deg);
}

.data-results-header svg {
    transition: transform 0.2s ease;
}

.data-results-body {
    max-height: 400px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.data-results-body.collapsed {
    max-height: 0;
    overflow: hidden;
}

.data-item {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.data-item:last-child {
    border-bottom: none;
}

.data-item-header {
    font-weight: 600;
    font-size: 13px;
    color: #11b76b;
    margin-bottom: 8px;
}

.data-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.data-label {
    font-weight: 500;
    color: #666;
}

.data-value {
    color: #333;
    word-break: break-word;
}

.data-value.highlight {
    font-weight: 600;
    color: #11b76b;
}

.data-value em {
    font-style: italic;
}

/* Sources Section */
.sources-section {
    margin-top: 12px;
    border: 1px solid #e3f2fd;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fbff;
}

.sources-header {
    padding: 10px 12px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    font-weight: 600;
    font-size: 13px;
    color: #1976d2;
}

.sources-list {
    padding: 8px;
}

.source-item {
    padding: 10px;
    margin: 6px 0;
    background: white;
    border-radius: 6px;
    border: 1px solid #e3f2fd;
}

.source-title {
    font-weight: 500;
    font-size: 13px;
    color: #333;
    margin-bottom: 6px;
}

.source-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
}

.source-similarity {
    color: #11b76b;
    font-weight: 600;
}

.source-category {
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Follow-up Questions */
.follow-up-questions {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e7ff;
}

.follow-up-title {
    font-weight: 600;
    font-size: 13px;
    color: #11b76b;
    margin-bottom: 8px;
}

.follow-up-question {
    padding: 8px 12px;
    margin: 6px 0;
    background: white;
    border: 1px solid #e0e7ff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    transition: all 0.2s ease;
}

.follow-up-question:hover {
    background: #11b76b;
    color: white;
    border-color: #11b76b;
    transform: translateX(4px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        max-height: 100vh;
    }

    .chatbot-container.active {
        display: flex;
        flex-direction: column;
    }

    .chatbot-header {
        padding: 14px 16px;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .chatbot-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .quick-replies {
        padding: 10px 12px;
        gap: 6px;
        flex-shrink: 0;
        border-top: 1px solid #eee;
        background: white;
    }

    .chatbot-input {
        padding: 12px 16px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #eee;
    }

    .chatbot-button {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
    }

    .chatbot-header-info h3 {
        font-size: 15px;
    }

    .chatbot-header-info p {
        font-size: 11px;
    }

    .header-btn {
        width: 32px;
        height: 32px;
    }

    .header-btn svg {
        width: 18px;
        height: 18px;
    }

    .chatbot-header-actions {
        gap: 6px;
    }

    .message-content {
        max-width: 100%;
        font-size: 14px;
    }

    .message-content p {
        margin: 6px 0;
        line-height: 1.5;
    }

    .message-content ul {
        margin: 8px 0;
        padding-left: 16px;
    }


    .message-content li {
        margin: 5px 0;
        font-size: 13px;
    }

    .message-content h3 {
        font-size: 14px;
    }

    .message-content h4 {
        font-size: 13px;
    }

    .message-time {
        font-size: 10px;
    }

    .quick-reply {
        padding: 7px 14px;
        font-size: 12px;
    }

    .chatbot-input input {
        padding: 10px 14px;
        font-size: 16px;
    }

    .send-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        flex-shrink: 0;
    }

    .send-button svg {
        width: 18px;
        height: 18px;
    }

    .data-results {
        margin-top: 10px;
        font-size: 13px;
    }

    .data-results-header {
        padding: 8px 10px;
        font-size: 12px;
    }

    .data-item {
        padding: 10px;
    }

    .data-item-header {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .data-row {
        grid-template-columns: 100px 1fr;
        gap: 6px;
        padding: 5px 0;
        font-size: 12px;
    }

    .data-label {
        font-size: 11px;
    }

    .data-value {
        font-size: 12px;
    }

    .sources-section {
        margin-top: 10px;
    }

    .sources-header {
        padding: 8px 10px;
        font-size: 12px;
    }

    .source-item {
        padding: 8px;
    }

    .source-title {
        font-size: 12px;
    }

    .source-meta {
        font-size: 10px;
        gap: 8px;
    }

    .follow-up-questions {
        margin-top: 10px;
        padding: 10px;
    }

    .follow-up-title {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .follow-up-question {
        padding: 7px 10px;
        margin: 5px 0;
        font-size: 12px;
    }

    .typing-indicator {
        padding: 10px 14px;
    }

    .typing-indicator span {
        height: 7px;
        width: 7px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .chatbot-container {
        width: 380px;
        height: 460px;
    }

    .message-content {
        font-size: 14px;
    }

    .data-row {
        grid-template-columns: 110px 1fr;
        font-size: 13px;
    }
}

@media (min-width: 1025px) {
    .chatbot-container {
        width: 420px;
        height: 560px;
    }
}

@media (max-width: 360px) {
    .chatbot-header-info h3 {
        font-size: 14px;
    }

    .chatbot-header-info p {
        font-size: 10px;
    }

    .message-content {
        max-width: 100%;
        font-size: 13px;
        padding: 10px 14px;
    }

    .data-row {
        grid-template-columns: 90px 1fr;
        font-size: 11px;
    }

    .quick-reply {
        font-size: 11px;
        padding: 6px 12px;
    }
}

@media (max-width: 768px) {
    body.chatbot-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}
