/* ============================================
   PRAT-IL Chatbot Widget
   ============================================ */

/* Floating Button */
#pratil-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, #00d285, #00b872);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 210, 133, 0.45), 0 2px 8px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s ease;
    animation: chatPulse 3s ease-in-out infinite;
}

#pratil-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 210, 133, 0.6), 0 4px 12px rgba(0,0,0,0.2);
    animation: none;
}

#pratil-chat-btn > svg {
    width: 28px;
    height: 28px;
    fill: #1e293b;
    transition: transform 0.3s ease;
}

#pratil-chat-btn.open .chat-btn-avatar { display: none; }
#pratil-chat-btn.open svg.icon-close { display: block !important; }
#pratil-chat-btn svg.icon-close { display: none; }

.chat-btn-avatar,
.chatbot-header-avatar,
.msg-avatar,
.chatbot-legal-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-btn-avatar {
    width: 46px;
    height: 46px;
}

.bot-avatar-svg {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 210, 133, 0.45), 0 2px 8px rgba(0,0,0,0.18); }
    50% { box-shadow: 0 8px 40px rgba(0, 210, 133, 0.7), 0 0 0 10px rgba(0,210,133,0.08); }
}

/* Notification badge */
#pratil-chat-btn .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 0.65rem;
    font-weight: 900;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Heebo', sans-serif;
}

/* Chat Window */
#pratil-chat-window {
    position: fixed;
    bottom: 106px;
    right: 28px;
    width: 390px;
    height: 580px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(15,23,42,0.22), 0 4px 16px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    border: 1px solid rgba(0,210,133,0.15);
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
    font-family: 'Heebo', sans-serif;
    direction: rtl;
}

#pratil-chat-window.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    position: relative;
}

.chatbot-header-avatar {
    width: 44px;
    height: 44px;
    background: transparent;
    border-radius: 50%;
    flex-shrink: 0;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-name {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}

.chatbot-header-status {
    font-size: 0.78rem;
    color: #00d285;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #00d285;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chatbot-header-close {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    margin-right: auto;
}

.chatbot-header-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Category pills */
.chatbot-categories {
    padding: 10px 16px 6px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-shrink: 0;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    scrollbar-width: none;
}

.chatbot-categories::-webkit-scrollbar { display: none; }

.cat-pill {
    padding: 5px 12px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: 'Heebo', sans-serif;
    flex-shrink: 0;
}

.cat-pill:hover, .cat-pill.active {
    background: #00d285;
    border-color: #00d285;
    color: #1e293b;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Message bubbles */
.msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
    animation: msgIn 0.25s ease;
}

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

.msg.bot { align-self: flex-end; }
.msg.user { align-self: flex-start; flex-direction: row-reverse; }

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
}

.msg-bubble {
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.55;
    max-width: 100%;
}

.msg.bot .msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-right-radius: 6px;
}

.msg.user .msg-bubble {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #ffffff;
    border-bottom-left-radius: 6px;
}

.msg-bubble strong {
    color: #00b872;
    font-weight: 800;
}

.msg.user .msg-bubble strong { color: #00d285; }

.msg-bubble .example {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0,210,133,0.1);
    border-right: 3px solid #00d285;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #1e293b;
}

/* Quick reply chips */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
    animation: msgIn 0.3s ease;
    align-self: flex-end;
    max-width: 92%;
    justify-content: flex-end;
}

.qr-chip {
    padding: 6px 12px;
    background: #fff;
    border: 1.5px solid #00d285;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    font-family: 'Heebo', sans-serif;
    transition: all 0.2s;
    white-space: nowrap;
}

.qr-chip:hover {
    background: #00d285;
    color: #1e293b;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 18px;
    border-bottom-right-radius: 6px;
    width: fit-content;
}

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

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

.chatbot-input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    font-size: 0.875rem;
    font-family: 'Heebo', sans-serif;
    direction: rtl;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.2s;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
}

.chatbot-input:focus {
    border-color: #00d285;
    background: #fff;
}

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

.chatbot-send {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #00d285, #00b872);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0,210,133,0.4);
}

.chatbot-send:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #1e293b;
}

/* Footer note */
.chatbot-footer-note {
    text-align: center;
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 6px 14px 10px;
    background: #fff;
}

/* Legal pre-chat card */
.chatbot-legal-card {
    align-self: stretch;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 18px;
    color: #1e293b;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.chatbot-legal-avatar {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
}

.chatbot-legal-card h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 900;
    color: #0f172a;
    text-align: center;
    line-height: 1.35;
}

.chatbot-legal-card p {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.7;
    color: #334155;
}

.chatbot-legal-accept {
    width: 100%;
    margin-top: 16px;
    padding: 11px 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #00d285, #00b872);
    color: #0f172a;
    font-family: 'Heebo', sans-serif;
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-legal-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 210, 133, 0.24);
}

/* Feedback row */
.msg-feedback {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #94a3b8;
}

.msg-feedback button {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.72rem;
    font-family: 'Heebo', sans-serif;
    color: #64748b;
    transition: all 0.2s;
}

.msg-feedback button:hover { background: #f1f5f9; border-color: #00d285; }

/* Responsive */
@media (max-width: 480px) {
    #pratil-chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 96px;
        height: calc(100dvh - 120px);
        border-radius: 20px;
    }

    #pratil-chat-btn {
        right: 18px;
        bottom: 18px;
    }
}
