/* =====================================================
   Topa Chatbot — floating widget (RTL)
   ===================================================== */

.topa-chatbot {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 999999;
    font-family: 'RB', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    direction: rtl;
    text-align: right;
}

/* More specific selector to override Elementor reset */
#topa-chatbot > .topa-chatbot-toggle,
#topa-chatbot .topa-chatbot-toggle[type="button"] {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 60px !important;
    height: 60px !important;
    border: none !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #F26522, #B37D35) !important;
    color: #fff !important;
    box-shadow: 0 6px 20px rgba(179, 125, 53, 0.4) !important;
    cursor: pointer !important;
    outline: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-align: center !important;
    vertical-align: middle !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

#topa-chatbot .topa-chatbot-toggle:hover,
#topa-chatbot .topa-chatbot-toggle:focus {
    transform: scale(1.08) !important;
    box-shadow: 0 10px 30px rgba(242, 101, 34, 0.55) !important;
}

.topa-chatbot-pulse {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(242, 101, 34, 0.35);
    animation: topa-chatbot-pulse 2s infinite;
    z-index: -1;
}

@keyframes topa-chatbot-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    70% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

#topa-chatbot .topa-chatbot-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 54px !important;
    height: 54px !important;
    border-radius: 50% !important;
    background: #fff !important;
    color: #F26522 !important;
    font-size: 26px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    overflow: hidden !important;
}

#topa-chatbot .topa-chatbot-toggle i {
    font-size: 26px !important;
    line-height: 1 !important;
    color: #F26522 !important;
}

.topa-chatbot-panel {
    position: absolute;
    left: 0;
    bottom: 70px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.topa-chatbot-panel.open {
    display: flex;
}

.topa-chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #F26522, #B37D35);
    color: #fff;
}

.topa-chatbot-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 20px;
    flex-shrink: 0;
}

.topa-chatbot-headinfo {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.topa-chatbot-title {
    font-weight: 800;
    font-size: 15px;
    line-height: 1.3;
}

.topa-chatbot-status {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.85;
    margin-top: 2px;
}

.topa-chatbot-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    margin-left: 5px;
    vertical-align: middle;
}

.topa-chatbot-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
}

.topa-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8f7f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.topa-chatbot-message {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    max-width: 85%;
    word-wrap: break-word;
}

.topa-chatbot-bot {
    background: #fff;
    color: #3D4041;
    border: 1px solid #E8E0D5;
    align-self: flex-start;
    border-top-right-radius: 4px;
}

/* Markdown rendering inside bot messages */
.topa-chatbot-bot h3,
.topa-chatbot-bot h4 {
    font-size: 15px;
    font-weight: 800;
    color: #1F2937;
    margin: 8px 0 4px;
    line-height: 1.3;
}

.topa-chatbot-bot h3:first-child,
.topa-chatbot-bot h4:first-child {
    margin-top: 0;
}

.topa-chatbot-bot ul {
    margin: 6px 0;
    padding-right: 18px;
    list-style: none;
}

.topa-chatbot-bot ul li {
    position: relative;
    padding-right: 12px;
    margin-bottom: 3px;
    line-height: 1.5;
}

.topa-chatbot-bot ul li::before {
    content: '';
    position: absolute;
    right: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #F26522;
}

.topa-chatbot-bot strong {
    font-weight: 800;
    color: #1F2937;
}

.topa-chatbot-bot em {
    font-style: italic;
    color: #6B7280;
}

.topa-chatbot-bot br + br {
    display: block;
    margin-top: 4px;
    content: '';
}

.topa-chatbot-user {
    background: linear-gradient(135deg, #F26522, #B37D35);
    color: #fff;
    align-self: flex-end;
    border-top-left-radius: 4px;
}

.topa-chatbot-loading {
    color: #6B7280;
    font-style: italic;
}

.topa-chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #E8E0D5;
    background: #fff;
}

.topa-chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #E8E0D5;
    border-radius: 999px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    color: #3D4041;
}

.topa-chatbot-input:focus {
    border-color: #B37D35;
}

.topa-chatbot-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #F26522, #B37D35);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topa-chatbot-send:hover,
.topa-chatbot-send:focus {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(242, 101, 34, 0.4);
    outline: none;
}

@media (max-width: 480px) {
    .topa-chatbot {
        left: 12px;
        bottom: 12px;
    }

    .topa-chatbot-panel {
        width: calc(100vw - 24px);
        bottom: 80px;
    }

    #topa-chatbot .topa-chatbot-toggle {
        width: 54px !important;
        height: 54px !important;
    }

    #topa-chatbot .topa-chatbot-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 22px !important;
    }

    #topa-chatbot .topa-chatbot-toggle i {
        font-size: 22px !important;
    }
}
