/* ───────────────────────────────────────────────────────────────────────────
   FokaSoft AI Chatbot Styles
   ─────────────────────────────────────────────────────────────────────────── */

/* Root chatbot container */
.fokasoftChatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
        Cantarell, sans-serif;
    z-index: 9999;
}

/* AI chat float button active state */
.float-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
}

.float-ai.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35) !important;
}

.float-ai-wrap {
    position: relative;
    display: flex;
}

.chat-welcome-box {
    position: absolute;
    right: calc(100% + 20px);
    top: 50%;
    width: min(320px, calc(100vw - 120px));
    background: #ffffff;
    color: #1f2a44;
    border: 1px solid #dbe3ff;
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(22, 35, 75, 0.2);
    padding: 12px 36px 12px 14px;
    z-index: 2;
    opacity: 1;
    transform: translateY(-50%) scale(1);
    filter: blur(0);
    transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
                filter 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-welcome-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-welcome-close:hover {
    background: #eef2ff;
    color: #374151;
}

.chat-welcome-box::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-top: 1px solid #dbe3ff;
    border-right: 1px solid #dbe3ff;
    transform: translateY(-50%) rotate(45deg);
}

.chat-welcome-box.hidden {
    opacity: 0;
    transform: translateY(-50%) translateX(14px) scale(0.96);
    filter: blur(2px);
    pointer-events: none;
}

.chat-welcome-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}

/* Chat container */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 10000;
}

.chat-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.chat-header-content h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-content p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.close-btn:hover {
    opacity: 1;
}

/* Suggestions container */
.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.suggestion-btn {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: all 0.2s ease;
    text-align: left;
}

.suggestion-btn:hover {
    background: #f0f0f0;
    border-color: #667eea;
    color: #667eea;
}

/* Messages area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: white;
}

/* Message item */
.message-item {
    display: flex;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

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

.message-item.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-text {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-item.user .message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-item.bot .message-text {
    background: #e8e8e8;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-text.error {
    background: #fee;
    color: #c33;
}

.message-item.error .message-avatar {
    margin-top: 2px;
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #e8e8e8;
    border-radius: 8px;
    width: fit-content;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typingAnimation 1.4s infinite;
}

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

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

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

/* Input area */
.input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    border-radius: 0 0 12px 12px;
}

.message-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
}

.message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mic-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #d8d8d8;
    background: #f6f7fb;
    color: #4f5d75;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mic-btn:hover {
    background: #eef1ff;
    border-color: #c9d1ff;
    transform: scale(1.05);
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn.listening {
    background: #e03131;
    border-color: #c92a2a;
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.2);
    animation: micPulse 1.4s ease-in-out infinite;
}

.mic-btn[hidden] {
    display: none !important;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

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

@keyframes micPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(224, 49, 49, 0.35);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(224, 49, 49, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(224, 49, 49, 0);
    }
}

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

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

.messages-area::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive design */
@media (max-width: 480px) {
    .chat-welcome-box {
        right: calc(100% + 12px);
        top: 50%;
        width: min(280px, calc(100vw - 92px));
        padding: 10px 12px;
    }

    .chat-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: 500px;
        max-width: 100%;
    }

    .message-content {
        max-width: 220px;
    }

    .suggestions-container {
        gap: 8px;
        padding: 12px;
    }

    .suggestion-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

@media (max-width: 360px) {
    .chat-welcome-box {
        right: calc(100% + 10px);
        top: 50%;
        width: min(250px, calc(100vw - 78px));
    }

    .fokasoftChatbot {
        bottom: 10px;
        right: 10px;
    }

    .chat-toggle-btn {
        bottom: 10px;
        right: 10px;
        width: 54px;
        height: 54px;
    }

    .chat-container {
        width: calc(100vw - 16px);
    }

    .chat-header-content h3 {
        font-size: 14px;
    }

    .message-text {
        font-size: 13px;
        padding: 8px 12px;
    }

    .close-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: #2a2a2a;
        color: #e0e0e0;
    }

    .messages-area {
        background: #2a2a2a;
    }

    .suggestion-btn {
        background: #3a3a3a;
        border-color: #444;
        color: #e0e0e0;
    }

    .suggestion-btn:hover {
        background: #4a4a4a;
    }

    .message-item.bot .message-text {
        background: #404040;
        color: #e0e0e0;
    }

    .message-input {
        background: #3a3a3a;
        border-color: #444;
        color: #e0e0e0;
    }

    .message-input::placeholder {
        color: #888;
    }

    .messages-area::-webkit-scrollbar-thumb {
        background: #555;
    }

    .messages-area::-webkit-scrollbar-thumb:hover {
        background: #777;
    }
}
