/* ===================================
   Tupu Chatbot Styles
   Bilingual Assistant - Cherie from Tupu
   =================================== */

:root {
    /* Tupu brand colors */
    --tupu-primary: #4E825F;
    --tupu-primary-hover: #3C6B4F;
    --tupu-primary-dark: #2E5C42;
    --tupu-accent: #8FBF8F;
    --tupu-bg: #F1F5E8;
    --tupu-text: #2C3A32;
    --tupu-border: #CDE2C7;
    
    /* Chatbot specific */
    --tupu-chat-shadow: 0 8px 32px rgba(78, 130, 95, 0.25);
    --tupu-chat-radius: 16px;
    --tupu-chat-z: 10000;
}

/* ===================================
   FAB Button (Floating Action Button)
   =================================== */

.tupu-chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--tupu-primary) 0%, var(--tupu-primary-hover) 100%);
    border: none;
    border-radius: 50%;
    box-shadow: var(--tupu-chat-shadow);
    cursor: pointer;
    z-index: var(--tupu-chat-z);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
}

.tupu-chatbot-fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(78, 130, 95, 0.35);
}

.tupu-chatbot-fab:active {
    transform: translateY(-1px) scale(0.98);
}

.tupu-chatbot-fab i {
    font-size: 28px;
}

.tupu-chatbot-fab.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Pulse animation for attention */
@keyframes tupu-pulse {
    0% {
        box-shadow: var(--tupu-chat-shadow);
    }
    50% {
        box-shadow: 0 8px 32px rgba(78, 130, 95, 0.4), 
                    0 0 0 12px rgba(78, 130, 95, 0.15);
    }
    100% {
        box-shadow: var(--tupu-chat-shadow);
    }
}

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

.tupu-chatbot-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: var(--tupu-chat-radius);
    box-shadow: var(--tupu-chat-shadow);
    z-index: calc(var(--tupu-chat-z) - 1);
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--tupu-border);
    overflow: hidden;
}

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

/* ===================================
   Chat Header
   =================================== */

.tupu-chat-header {
    background: linear-gradient(135deg, var(--tupu-primary) 0%, var(--tupu-primary-hover) 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--tupu-chat-radius) var(--tupu-chat-radius) 0 0;
    flex-shrink: 0;
}

.tupu-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tupu-chat-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;
}

.tupu-chat-avatar i {
    font-size: 22px;
}

.tupu-chat-avatar.ai {
    background: rgba(255, 255, 255, 0.25);
}

.tupu-chat-avatar.user {
    background: var(--tupu-accent);
    color: var(--tupu-text);
}

.tupu-chat-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    font-family: 'DM Serif Display', serif;
}

.tupu-chat-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.tupu-chat-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tupu-lang-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tupu-lang-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.tupu-close-btn {
    background: none;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tupu-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tupu-close-btn i {
    font-size: 16px;
}

/* ===================================
   Chat Messages Area
   =================================== */

.tupu-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--tupu-bg);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.tupu-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.tupu-chat-messages::-webkit-scrollbar-thumb {
    background: var(--tupu-accent);
    border-radius: 3px;
}

.tupu-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--tupu-primary);
}

/* ===================================
   Chat Messages
   =================================== */

.tupu-message {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: tupu-slide-in 0.3s ease-out;
}

@keyframes tupu-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.tupu-message-ai {
    flex-direction: row;
}

.tupu-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-line;
}

.tupu-message-user .tupu-message-bubble {
    background: linear-gradient(135deg, var(--tupu-primary) 0%, var(--tupu-primary-hover) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.tupu-message-ai .tupu-message-bubble {
    background: white;
    color: var(--tupu-text);
    border: 1px solid var(--tupu-border);
    border-bottom-left-radius: 4px;
}

.tupu-message .tupu-chat-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

/* ===================================
   Typing Indicator
   =================================== */

.tupu-typing-indicator {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.tupu-typing-dots {
    background: white;
    border: 1px solid var(--tupu-border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.tupu-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--tupu-accent);
    border-radius: 50%;
    animation: tupu-typing 1.4s infinite;
}

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

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

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

/* ===================================
   Input Area
   =================================== */

.tupu-chat-input-area {
    background: white;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--tupu-border);
    flex-shrink: 0;
}

.tupu-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.tupu-chat-input {
    flex: 1;
    border: 1.5px solid var(--tupu-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    transition: all 0.2s ease;
    color: var(--tupu-text);
}

.tupu-chat-input:focus {
    outline: none;
    border-color: var(--tupu-primary);
    box-shadow: 0 0 0 3px rgba(78, 130, 95, 0.1);
}

.tupu-chat-input::placeholder {
    color: #9ca3af;
}

.tupu-send-btn {
    background: linear-gradient(135deg, var(--tupu-primary) 0%, var(--tupu-primary-hover) 100%);
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    flex-shrink: 0;
}

.tupu-send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 130, 95, 0.3);
}

.tupu-send-btn:active:not(:disabled) {
    transform: translateY(0);
}

.tupu-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tupu-send-btn i {
    font-size: 16px;
}

/* ===================================
   Mobile Responsiveness
   =================================== */

@media (max-width: 768px) {
    .tupu-chatbot-widget {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 99999;
    }
    
    .tupu-chatbot-widget.open {
        transform: translateY(0) scale(1);
    }
    
    .tupu-chat-header {
        border-radius: 0;
        padding: 20px 16px 16px;
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .tupu-chat-messages {
        padding: 16px;
    }
    
    .tupu-chat-input-area {
        padding: 16px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .tupu-chatbot-fab {
        bottom: max(24px, env(safe-area-inset-bottom));
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .tupu-chatbot-fab i {
        font-size: 24px;
    }
    
    .tupu-message-bubble {
        max-width: 85%;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .tupu-lang-toggle {
        font-size: 11px;
        padding: 5px 10px;
    }
    
    .tupu-chat-title {
        font-size: 16px;
    }
    
    .tupu-chat-subtitle {
        font-size: 12px;
    }
}

/* ===================================
   Accessibility
   =================================== */

@media (prefers-reduced-motion: reduce) {
    .tupu-chatbot-fab,
    .tupu-chatbot-widget,
    .tupu-message,
    .tupu-typing-dots span {
        animation: none;
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .tupu-chatbot-widget {
        border: 2px solid var(--tupu-primary-dark);
    }
    
    .tupu-message-ai .tupu-message-bubble {
        border: 2px solid var(--tupu-primary);
    }
    
    .tupu-chat-input {
        border: 2px solid var(--tupu-primary);
    }
}

/* ===================================
   Z-index Management (ensure above other elements)
   =================================== */

.tupu-chatbot-fab,
.tupu-chatbot-widget {
    z-index: 10001 !important;
}

/* Ensure FAB is always visible */
.tupu-chatbot-fab {
    position: fixed !important;
    right: 24px !important;
}

@media (max-width: 768px) {
    .tupu-chatbot-fab {
        right: 16px !important;
    }
}
