/* InfoVera V2 — Frontend Widget v2.0 */

/* ═══ Reset & Container ═══ */
.iv2-chatbot {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.iv2-chatbot * {
    box-sizing: border-box;
}

/* ═══ Position ═══ */
.iv2-chatbot[data-position="bottom-right"] {
    bottom: 24px;
    right: 24px;
}

.iv2-chatbot[data-position="bottom-left"] {
    bottom: 24px;
    left: 24px;
}

/* ═══ Welcome Caption ═══ */
.iv2-caption {
    position: absolute;
    bottom: 68px;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px 32px 10px 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    animation: iv2FadeIn 0.4s ease 2s both;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.iv2-chatbot[data-position="bottom-left"] .iv2-caption {
    right: auto;
    left: 0;
}

.iv2-caption-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.iv2-caption-close:hover {
    color: #333;
}

.iv2-caption.iv2-hidden {
    display: none !important;
}

/* ═══ Toggle Button (Launcher) ═══ */
/* Launcher sizes — controlled independently from chat window */
.iv2-toggle.iv2-launcher-small  { width: 44px; height: 44px; }
.iv2-toggle.iv2-launcher-small svg { width: 20px; height: 20px; }
.iv2-toggle.iv2-launcher-medium { width: 56px; height: 56px; }
.iv2-toggle.iv2-launcher-medium svg { width: 24px; height: 24px; }
.iv2-toggle.iv2-launcher-large  { width: 68px; height: 68px; }
.iv2-toggle.iv2-launcher-large svg  { width: 30px; height: 30px; }

.iv2-toggle {
    width: 56px;
    height: 56px;
    background: var(--iv2-primary, #1a1a2e);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
    padding: 0;
}

.iv2-toggle[data-shape="circle"]  { border-radius: 50%; }
.iv2-toggle[data-shape="rounded"] { border-radius: 14px; }
.iv2-toggle[data-shape="square"]  { border-radius: 6px; }

.iv2-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(0,0,0,0.22);
}

.iv2-toggle:active {
    transform: scale(0.96);
}

.iv2-toggle.iv2-hidden {
    display: none !important;
}

/* ═══ Avatar Launcher ═══ */
.iv2-toggle.iv2-toggle-avatar {
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: 3px solid var(--iv2-primary, #1a1a2e);
}

.iv2-toggle.iv2-toggle-avatar:hover {
    border-color: var(--iv2-accent, #4ade80);
}

.iv2-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.iv2-toggle.iv2-toggle-avatar::after {
    /* Disable pulse animation for avatar */
    display: none;
}

/* Subtle pulse on idle */
.iv2-toggle::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(74,222,128,0.3);
    animation: iv2Pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes iv2Pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
    50% { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
    25% { box-shadow: 0 0 0 3px rgba(74,222,128,0.15); }
}

/* ═══ Chat Window ═══ */
.iv2-window {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
    animation: iv2SlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Window size is set via inline styles from backend (iv2_window_width / iv2_window_height) */

.iv2-hidden {
    display: none !important;
}

@keyframes iv2SlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ═══ Header ═══ */
.iv2-header {
    background: var(--iv2-primary, #1a1a2e);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.iv2-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.iv2-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--iv2-accent, #4ade80);
    animation: iv2DotPulse 2s ease-in-out infinite;
}

@keyframes iv2DotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.iv2-header-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.iv2-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.iv2-header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
}

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

/* ═══ Chat Body ═══ */
.iv2-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f8fa;
    scroll-behavior: smooth;
}

.iv2-body::-webkit-scrollbar {
    width: 4px;
}

.iv2-body::-webkit-scrollbar-track {
    background: transparent;
}

.iv2-body::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 4px;
}

/* ═══ Messages ═══ */
.iv2-msg {
    max-width: 88%;
    padding: 10px 13px;
    font-size: 13px;
    line-height: 1.55;
    animation: iv2FadeIn 0.2s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.iv2-msg-bot {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px 12px 12px 3px;
    align-self: flex-start;
    color: #1a1a2e;
}

.iv2-msg-user {
    background: var(--iv2-primary, #1a1a2e);
    color: #fff;
    border-radius: 12px 12px 3px 12px;
    align-self: flex-end;
}

/* ═══ Link Buttons ═══ */
.iv2-link-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}

.iv2-link-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f4ff;
    border: 1px solid #d0daf0;
    border-radius: 8px;
    color: var(--iv2-primary, #1a1a2e);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    cursor: pointer;
}

.iv2-link-btn:hover {
    background: var(--iv2-primary, #1a1a2e);
    border-color: var(--iv2-primary, #1a1a2e);
    color: #fff;
    transform: translateX(2px);
    text-decoration: none;
}

.iv2-link-btn:active {
    transform: translateX(0);
}

.iv2-link-btn-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.iv2-link-btn:hover .iv2-link-btn-icon {
    opacity: 1;
}

/* ═══ Quick Suggestion Buttons ═══ */
.iv2-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.iv2-quick-btn {
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
    color: #1a1a2e;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.iv2-quick-btn:hover {
    background: var(--iv2-primary, #1a1a2e);
    border-color: var(--iv2-primary, #1a1a2e);
    color: #fff;
    transform: translateY(-1px);
}

/* ═══ Typing Indicator ═══ */
.iv2-typing {
    display: flex;
    gap: 4px;
    padding: 10px 13px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px 12px 12px 3px;
}

.iv2-typing span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #999;
    animation: iv2Bounce 0.6s infinite alternate;
}

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

@keyframes iv2Bounce {
    to { transform: translateY(-4px); opacity: 0.4; }
}

/* ═══ Input Row ═══ */
.iv2-input-row {
    display: flex;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
    align-items: stretch;
}

.iv2-input-row input {
    flex: 1;
    border: none;
    padding: 14px 14px;
    font-size: 13px;
    outline: none;
    background: transparent;
    font-family: inherit;
    color: #1a1a2e;
    min-width: 0;
    min-height: 46px;
}

.iv2-input-row input::placeholder {
    color: #999;
}

.iv2-input-row button {
    background: var(--iv2-primary, #1a1a2e);
    color: #fff;
    border: none;
    padding: 0 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.iv2-input-row button:hover {
    opacity: 0.85;
}

/* ═══ Mobile Responsive ═══ */
@media (max-width: 480px) {
    .iv2-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0 !important;
        z-index: 100000;
    }

    .iv2-header {
        border-radius: 0 !important;
    }

    .iv2-chatbot[data-position="bottom-right"],
    .iv2-chatbot[data-position="bottom-left"] {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .iv2-chatbot[data-position="bottom-left"] {
        left: 16px;
        right: auto;
    }

    .iv2-msg {
        max-width: 92%;
    }

    .iv2-caption {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .iv2-chatbot.iv2-mobile-hidden {
        display: none !important;
    }
}

/* ═══ Print: hide ═══ */
@media print {
    .iv2-chatbot {
        display: none !important;
    }
}
