/* IronNest AI Chat Widget */
:root {
    --ai-blue: #006cb5;
    --ai-blue-dark: #005a96;
    --ai-bg: #ffffff;
    --ai-text: #1a1a2e;
    --ai-border: #e0e6ef;
    --ai-bubble-user: #006cb5;
    --ai-bubble-bot: #f0f4f8;
    --ai-radius: 16px;
    --ai-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

/* ── Floating Button ── */
#inest-ai-bubble {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--ai-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,108,181,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    outline: none;
}
#inest-ai-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,108,181,0.55);
}
#inest-ai-bubble svg { pointer-events: none; }

#inest-ai-bubble .inest-ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 10px;
    display: none;
}
#inest-ai-bubble.inest-ai-has-badge .inest-ai-badge { display: block; }

/* ── Chat Panel ── */
#inest-ai-panel {
    position: fixed;
    bottom: 156px;
    right: 24px;
    z-index: 9999;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: var(--ai-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ai-border);
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: bottom right;
}
#inest-ai-panel.inest-ai-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(12px);
}

/* ── Panel Header ── */
.inest-ai-header {
    background: linear-gradient(135deg, var(--ai-blue) 0%, #0084d6 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.inest-ai-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.inest-ai-header-info { flex: 1; min-width: 0; }
.inest-ai-header-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}
.inest-ai-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.inest-ai-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}
.inest-ai-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}
.inest-ai-close:hover { opacity: 1; }

/* ── Messages Area ── */
.inest-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.inest-ai-messages::-webkit-scrollbar { width: 4px; }
.inest-ai-messages::-webkit-scrollbar-track { background: transparent; }
.inest-ai-messages::-webkit-scrollbar-thumb { background: #cdd6e0; border-radius: 4px; }

/* ── Message Bubbles ── */
.inest-ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: inestMsgIn 0.2s ease;
}
@keyframes inestMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.inest-ai-msg--user { flex-direction: row-reverse; }
.inest-ai-msg__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e8eff7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--ai-blue);
}
.inest-ai-msg__bubble {
    max-width: 80%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.inest-ai-msg--bot .inest-ai-msg__bubble {
    background: var(--ai-bubble-bot);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}
.inest-ai-msg--user .inest-ai-msg__bubble {
    background: var(--ai-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ── */
.inest-ai-typing .inest-ai-msg__bubble {
    padding: 12px 16px;
}
.inest-ai-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.inest-ai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #93a4b8;
    animation: inestDot 1.2s infinite;
}
.inest-ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.inest-ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes inestDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Calculator Suggestion Card ── */
.inest-ai-calc-card {
    background: #fff;
    border: 1.5px solid var(--ai-blue);
    border-radius: 10px;
    padding: 11px 13px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
}
.inest-ai-calc-card:hover {
    background: #f0f7ff;
    box-shadow: 0 2px 12px rgba(0,108,181,0.15);
}
.inest-ai-calc-card__icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #e8f1fb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--ai-blue);
}
.inest-ai-calc-card__text { flex: 1; min-width: 0; }
.inest-ai-calc-card__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inest-ai-calc-card__sub {
    font-size: 11px;
    color: #5a7a99;
    margin-top: 1px;
}
.inest-ai-calc-card__arrow {
    color: var(--ai-blue);
    flex-shrink: 0;
}

/* ── Lead Form Card ── */
.inest-ai-lead-card {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f1fb 100%);
    border: 1.5px solid var(--ai-blue);
    border-radius: 10px;
    padding: 13px;
    margin-top: 6px;
}
.inest-ai-lead-card__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ai-text);
    margin-bottom: 10px;
}
.inest-ai-lead-card input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--ai-border);
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 7px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
    background: #fff;
}
.inest-ai-lead-card input:focus { border-color: var(--ai-blue); }
.inest-ai-lead-card__btn {
    width: 100%;
    padding: 9px;
    background: var(--ai-blue);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 2px;
}
.inest-ai-lead-card__btn:hover { background: var(--ai-blue-dark); }
.inest-ai-lead-card__btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Quick Prompts ── */
.inest-ai-quick-prompts {
    padding: 0 16px 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.inest-ai-quick-btn {
    font-size: 11.5px;
    padding: 5px 10px;
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    background: #fff;
    color: var(--ai-blue);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.inest-ai-quick-btn:hover {
    background: #e8f1fb;
    border-color: var(--ai-blue);
}

/* ── Input Area ── */
.inest-ai-input-area {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--ai-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fafbfc;
}
.inest-ai-input {
    flex: 1;
    border: 1.5px solid var(--ai-border);
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 13.5px;
    line-height: 1.4;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    background: #fff;
    transition: border-color 0.15s;
    font-family: inherit;
}
.inest-ai-input:focus { border-color: var(--ai-blue); }
.inest-ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ai-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}
.inest-ai-send-btn:hover { background: var(--ai-blue-dark); transform: scale(1.05); }
.inest-ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Disclaimer ── */
.inest-ai-disclaimer {
    text-align: center;
    font-size: 10px;
    color: #8a9ab5;
    padding: 0 14px 8px;
    flex-shrink: 0;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    /* Bubble moves to RIGHT side; sticky CTA is on LEFT (bottom: 80px right: 20px)
       so they don't collide */
    #inest-ai-bubble {
        right: 20px;
        bottom: 16px;
    }
    #inest-ai-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 80px;
        max-height: calc(100vh - 100px);
    }
}

@media (max-width: 480px) {
    /* Full-screen chat on small phones */
    #inest-ai-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        z-index: 9999;
        bottom: 0;
    }
    #inest-ai-bubble {
        right: 16px;
        bottom: 16px;
    }
}
