/* ===== Tooishen Chatbot Widget ===== */

/* Toggle Button */
.chatbot-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c4f55, #3a6b73);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 79, 85, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(44, 79, 85, 0.55);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active svg.chat-icon {
    display: none;
}

.chatbot-toggle.active svg.close-icon {
    display: block;
}

.chatbot-toggle svg.close-icon {
    display: none;
}

/* Notification dot */
.chatbot-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #e8734a;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: chatbot-pulse 2s infinite;
}

.chatbot-toggle.active::after {
    display: none;
}

@keyframes chatbot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* Chat Panel */
.chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #2c4f55, #3a6b73);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.chatbot-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.chatbot-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.8;
    color: #fff;
}

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

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

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

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

/* Message Bubbles */
.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: chatbot-fadeIn 0.3s ease;
}

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

.chatbot-msg.bot {
    background: #fff;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chatbot-msg.user {
    background: linear-gradient(135deg, #2c4f55, #3a6b73);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.bot a {
    color: #2c4f55;
    text-decoration: underline;
    font-weight: 500;
}

.chatbot-msg.bot a:hover {
    color: #e8734a;
}

.chatbot-msg.bot strong {
    color: #2c4f55;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chatbot-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: chatbot-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes chatbot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input Area */
.chatbot-input {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}

.chatbot-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fa;
}

.chatbot-input input:focus {
    border-color: #2c4f55;
    background: #fff;
}

.chatbot-input input::placeholder {
    color: #999;
}

.chatbot-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2c4f55, #3a6b73);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(44, 79, 85, 0.3);
}

.chatbot-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-input button svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Location Banner */
.chatbot-location-banner {
    padding: 8px 14px;
    background: #e8f5e9;
    font-size: 12px;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chatbot-location-banner.pending {
    background: #fff3e0;
    color: #e65100;
}

.chatbot-location-banner svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-panel {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }

    .chatbot-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .chatbot-messages {
        max-height: calc(100vh - 200px);
    }
}
