/* ============================================================================
   CHATBOT WIDGET — HubEurope Tracking Assistant
   Matches the paperwhite design system from tracking-styles.css
   ============================================================================ */

/* Floating chat trigger button */
.chatbot-trigger {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--color-orange, #FF4400);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 68, 0, 0.3);
    transition: all 0.2s ease;
    z-index: 1001;
    border: none;
    outline: none;
}

.chatbot-trigger:hover {
    background: var(--color-orange-light, #FF6A26);
    transform: scale(1.05);
}

/* Speech bubble icon */
.chatbot-trigger .icon-chat {
    width: 28px;
    height: 28px;
}

.chatbot-trigger .chat-dot {
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.chatbot-trigger .dot-2 {
    animation-delay: 0.15s;
}

.chatbot-trigger .dot-3 {
    animation-delay: 0.3s;
}

@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 1; }
    30% { transform: translateY(-3px); opacity: 0.6; }
}

/* Hide speech bubble when open, show close icon */
.chatbot-trigger.open .icon-chat {
    display: none;
}

.chatbot-trigger.open svg.icon-close {
    display: block;
}

.chatbot-trigger:not(.open) svg.icon-close {
    display: none;
}

.chatbot-trigger svg.icon-close {
    width: 24px;
    height: 24px;
    fill: none;
}

/* Unread indicator */
.chatbot-trigger .unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #34A853;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
}

.chatbot-trigger.has-unread .unread-dot {
    display: block;
    animation: pulse-dot 2s infinite;
}

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

/* Chat panel */
.chatbot-panel {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 380px;
    max-height: 520px;
    background: var(--color-paperwhite, #FEFEFE);
    border: 1px solid var(--color-border, #E8E8E8);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 1002;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s ease-out;
}

.chatbot-panel.visible {
    display: flex;
}

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

/* Panel header */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--color-orange, #FF4400);
    color: white;
    flex-shrink: 0;
}

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

.chatbot-header-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.chatbot-header-text h3 {
    margin: 0;
    font-family: var(--e-global-typography-primary-font-family, 'MuseoModerno'), sans-serif;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.chatbot-header-text p {
    margin: 2px 0 0 0;
    font-family: var(--e-global-typography-text-font-family, 'Open Sans'), sans-serif;
    font-size: 11px;
    opacity: 0.85;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 320px;
}

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

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

/* Message bubbles */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: var(--e-global-typography-text-font-family, 'Open Sans'), sans-serif;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: #F3F4F6;
    color: var(--color-text, #000);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--color-orange, #FF4400);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Markdown rendering in assistant messages */
.chat-msg.assistant strong {
    font-weight: 700;
}

.chat-msg.assistant a {
    color: var(--color-orange, #FF4400);
    text-decoration: underline;
}

.chat-msg.assistant code {
    background: #E5E7EB;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

/* Typing indicator */
.chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: #F3F4F6;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: typing-bounce 1.2s ease-in-out infinite;
}

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

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

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

/* Starter prompts */
.chatbot-starters {
    padding: 0 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.starter-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--color-border, #E8E8E8);
    border-radius: 16px;
    font-family: var(--e-global-typography-text-font-family, 'Open Sans'), sans-serif;
    font-size: 12px;
    color: var(--color-text-secondary, #404040);
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.3;
}

.starter-btn:hover {
    background: var(--color-orange, #FF4400);
    color: white;
    border-color: var(--color-orange, #FF4400);
}

/* Input area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border, #E8E8E8);
    background: white;
    flex-shrink: 0;
}

.chatbot-input-area input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border, #E8E8E8);
    border-radius: 20px;
    font-family: var(--e-global-typography-text-font-family, 'Open Sans'), sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

.chatbot-input-area input:focus {
    border-color: var(--color-orange, #FF4400);
}

.chatbot-input-area input::placeholder {
    color: #9CA3AF;
}

.chatbot-send-btn {
    width: 34px;
    height: 34px;
    background: var(--color-orange, #FF4400);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    background: var(--color-orange-light, #FF6A26);
}

.chatbot-send-btn:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Error state */
.chat-error {
    align-self: center;
    padding: 8px 14px;
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
}

/* Powered-by footer */
.chatbot-footer {
    text-align: center;
    padding: 4px 14px 8px;
    font-size: 10px;
    color: #9CA3AF;
    font-family: var(--e-global-typography-text-font-family, 'Open Sans'), sans-serif;
}

/* ============================================================================
   RESPONSIVE — MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .chatbot-trigger {
        bottom: 72px;
        right: 15px;
        width: 45px;
        height: 45px;
    }

    .chatbot-trigger svg {
        width: 20px;
        height: 20px;
    }

    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 75vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }

    .chatbot-messages {
        max-height: calc(75vh - 180px);
    }
}

/* ============================================================================
   PRINT — HIDE CHATBOT
   ============================================================================ */

@media print {
    .chatbot-trigger,
    .chatbot-panel {
        display: none !important;
    }
}
