/* Faratek Chatbot — always loaded, does not depend on Vite build */
[x-cloak] {
    display: none !important;
}

#faratek-chatbot {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 2147483647 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: none;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#faratek-chatbot > * {
    pointer-events: auto;
}

/* ── FAB (chat widget launcher) ─────────────────────── */
#faratek-chatbot-fab,
.faratek-chatbot-fab,
.chatbot-fab {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 64px !important;
    height: 64px !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #fff !important;
    cursor: pointer !important;
    box-shadow: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    padding: 0 !important;
    transition: transform 0.2s ease;
}

.chatbot-fab-widget {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 18px 18px 18px 5px;
    background: linear-gradient(145deg, var(--chat-primary, #2563eb), var(--chat-accent, #0ea5e9));
    box-shadow:
        0 8px 28px rgba(37, 99, 235, 0.42),
        0 2px 8px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-fab-widget::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 10px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--chat-accent, #0ea5e9), var(--chat-primary, #2563eb));
    transform: rotate(45deg);
    border-radius: 0 0 3px 0;
    box-shadow: 2px 2px 4px rgba(37, 99, 235, 0.2);
}

.chatbot-fab-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: #fff;
    padding: 4px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
    overflow: hidden;
}

.chatbot-fab-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.chatbot-fab-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 18px;
    font-weight: 700;
    color: var(--chat-primary, #2563eb);
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    border-radius: 8px;
}

.chatbot-fab-online {
    position: absolute;
    top: -1px;
    right: -1px;
    z-index: 2;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.chatbot-fab-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary, #2563eb), var(--chat-accent, #0ea5e9));
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45);
    line-height: 1;
}

#faratek-chatbot-fab:hover,
.faratek-chatbot-fab:hover,
.chatbot-fab:hover {
    transform: scale(1.05);
}

#faratek-chatbot-fab:hover .chatbot-fab-widget,
.chatbot-fab:hover .chatbot-fab-widget {
    box-shadow:
        0 10px 32px rgba(37, 99, 235, 0.5),
        0 3px 10px rgba(15, 23, 42, 0.14);
}

/* ── Window ──────────────────────────────────────────── */
.chatbot-window {
    width: min(380px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 8rem));
    display: none;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06) !important;
    border: none !important;
}

.chatbot-window.is-open {
    display: flex !important;
    flex-direction: column;
}

.chatbot-light {
    background: #fff;
    color: #1f2937;
}

/* ── Header ─────────────────────────────────────────── */
.chatbot-header {
    background: linear-gradient(135deg, var(--chat-primary, #2563eb), var(--chat-accent, #0ea5e9));
    color: #fff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chatbot-header-text {
    min-width: 0;
}

.chatbot-header-name {
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.chatbot-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    margin: 2px 0 0;
    opacity: 0.9;
    line-height: 1;
}

.chatbot-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
    flex-shrink: 0;
}

.chatbot-status-dot.is-typing {
    background: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
    animation: chatbot-pulse 1.2s ease-in-out infinite;
}

.chatbot-status-dot.is-live {
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

.chatbot-status-dot.is-waiting {
    background: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
    animation: chatbot-pulse 1.2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-header-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.chatbot-header-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.chatbot-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
    opacity: 0.85;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    opacity: 1;
}

/* ── Messages area ─────────────────────────────────── */
.chatbot-messages {
    flex: 1 1 auto;
    min-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px;
    background: #eceff1;
    background-image: radial-gradient(circle at 20% 80%, rgba(37, 99, 235, 0.04) 0%, transparent 50%),
                      radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.04) 0%, transparent 50%);
    scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 99px;
}

/* ── Message rows ───────────────────────────────────── */
.chatbot-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 3px;
}

.chatbot-msg-row-user {
    justify-content: flex-end;
}

.chatbot-msg-row-bot {
    justify-content: flex-start;
}

.chatbot-msg-row-system {
    justify-content: center;
    margin: 6px 0;
}

.chatbot-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    margin-bottom: 1px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.chatbot-msg-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--chat-primary, #2563eb), var(--chat-accent, #0ea5e9));
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-bottom: 1px;
}

/* ── Bubbles ────────────────────────────────────────── */
.chatbot-bubble {
    position: relative;
    max-width: 72%;
    padding: 6px 10px 5px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.35;
    word-break: break-word;
    box-sizing: border-box;
}

.chatbot-bubble-text {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.35 !important;
    font-size: inherit !important;
}

.chatbot-bubble-text p,
.chatbot-bubble-text div,
.chatbot-bubble-text br + br {
    margin: 0 !important;
    padding: 0 !important;
}

.chatbot-bubble-user {
    background: linear-gradient(135deg, var(--chat-primary, #2563eb), color-mix(in srgb, var(--chat-primary, #2563eb) 80%, var(--chat-accent, #0ea5e9)));
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.chatbot-bubble-bot {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chatbot-bubble-agent {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #78350f;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.2);
    border: 1px solid #fcd34d;
}

.chatbot-bubble-agent .chatbot-bubble-time {
    color: #92400e;
    opacity: 0.65;
}

.chatbot-bubble-system {
    display: inline-block;
    max-width: 90%;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    color: #64748b;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
}

.chatbot-bubble-time {
    display: block;
    font-size: 10px;
    line-height: 1;
    margin-top: 3px;
    text-align: right;
    opacity: 0.55;
    user-select: none;
}

.chatbot-bubble-user .chatbot-bubble-time {
    color: rgba(255, 255, 255, 0.85);
    opacity: 0.7;
}

.chatbot-bubble-bot .chatbot-bubble-time {
    color: #94a3b8;
}

.chatbot-bubble-welcome {
    max-width: 85%;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 8px 12px;
    font-size: 13.5px;
    line-height: 1.4;
    color: #334155;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ── Typing indicator ───────────────────────────────── */
.chatbot-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

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

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

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

/* ── Quick replies ──────────────────────────────────── */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid #e8ecf0;
    background: #f8fafc;
    flex-shrink: 0;
}

.chatbot-quick-reply {
    border: 1px solid color-mix(in srgb, var(--chat-primary, #2563eb) 30%, #e5e7eb);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    background: #fff;
    color: var(--chat-primary, #2563eb);
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chatbot-quick-reply:hover {
    background: color-mix(in srgb, var(--chat-primary, #2563eb) 8%, #fff);
    border-color: var(--chat-primary, #2563eb);
}

/* ── Composer ───────────────────────────────────────── */
.chatbot-composer {
    padding: 10px 12px 12px;
    border-top: 1px solid #e8ecf0;
    background: #fff;
    flex-shrink: 0;
}

.chatbot-composer-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    resize: none;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 9px 14px;
    font-size: 13.5px;
    line-height: 1.35;
    background: #f8fafc;
    color: #1e293b;
    font-family: inherit;
    max-height: 100px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.chatbot-input:focus {
    border-color: color-mix(in srgb, var(--chat-primary, #2563eb) 50%, #e2e8f0);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-primary, #2563eb) 12%, transparent);
    background: #fff;
}

.chatbot-input::placeholder {
    color: #94a3b8;
}

.chatbot-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--chat-primary, #2563eb), var(--chat-accent, #0ea5e9));
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

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

/* ── Dark mode (future) ─────────────────────────────── */
.chatbot-dark {
    background: #1e293b;
    color: #f1f5f9;
}

.chatbot-dark .chatbot-messages {
    background: #0f172a;
}

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 640px) {
    #faratek-chatbot {
        bottom: 16px !important;
        right: 16px !important;
    }

    .chatbot-window.is-open {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0 !important;
    }

    .chatbot-bubble {
        max-width: 82%;
    }
}
