/* Chatbot Styles */
.chatbot-toggle {
    display: flex;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ffffff;
    color: white;
    border: 1px solid #0A6A47;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(10, 106, 71, 0.3);
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    /* Below .welcome-toast (10100); .chatbot-window is 10200 when open */
    z-index: 10050;
    transition: all 0.3s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(10, 106, 71, 0.4);
}

.chatbot-toggle.chatbot-active {
    border-color: #06402B;
}

.chatbot-toggle.chatbot-toggle--fallback {
    background: linear-gradient(145deg, #0a6a47 0%, #06402b 100%);
    color: #ffffff;
}

.chatbot-toggle-fallback-icon {
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chatbot-window {
    display: flex;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 400px;
    max-width: calc(100vw - 4rem);
    height: 600px;
    max-height: calc(100vh - 4rem);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    /* Below welcome toast (10950); below .cv-modal (11000) */
    z-index: 10200;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    border: 1px solid rgba(10, 106, 0.1);
}

.chatbot-window.chatbot-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chatbot-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(10, 106, 71, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #FAFAFA;
    border-radius: 16px 16px 0 0;
}

.chatbot-header-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0A6A47;
    margin-bottom: 0.25rem;
}

.chatbot-header-content p {
    font-size: 0.875rem;
    color: #3B4D50;
    margin: 0;
}

.chatbot-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #3B4D50;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 1rem;
}

.chatbot-close:hover {
    background: rgba(10, 106, 71, 0.1);
}

.chatbot-close svg {
    width: 20px;
    height: 20px;
}

.chatbot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chatbot-message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message-user {
    align-self: flex-end;
    margin-left: auto;
}

.chatbot-message-assistant {
    align-self: flex-start;
}

.chatbot-message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.9375rem;
}

.chatbot-message-user .chatbot-message-content {
    background: #0A6A47;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-assistant .chatbot-message-content {
    background: #F0F0F0;
    color: #3B4D50;
    border-bottom-left-radius: 4px;
}

.chatbot-typing .chatbot-message-content {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3B4D50;
    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.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.chatbot-input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(10, 106, 71, 0.1);
    display: flex;
    gap: 0.75rem;
    background: #FAFAFA;
    border-radius: 0 0 16px 16px;
}

.chatbot-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(10, 106, 71, 0.2);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #3B4D50;
    background: white;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    outline: none;
    border-color: #0A6A47;
}

.chatbot-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #0A6A47;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    background: #06402B;
    transform: scale(1.05);
}

.chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Mobile: bottom sheet (~75% height), slide up from bottom; header + X stay visible */
@media (max-width: 768px) {
    .chatbot-toggle {
        bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
        right: max(1.5rem, env(safe-area-inset-right, 0px));
        width: 56px;
        height: 56px;
    }

    .chatbot-toggle.chatbot-active {
        opacity: 0;
        pointer-events: none;
    }

    .chatbot-window {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: none;
        height: 75vh;
        height: 75dvh;
        max-height: 75vh;
        max-height: 75dvh;
        border-radius: 16px 16px 0 0;
        transform: translateY(105%);
        box-sizing: border-box;
    }

    .chatbot-window.chatbot-open {
        transform: translateY(0);
    }

    .chatbot-header {
        flex-shrink: 0;
        border-radius: 16px 16px 0 0;
    }

    .chatbot-close {
        min-width: 44px;
        min-height: 44px;
        margin-left: 0.5rem;
    }

    .chatbot-input-container {
        flex-shrink: 0;
        border-radius: 0;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .chatbot-message {
        max-width: 90%;
    }
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #0A6A47;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #06402B;
}
