/* ==========================================================================
   AI Assistant Bursa Ikan - Modern Clean White Theme
   ========================================================================== */

/* Toggle Floating Button */
#chatToggle {
    position: fixed !important;
    bottom: 28px !important;
    right: 28px !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

#chatToggle:hover {
    transform: translateY(-4px) scale(1.02) !important;
}

.chat-toggle-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid rgba(14, 107, 168, 0.15);
    color: #0e6ba8;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Montserrat', 'Inter', sans-serif;
    padding: 10px 16px;
    border-radius: 9999px;
    box-shadow: 0 6px 24px rgba(14, 107, 168, 0.18), 0 2px 8px rgba(0,0,0,0.08);
    white-space: nowrap;
    letter-spacing: -0.01em;
    transition: all 0.25s ease;
}

#chatToggle:hover .chat-toggle-pill {
    background: #f0f8ff;
    box-shadow: 0 10px 32px rgba(14, 107, 168, 0.25), 0 4px 12px rgba(0,0,0,0.1);
    color: #0077cc;
}

.chat-toggle-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    display: inline-block;
    flex-shrink: 0;
    animation: chatPulse 2.2s ease-in-out infinite;
}

.chat-toggle-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(145deg, #0ea5e9, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    box-shadow: 0 6px 20px rgba(14, 107, 168, 0.45), 0 2px 6px rgba(0,0,0,0.15);
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#chatToggle:hover .chat-toggle-circle {
    background: linear-gradient(145deg, #38bdf8, #3b82f6);
    box-shadow: 0 10px 30px rgba(14, 107, 168, 0.6);
}

.chat-toggle-badge {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 13px;
    height: 13px;
    background: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

@keyframes chatPulse {
    0%, 100% { opacity: 0.7; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* ===================== Chatbot Container ===================== */
#chatbot {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 400px !important;
    max-width: calc(100vw - 32px) !important;
    height: 580px !important;
    max-height: calc(100vh - 48px) !important;
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 20px !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(14, 107, 168, 0.08) !important;
    display: none;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 999999 !important;
    font-family: 'Montserrat', 'Inter', -apple-system, sans-serif !important;
    animation: chatSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================== Header ===================== */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 14px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    user-select: none;
    flex-shrink: 0;
}

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

.ai-chat-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.ai-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
    animation: chatPulse 2.2s ease-in-out infinite;
    flex-shrink: 0;
}

.ai-chat-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.ai-chat-subtitle {
    font-size: 11.5px;
    color: #64748b;
    font-weight: 500;
    margin: 0;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-chat-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 13px;
    padding: 0;
    line-height: 1;
}

.ai-chat-icon-btn:hover {
    background: #eff6ff;
    color: #3b82f6;
    border-color: #bfdbfe;
}

.ai-chat-icon-btn.close-btn:hover {
    background: #fff1f2;
    color: #ef4444;
    border-color: #fecaca;
}

/* ===================== Messages Area ===================== */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    min-height: 0;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

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

/* ===================== Message Bubbles ===================== */
.ai-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: fadeInMsg 0.2s ease;
}

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

.ai-msg.bot {
    align-self: flex-start;
}

.ai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 82%;
}

.ai-msg-bubble {
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.ai-msg.bot .ai-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ai-msg.user .ai-msg-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* ===================== Welcome Card ===================== */
.ai-welcome-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 4px;
}

.ai-welcome-title {
    font-size: 14px;
    font-weight: 700;
    color: #0369a1;
    margin: 0 0 6px 0;
}

.ai-welcome-text {
    font-size: 12.5px;
    color: #475569;
    line-height: 1.55;
    margin: 0 0 12px 0;
}

/* ===================== Quick Prompt Chips ===================== */
.ai-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-chip {
    background: #ffffff;
    border: 1.5px solid #93c5fd;
    color: #1d4ed8;
    font-size: 11.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.1);
    line-height: 1.3;
}

.ai-chip:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* ===================== Typing / Loading Indicator ===================== */
.ai-loading-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 12px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ai-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3b82f6;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.18s; background: #60a5fa; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.36s; background: #93c5fd; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-6px); opacity: 1; }
}

.ai-loading-text {
    font-size: 12.5px;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

/* ===================== Input Area ===================== */
.ai-chat-input-area {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    color: #1e293b;
    font-size: 13px;
    font-family: inherit;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    min-width: 0;
}

.ai-chat-input:focus {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ai-chat-input::placeholder {
    color: #94a3b8;
    font-size: 12.5px;
}

.ai-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    border: none;
    color: #ffffff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.ai-chat-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

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

.ai-chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===================== Message Content Formatting ===================== */
.ai-msg.bot .ai-msg-bubble strong {
    color: #1d4ed8;
    font-weight: 700;
}

.ai-msg.bot .ai-msg-bubble em {
    color: #475569;
}

.ai-msg.bot .ai-msg-bubble h2,
.ai-msg.bot .ai-msg-bubble h3,
.ai-msg.bot .ai-msg-bubble h4 {
    color: #1d4ed8;
    font-weight: 700;
    margin: 8px 0 4px;
}

.ai-msg.bot .ai-msg-bubble ul,
.ai-msg.bot .ai-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.ai-msg.bot .ai-msg-bubble li {
    margin-bottom: 4px;
    color: #334155;
}

.ai-msg.bot .ai-msg-bubble pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 11.5px;
    overflow-x: auto;
    margin: 8px 0;
    color: #334155;
}

/* ===================== Mobile Responsiveness ===================== */
@media (max-width: 640px) {
    .chat-toggle-pill {
        display: none !important;
    }

    #chatToggle {
        bottom: 20px !important;
        right: 20px !important;
    }

    #chatbot {
        bottom: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
}

@media (max-height: 700px) {
    #chatbot {
        height: calc(100vh - 40px) !important;
    }
}