/* Mango Chatbot CSS - Elite Premium Design */

:root {
    --chat-primary: #1a9cb0;
    --chat-primary-light: #2dd4bf;
    --chat-primary-dark: #0d7a8a;
    --chat-accent: #f59e0b;
    --chat-accent-light: #fbbf24;
    --chat-bg: #0f0f14;
    --chat-header-bg: linear-gradient(135deg, #1a9cb0 0%, #0891b2 50%, #0e7490 100%);
    --chat-user-msg-bg: linear-gradient(135deg, #1a9cb0, #0d7a8a);
    --chat-bot-msg-bg: rgba(40, 40, 50, 0.95);
    --chat-text: #ffffff;
    --chat-input-bg: rgba(30, 30, 40, 0.95);
    --chat-border: rgba(26, 156, 176, 0.4);
    --chat-glow: rgba(26, 156, 176, 0.5);
}

/* ==================== FLOATING ACTION BUTTON ==================== */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 30px;
    height: 70px;
    width: 70px;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 50%, #ea580c 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 
        0 8px 32px rgba(245, 158, 11, 0.5),
        0 4px 16px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 
            0 8px 32px rgba(245, 158, 11, 0.5),
            0 4px 16px rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 
            0 8px 40px rgba(245, 158, 11, 0.7),
            0 4px 20px rgba(245, 158, 11, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.3);
    }
}

.chatbot-toggler:hover {
    transform: scale(1.15) rotate(10deg);
    box-shadow: 
        0 12px 40px rgba(245, 158, 11, 0.6),
        0 6px 24px rgba(0, 0, 0, 0.5);
}

.chatbot-toggler span {
    position: absolute;
    transition: all 0.4s ease;
}

.chatbot-toggler span:last-child,
.show-chatbot .chatbot-toggler span:first-child {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.show-chatbot .chatbot-toggler {
    background: linear-gradient(135deg, #1a9cb0, #0d7a8a);
}

/* ==================== CHATBOT WINDOW ==================== */
.chatbot-wrapper {
    position: fixed;
    bottom: 115px;
    right: 30px;
    width: 420px;
    max-height: 600px;
    background: var(--chat-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 28px;
    box-shadow: 
        0 32px 64px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(26, 156, 176, 0.3),
        0 0 60px -10px rgba(26, 156, 176, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85) translateY(30px);
    transform-origin: bottom right;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--chat-border);
}

.show-chatbot .chatbot-wrapper {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* ==================== HEADER ==================== */
.chatbot-header {
    background: var(--chat-header-bg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    animation: shimmer 4s infinite linear;
}

@keyframes shimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chatbot-header h2 {
    color: white;
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    letter-spacing: 0.3px;
}

.chatbot-header h2::before {
    content: '🥭';
    font-size: 1.5rem;
}

.chatbot-header .close-btn {
    color: white;
    cursor: pointer;
    font-size: 18px;
    background: rgba(255,255,255,0.2);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.chatbot-header .close-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: rotate(90deg) scale(1.1);
}

/* ==================== CHAT MESSAGES ==================== */
.chatbox {
    height: 420px;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 100px;
    background: #0f0f14;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-primary) transparent;
}

.chatbox::-webkit-scrollbar {
    width: 6px;
}

.chatbox::-webkit-scrollbar-track {
    background: transparent;
}

.chatbox::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--chat-primary), var(--chat-primary-dark));
    border-radius: 10px;
}

.chatbox .chat {
    display: flex;
    list-style: none;
    margin-bottom: 20px;
    animation: fadeInUp 0.4s ease;
}

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

.chatbox .chat p {
    white-space: pre-wrap;
    padding: 14px 20px;
    border-radius: 20px;
    max-width: 82%;
    font-size: 1.05rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

/* User Messages */
.chatbox .outgoing {
    justify-content: flex-end;
}

.chatbox .outgoing p {
    background: var(--chat-user-msg-bg);
    color: white;
    border-radius: 20px 20px 6px 20px;
    box-shadow: 
        0 6px 24px rgba(26, 156, 176, 0.35),
        inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Bot Messages */
.chatbox .incoming {
    justify-content: flex-start;
    align-items: flex-end;
}

.chatbox .incoming .mango-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    box-shadow: 
        0 4px 16px rgba(245, 158, 11, 0.4),
        0 0 0 3px rgba(245, 158, 11, 0.3);
    border: 2px solid rgba(245, 158, 11, 0.6);
    flex-shrink: 0;
}

.chatbox .incoming span.fa-robot {
    display: none;
}

.chatbox .incoming p {
    background: var(--chat-bot-msg-bg);
    color: var(--chat-text);
    border-radius: 20px 20px 20px 6px;
    border: 1px solid rgba(255,255,255,0.08);
}

.chatbox .incoming p a {
    color: var(--chat-accent-light) !important;
    text-decoration: none !important;
    font-weight: 600;
    transition: all 0.2s;
}

.chatbox .incoming p a:hover {
    color: #fcd34d !important;
    text-decoration: underline !important;
}

/* ==================== INPUT AREA ==================== */
.chat-input {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    gap: 12px;
    background: #0f0f14;
    padding: 18px 20px;
    backdrop-filter: blur(16px);
}

.chat-input textarea {
    height: 52px;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    background: var(--chat-input-bg);
    color: var(--chat-text);
    padding: 15px 20px;
    border-radius: 26px;
    font-size: 1.05rem;
    font-family: inherit;
    border: 2px solid rgba(26, 156, 176, 0.25);
    transition: all 0.3s ease;
}

.chat-input textarea:focus {
    border-color: var(--chat-primary);
    box-shadow: 
        0 0 0 4px rgba(26, 156, 176, 0.15),
        0 4px 20px rgba(26, 156, 176, 0.2);
}

.chat-input textarea::placeholder {
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
}

/* ==================== SEND BUTTON ==================== */
#send-btn {
    align-self: center;
    color: white;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    border-radius: 50%;
    border: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 6px 24px rgba(26, 156, 176, 0.5),
        0 3px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    flex-shrink: 0;
}

#send-btn:hover {
    transform: scale(1.15);
    box-shadow: 
        0 8px 32px rgba(26, 156, 176, 0.7),
        0 4px 16px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, var(--chat-primary-light), var(--chat-primary));
}

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

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 0;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: var(--chat-primary-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 490px) {
    .chatbot-wrapper {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        background: #0f0f14;
        font-size: 17px;
    }

    .chatbot-wrapper .chatbox {
        height: calc(100vh - 160px);
        height: calc(100dvh - 160px);
        padding: 20px;
        padding-bottom: 100px;
    }

    .chatbox .chat p {
        font-size: 1.75rem;
        padding: 20px 23px;
        max-width: 88%;
        line-height: 1.7;
    }

    .chatbot-header {
        padding: 18px 20px;
    }

    .chatbot-header h2 {
        font-size: 1.7rem;
    }

    .chat-input {
        padding: 16px 18px;
        gap: 10px;
    }

    .chat-input textarea {
        font-size: 18px !important;
        height: 58px;
        padding: 18px 20px;
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none;
        appearance: none;
    }

    .chat-input textarea::placeholder {
        font-size: 16px;
    }

    #send-btn {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .chatbot-toggler {
        bottom: 20px;
        right: 20px;
        height: 62px;
        width: 62px;
        font-size: 26px;
    }

    .show-chatbot .chatbot-toggler {
        display: none;
    }

    .chatbox .incoming .mango-avatar {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }
}

/* Extra small screens - keep fonts readable */
@media (max-width: 360px) {
    .chatbox .chat p {
        font-size: 1.1rem;
        padding: 14px 16px;
    }
    
    .chatbot-header h2 {
        font-size: 1.4rem;
    }
}

/* ==================== STATES ==================== */
.chat-input textarea:disabled {
    background: rgba(40, 40, 50, 0.6);
    color: rgba(255,255,255,0.5);
    cursor: not-allowed;
}

/* Prevent touch issues on mobile */
.chatbot-wrapper {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.chatbox .chat p {
    -webkit-user-select: text;
    user-select: text;
}

.chat-input textarea {
    -webkit-user-select: text;
    user-select: text;
}
