/**
 * Chatbot Widget CSS
 * Dinas Pertanian, Perikanan dan Kehutanan Kota Pontianak
 * December 2024
 */

:root {
    --chatbot-primary: #40ae4e;
    --chatbot-primary-dark: #2d8a3a;
    --chatbot-bg: #ffffff;
    --chatbot-user-bg: #40ae4e;
    --chatbot-bot-bg: #f0f0f0;
    --chatbot-text: #333333;
    --chatbot-text-light: #666666;
    --chatbot-border: #e0e0e0;
    --chatbot-shadow: rgba(0, 0, 0, 0.15);
}

/* Widget Container - Fixed di pojok kanan bawah */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1010;
    font-family: 'Roboto', Arial, sans-serif;
}

/* Toggle Button - Bulat 60px */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--chatbot-shadow);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px var(--chatbot-shadow);
}

#chatbot-toggle:active {
    transform: scale(0.95);
}

#chatbot-toggle i {
    transition: transform 0.3s ease;
}

#chatbot-toggle.active i.fa-comments {
    transform: rotate(360deg);
}

/* Chat Container - 380x500px */
#chatbot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--chatbot-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--chatbot-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#chatbot-container.show {
    display: flex;
}

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

/* Header */
#chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chatbot-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    padding: 4px;
    object-fit: contain;
}

#chatbot-title {
    display: flex;
    flex-direction: column;
}

#chatbot-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#chatbot-title span {
    font-size: 12px;
    opacity: 0.9;
}

#chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s ease;
}

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message Bubble */
.chatbot-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message.user {
    flex-direction: row-reverse;
}

.chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.chatbot-message.bot .chatbot-avatar {
    background: var(--chatbot-primary);
    color: white;
}

.chatbot-message.user .chatbot-avatar {
    background: var(--chatbot-primary-dark);
    color: white;
}

.chatbot-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chatbot-message.bot .chatbot-bubble {
    background: var(--chatbot-bot-bg);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-bubble {
    background: var(--chatbot-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-bubble p {
    margin: 0 0 8px 0;
}

.chatbot-bubble p:last-child {
    margin-bottom: 0;
}

/* Answer with HTML content */
.chatbot-answer {
    line-height: 1.6;
}

.chatbot-answer strong {
    color: var(--chatbot-primary-dark);
}

.chatbot-answer ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.chatbot-answer li {
    margin-bottom: 4px;
}

.chatbot-answer a {
    color: var(--chatbot-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.chatbot-answer a:hover {
    color: var(--chatbot-primary-dark);
    text-decoration: underline;
}

/* Sources Links */
.chatbot-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.chatbot-sources strong {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--chatbot-text-light);
}

.chatbot-sources a {
    display: block;
    font-size: 12px;
    color: var(--chatbot-primary);
    text-decoration: none;
    margin-bottom: 4px;
    transition: color 0.2s ease;
}

.chatbot-sources a:hover {
    color: var(--chatbot-primary-dark);
    text-decoration: underline;
}

.chatbot-sources a i {
    margin-right: 4px;
}

/* Typing Indicator */
#chatbot-typing {
    display: none;
    align-items: center;
    gap: 8px;
}

#chatbot-typing.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--chatbot-bot-bg);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    animation: typing 1.4s infinite;
}

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

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

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

/* Input Area */
#chatbot-input-area {
    padding: 16px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 8px;
}

#chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease;
}

#chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

#chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

#chatbot-send:active {
    transform: scale(0.95);
}

#chatbot-send:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Welcome Message */
.chatbot-welcome {
    text-align: center;
    padding: 20px;
    color: var(--chatbot-text-light);
}

.chatbot-welcome i {
    font-size: 48px;
    color: var(--chatbot-primary);
    margin-bottom: 12px;
}

.chatbot-welcome h3 {
    margin: 0 0 8px 0;
    color: var(--chatbot-text);
    font-size: 18px;
}

.chatbot-welcome p {
    margin: 0;
    font-size: 14px;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    #chatbot-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    #chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 22px;
        margin-left: auto;
    }

    #chatbot-container {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        bottom: 76px;
        right: 0;
        left: 0;
        border-radius: 12px 12px 0 0;
    }

    .chatbot-bubble {
        max-width: 85%;
    }

    #chatbot-header {
        padding: 12px;
    }

    #chatbot-logo {
        width: 36px;
        height: 36px;
    }

    #chatbot-title h4 {
        font-size: 14px;
    }

    #chatbot-title span {
        font-size: 11px;
    }

    #chatbot-messages {
        padding: 12px;
    }

    #chatbot-input-area {
        padding: 12px;
    }
}

/* Accessibility */
#chatbot-toggle:focus,
#chatbot-close:focus,
#chatbot-send:focus,
#chatbot-input:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}

/* Print - Hide widget */
@media print {
    #chatbot-widget {
        display: none !important;
    }
}
