/* ==========================================================================
   Chatbot UI (Mitsuo's Makikomi Bot)
   ========================================================================== */
.chatbot-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    font-family: var(--font-main);
}

.chatbot-toggle {
    display: none;
    /* Hidden across all layouts now, launched only from bottom menu or code */
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-passion-primary) 0%, #B00020 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg), 0 0 15px rgba(230, 57, 70, 0.4);
    cursor: pointer;
    transition: transform var(--trans-normal), box-shadow var(--trans-normal);
    border: 3px solid white;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg), 0 0 25px rgba(230, 57, 70, 0.6);
}

.chatbot-toggle i {
    font-size: 1.6rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-toggle.open i {
    transform: rotate(90deg) scale(0);
}

.chatbot-toggle .icon-close {
    position: absolute;
    transform: rotate(-90deg) scale(0);
    font-size: 1.8rem;
}

.chatbot-toggle.open .icon-close {
    transform: rotate(0) scale(1);
}

.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #F4A261;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

.chatbot-panel {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 360px;
    height: 520px;
    background-color: var(--color-surface);
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chatbot-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chatbot-header {
    background: linear-gradient(135deg, var(--color-passion-primary) 0%, #B00020 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header button[id="chatbot-close-btn"] {
    position: relative;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2) !important;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.chatbot-header button[id="chatbot-close-btn"]:hover {
    background: rgba(255, 255, 255, 0.4) !important;
    transform: scale(1.1);
}

.chatbot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: white;
    border: 2px solid rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

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

.chatbot-info h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 2px;
    font-family: var(--font-heading);
}

.chatbot-info p {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0;
}

.chatbot-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--color-snow-light);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.message {
    max-width: 85%;
    animation: messageSlideIn 0.3s ease forwards;
}

.message-bot {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

.message-bot .message-bubble {
    background-color: white;
    color: var(--color-text-main);
    border-bottom-left-radius: 4px;
    border-left: 2px solid var(--color-passion-primary);
}

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

.message-time {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 4px;
    display: block;
}

.message-bot .message-time {
    text-align: left;
    margin-left: 4px;
}

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

.chatbot-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chatbot-option-btn {
    background-color: var(--color-passion-light);
    color: var(--color-passion-primary);
    border: 1px solid rgba(230, 57, 70, 0.2);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.chatbot-option-btn:hover {
    background-color: var(--color-passion-primary);
    color: white;
}

.chatbot-input-area {
    padding: 15px;
    background-color: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 10px;
}

.chatbot-input {
    flex-grow: 1;
    background-color: var(--color-snow-mid);
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: box-shadow var(--trans-fast);
}

.chatbot-input:focus {
    box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.2);
    background-color: white;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-passion-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.chatbot-send:hover {
    background-color: var(--color-passion-hover);
    transform: scale(1.05);
}

.chatbot-send i {
    margin-left: -2px;
}

/* Animations */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(244, 162, 97, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(244, 162, 97, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(244, 162, 97, 0);
    }
}

@media (max-width: 480px) {
    .chatbot-panel {
        position: fixed;
        bottom: 0px;
        /* Attach to bottom exactly or slightly above menu */
        right: 0;
        width: 100%;
        height: calc(100vh - 60px);
        /* Leave room for mobile footer menu */
        border-radius: 20px 20px 0 0;
        z-index: 2001;
    }
}