/* =========================================================================
 * Rolofin Chatbot — CSS interamente confinato (namespaced).
 * Ogni regola è ancorata a .rolofin-chatbot-widget / .rolofin-launcher /
 * .rolofin-chatbot-trigger-card così da NON toccare il resto del sito.
 * ========================================================================= */

/* ===== Widget root ===== */
.rolofin-chatbot-widget {
    position: fixed;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 110px);
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(27, 42, 74, 0.25);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.rolofin-chatbot-widget.open { display: flex; }
.rolofin-chatbot-widget * { box-sizing: border-box; }

.rolofin-chatbot-widget.rolofin-dock-bottom-left  { bottom: 96px; left: 20px;  right: auto; top: auto; }
.rolofin-chatbot-widget.rolofin-dock-bottom-right { bottom: 96px; right: 20px; left: auto;  top: auto; }
.rolofin-chatbot-widget.rolofin-dock-top-left     { top: 96px;    left: 20px;  right: auto; bottom: auto; }
.rolofin-chatbot-widget.rolofin-dock-top-right    { top: 96px;    right: 20px; left: auto;  bottom: auto; }

.rolofin-chatbot-widget.rolofin-expanded {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%);
    width: min(680px, 94vw);
    height: min(800px, 88vh);
    max-height: 88vh;
}

/* ===== Header ===== */
.rolofin-chatbot-widget .rolofin-chatbot-header {
    background: linear-gradient(135deg, #1B2A4A 0%, #00A6CD 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 11px;
    border-top-right-radius: 11px;
    flex-shrink: 0;
    min-height: 50px;
}
.rolofin-chatbot-widget .rolofin-chatbot-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; }
.rolofin-chatbot-widget .rolofin-header-actions { display: flex; align-items: center; gap: 10px; }
.rolofin-chatbot-widget .rolofin-header-actions button {
    background: transparent; border: none; color: #fff;
    font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 4px; transition: transform 0.2s;
}
.rolofin-chatbot-widget .rolofin-header-actions button:hover { transform: scale(1.15); }

/* ===== Body / messaggi ===== */
.rolofin-chatbot-widget .rolofin-chatbot-body {
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    background-color: #f9f9f9; padding: 15px;
    scrollbar-color: #00A6CD #f1f1f1; scrollbar-width: thin;
}
.rolofin-chatbot-widget .chat-messages { display: flex; flex-direction: column; gap: 10px; }

.rolofin-chatbot-widget .message { display: flex; animation: rolofinFadeIn 0.3s ease-in; }
@keyframes rolofinFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.rolofin-chatbot-widget .user-message { justify-content: flex-end; }
.rolofin-chatbot-widget .user-message p {
    background-color: #00A6CD; color: #fff;
    padding: 10px 12px; border-radius: 12px; border-bottom-right-radius: 4px;
    max-width: 85%; word-wrap: break-word; margin: 0; font-size: 14px; line-height: 1.4;
}
.rolofin-chatbot-widget .assistant-message { justify-content: flex-start; }
.rolofin-chatbot-widget .assistant-message p {
    background-color: #e8e8e8; color: #1B2A4A;
    padding: 10px 12px; border-radius: 12px; border-bottom-left-radius: 4px;
    max-width: 85%; word-wrap: break-word; margin: 0; font-size: 14px; line-height: 1.4;
}
.rolofin-chatbot-widget .assistant-message a { color: #00A6CD; text-decoration: none; font-weight: 600; }
.rolofin-chatbot-widget .assistant-message a:hover { text-decoration: underline; }

.rolofin-chatbot-widget .typing-indicator { color: #999; font-size: 12px; font-style: italic; padding: 5px 0; margin-top: 10px; }

/* ===== Footer ===== */
.rolofin-chatbot-widget .rolofin-chatbot-footer {
    border-top: 1px solid #e0e0e0; padding: 12px;
    display: flex; gap: 8px; background-color: #fff;
    border-bottom-left-radius: 11px; border-bottom-right-radius: 11px;
    flex-shrink: 0; min-height: 50px;
}
.rolofin-chatbot-widget .rolofin-chatbot-footer input {
    flex: 1; border: 1px solid #d0d0d0; padding: 8px 12px;
    border-radius: 6px; font-size: 13px; outline: none; transition: border-color 0.2s;
    margin: 0; min-height: 0; box-shadow: none;
}
.rolofin-chatbot-widget .rolofin-chatbot-footer input:focus { border-color: #00A6CD; }
.rolofin-chatbot-widget .rolofin-chatbot-footer button {
    border: none; padding: 8px 12px; border-radius: 6px;
    cursor: pointer; font-size: 16px; transition: all 0.2s; flex-shrink: 0;
    width: auto; min-height: 0;
}
.rolofin-chatbot-widget .send-button { background-color: #00A6CD; color: #fff; font-weight: 600; }
.rolofin-chatbot-widget .send-button:hover { background-color: #0088a8; box-shadow: 0 2px 8px rgba(0, 166, 205, 0.3); }
.rolofin-chatbot-widget .voice-button { background-color: #1B2A4A; color: #fff; }
.rolofin-chatbot-widget .voice-button:hover { background-color: #0f1620; }

/* ===== Scrollbar (webkit) ===== */
.rolofin-chatbot-widget .rolofin-chatbot-body::-webkit-scrollbar { width: 8px; }
.rolofin-chatbot-widget .rolofin-chatbot-body::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.rolofin-chatbot-widget .rolofin-chatbot-body::-webkit-scrollbar-thumb { background: #00A6CD; border-radius: 10px; }
.rolofin-chatbot-widget .rolofin-chatbot-body::-webkit-scrollbar-thumb:hover { background: #0088a8; }

/* ===== Product cards (sempre dentro al widget) ===== */
.rolofin-chatbot-widget .products-message { width: 100%; }
.rolofin-chatbot-widget .product-grid { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 100%; }
.rolofin-chatbot-widget .product-card {
    display: flex; gap: 10px; background: #fff; border: 1px solid #e0e0e0;
    border-radius: 10px; overflow: hidden; text-decoration: none; color: #1B2A4A;
    transition: box-shadow 0.2s, transform 0.2s;
}
.rolofin-chatbot-widget .product-card:hover { box-shadow: 0 3px 12px rgba(0,166,205,0.18); transform: translateY(-1px); }
.rolofin-chatbot-widget .product-img-wrap {
    width: 72px; min-width: 72px; height: 72px; background: #f0f4f8;
    display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.rolofin-chatbot-widget .product-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.rolofin-chatbot-widget .product-no-image { font-size: 24px; opacity: 0.4; }
.rolofin-chatbot-widget .product-info { flex: 1; padding: 8px 10px 8px 0; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.rolofin-chatbot-widget .product-name {
    font-size: 12px; font-weight: 700; color: #1B2A4A; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rolofin-chatbot-widget .product-desc {
    font-size: 11px; color: #666; margin: 3px 0 0; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rolofin-chatbot-widget .product-pricing { margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rolofin-chatbot-widget .product-sale-price { font-size: 13px; font-weight: 700; color: #e53e3e; }
.rolofin-chatbot-widget .product-regular-price { font-size: 13px; font-weight: 600; color: #1B2A4A; }
.rolofin-chatbot-widget .product-regular-price.strikethrough { font-size: 11px; font-weight: 400; color: #999; text-decoration: line-through; }

/* ===== Trigger card inline (shortcode [rolofin_chatbot]) ===== */
.rolofin-chatbot-trigger-card {
    background: linear-gradient(135deg, #1B2A4A 0%, #2a3f5f 100%);
    color: #fff; padding: 30px 20px; border-radius: 10px;
    text-align: center; cursor: pointer; max-width: 280px; margin: 20px auto;
    box-shadow: 0 4px 12px rgba(27, 42, 74, 0.2); transition: all 0.3s ease;
    border: none; font-family: inherit;
}
.rolofin-chatbot-trigger-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(27, 42, 74, 0.3); }
.rolofin-chatbot-trigger-card h3 { color: #00A6CD; margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.rolofin-chatbot-trigger-card p { margin: 0; font-size: 14px; line-height: 1.5; opacity: 0.95; }

/* ===== Launcher flottante (FAB) ===== */
.rolofin-launcher { position: fixed; z-index: 99998; display: flex; align-items: center; gap: 12px; }
.rolofin-launcher * { box-sizing: border-box; }
.rolofin-launcher.rolofin-corner-bottom-left  { bottom: 22px; left: 22px;  flex-direction: row; }
.rolofin-launcher.rolofin-corner-bottom-right { bottom: 22px; right: 22px; flex-direction: row-reverse; }
.rolofin-launcher.rolofin-corner-top-left     { top: 22px;    left: 22px;  flex-direction: row; }
.rolofin-launcher.rolofin-corner-top-right    { top: 22px;    right: 22px; flex-direction: row-reverse; }

.rolofin-launcher .rolofin-launcher-btn {
    position: relative; width: 60px; height: 60px; min-width: 60px; border-radius: 50%;
    border: none; cursor: pointer; padding: 0; margin: 0;
    background: linear-gradient(135deg, #1B2A4A 0%, #00A6CD 100%);
    box-shadow: 0 6px 18px rgba(27, 42, 74, 0.35);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s; overflow: visible;
    animation: rolofinPulse 2.4s infinite;
}
.rolofin-launcher .rolofin-launcher-btn:hover { transform: scale(1.08); }
.rolofin-launcher .rolofin-launcher-logo { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; }

@keyframes rolofinPulse {
    0%   { box-shadow: 0 6px 18px rgba(27,42,74,0.35), 0 0 0 0 rgba(0,166,205,0.45); }
    70%  { box-shadow: 0 6px 18px rgba(27,42,74,0.35), 0 0 0 14px rgba(0,166,205,0); }
    100% { box-shadow: 0 6px 18px rgba(27,42,74,0.35), 0 0 0 0 rgba(0,166,205,0); }
}

.rolofin-launcher .rolofin-launcher-dot {
    position: absolute; top: -2px; right: -2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #e53e3e; border: 2px solid #fff;
}

.rolofin-launcher .rolofin-launcher-bubble {
    position: relative; max-width: 220px;
    background: #fff; color: #1B2A4A;
    padding: 10px 28px 10px 14px; border-radius: 12px;
    box-shadow: 0 4px 16px rgba(27, 42, 74, 0.18);
    font-size: 13px; line-height: 1.35;
}
.rolofin-launcher .rolofin-launcher-bubble strong { display: block; font-size: 14px; color: #1B2A4A; }
.rolofin-launcher .rolofin-launcher-bubble span { color: #64748b; }
.rolofin-launcher .rolofin-bubble-close {
    position: absolute; top: 4px; right: 6px;
    background: transparent; border: none; cursor: pointer;
    font-size: 16px; color: #94a3b8; line-height: 1; padding: 0;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .rolofin-chatbot-widget,
    .rolofin-chatbot-widget.rolofin-expanded {
        width: 100vw; height: 100vh; max-height: 100vh;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        transform: none !important; border-radius: 0;
    }
    .rolofin-chatbot-widget .rolofin-chatbot-header { border-radius: 0; }
    .rolofin-chatbot-widget .user-message p,
    .rolofin-chatbot-widget .assistant-message p { max-width: 90%; }
    .rolofin-chatbot-trigger-card { max-width: 90%; }
    .rolofin-launcher .rolofin-launcher-bubble { display: none; }
}

/* ===== Waitlist form ===== */
.rolofin-chatbot-widget .rolofin-wl-box {
    background: #fff; border: 1px solid #e0e0e0; border-radius: 12px;
    padding: 12px; max-width: 90%;
}
.rolofin-chatbot-widget .rolofin-wl-box p { margin: 0 0 8px; font-size: 13px; color: #1B2A4A; }
.rolofin-chatbot-widget .rolofin-wl-email {
    width: 100%; border: 1px solid #d0d0d0; border-radius: 6px;
    padding: 8px 10px; font-size: 13px; outline: none; margin-bottom: 8px; box-sizing: border-box;
}
.rolofin-chatbot-widget .rolofin-wl-email:focus { border-color: #00A6CD; }
.rolofin-chatbot-widget .rolofin-wl-actions { display: flex; gap: 8px; }
.rolofin-chatbot-widget .rolofin-wl-submit {
    flex: 1; border: none; background: #00A6CD; color: #fff; font-weight: 600;
    padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.rolofin-chatbot-widget .rolofin-wl-submit:hover { background: #0088a8; }
.rolofin-chatbot-widget .rolofin-wl-cancel {
    border: 1px solid #d0d0d0; background: #fff; color: #64748b;
    padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.rolofin-chatbot-widget .rolofin-wl-cancel:hover { background: #f1f5f9; }
