/* ==========================================================================
   ICN Technology - Enterprise AI WhatsApp Chatbot Styling
   Ultra-fast, zero bloat, mobile-first responsive design
   ========================================================================== */

:root {
    --icn-wa-primary: #075E54;
    --icn-wa-teal: #128C7E;
    --icn-wa-green: #25D366;
    --icn-wa-light-green: #dcf8c6;
    --icn-wa-bg: #ece5dd;
    --icn-wa-chat-bg: #f8fafc;
    --icn-wa-dark: #071D46;
    --icn-wa-cyan: #00D2FF;
    --icn-wa-user-bubble: #e7fedb;
    --icn-wa-bot-bubble: #ffffff;
    --icn-wa-shadow: 0 12px 36px rgba(7, 29, 70, 0.22);
}

/* Floating Root Container */
.icn-chatbot-wrapper {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Proactive Teaser Speech Bubble */
.icn-chat-teaser {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 290px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(37, 211, 102, 0.2);
    border: 1px solid #e2e8f0;
    padding: 12px 14px;
    animation: icnTeaserPop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 99998;
}

.icn-chat-teaser:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.icn-chat-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 50%;
}
.icn-chat-teaser-close:hover {
    color: #ef4444;
    background: #f1f5f9;
}

.icn-chat-teaser-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icn-chat-teaser-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.35);
}

.icn-chat-teaser-text strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 2px;
}

.icn-chat-teaser-text p {
    font-size: 11.5px;
    color: #475569;
    margin: 0;
    line-height: 1.35;
}

@keyframes icnTeaserPop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Floating Trigger Button */
.icn-chat-trigger {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: #ffffff;
    border: none;
    padding: 10px 18px 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    user-select: none;
}

.icn-chat-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6);
}

.icn-chat-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.5), 0 8px 24px rgba(37, 211, 102, 0.45);
}

.icn-chat-trigger-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    border: 2px solid rgba(37, 211, 102, 0.7);
    animation: icnWaRadar 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}

@keyframes icnWaRadar {
    0% {
        transform: scale(0.96);
        opacity: 0.9;
    }
    70% {
        transform: scale(1.18);
        opacity: 0;
    }
    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

.icn-chat-trigger-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ffffff;
    flex-shrink: 0;
}

.icn-chat-trigger-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.icn-trigger-title {
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: -0.2px;
}

.icn-trigger-status {
    font-size: 10.5px;
    font-weight: 600;
    color: #dcfce7;
    display: flex;
    align-items: center;
    gap: 4px;
}

.icn-online-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.icn-chat-badge {
    position: absolute;
    top: -5px;
    right: -3px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: icnBadgeBounce 2s ease infinite;
}

@keyframes icnBadgeBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
    60% { transform: translateY(-2px); }
}

/* Chatbot Main Panel */
.icn-chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 375px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--icn-wa-shadow);
    border: 1px solid rgba(226, 232, 240, 0.85);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: icnPanelSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    z-index: 99999;
}

@keyframes icnPanelSlide {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.icn-chat-header {
    background: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.icn-chat-header-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    padding: 3px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icn-chat-header-avatar img {
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.icn-avatar-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #25D366;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.icn-chat-header-info {
    flex: 1;
    min-width: 0;
}

.icn-header-name-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.icn-chat-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icn-verified-badge {
    color: #4ade80;
    font-size: 14px;
    display: inline-flex;
}

.icn-chat-header-status {
    font-size: 11px;
    color: #dcfce7;
    opacity: 0.9;
    display: block;
    margin-top: 1px;
}

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

.icn-chat-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.icn-chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

/* Chat Body */
.icn-chat-body {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
    background-color: #efeae2;
    background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.icn-chat-notice {
    align-self: center;
    background: rgba(255, 255, 255, 0.85);
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: center;
    margin-bottom: 4px;
}
.icn-chat-notice i {
    color: #128C7E;
}

/* Chat Bubbles */
.icn-msg {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
    animation: icnMsgFade 0.25s ease-out forwards;
}

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

.icn-msg-bot {
    align-self: flex-start;
    background: var(--icn-wa-bot-bubble);
    color: #1e293b;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.icn-msg-user {
    align-self: flex-end;
    background: var(--icn-wa-user-bubble);
    color: #0f172a;
    border-top-right-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.icn-msg-content p {
    margin: 0 0 6px 0;
}
.icn-msg-content p:last-child {
    margin-bottom: 0;
}

.icn-msg-content strong {
    color: #071D46;
}

.icn-msg-content ul {
    margin: 6px 0;
    padding-left: 18px;
}
.icn-msg-content li {
    margin-bottom: 3px;
}

.icn-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
}

.icn-msg-user .icn-msg-meta {
    color: #64748b;
}

.icn-msg-ticks {
    color: #38bdf8;
    font-size: 11px;
}

/* In-message actions */
.icn-msg-action-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #128C7E;
    color: #ffffff !important;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 8px;
    text-decoration: none;
    transition: background 0.2s ease;
}
.icn-msg-action-link:hover {
    background: #075E54;
    color: #ffffff !important;
}

/* Typing Indicator */
.icn-chat-typing {
    padding: 0 14px 8px 14px;
    background: #efeae2;
}

.icn-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    padding: 8px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.icn-typing-avatar {
    color: #128C7E;
    font-size: 13px;
    margin-right: 4px;
}

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

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

.icn-typing-text {
    font-size: 11px;
    color: #64748b;
    margin-left: 6px;
}

@keyframes icnDotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; background: #128C7E; }
}

/* Suggestion Chips */
.icn-chat-chips {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}

.icn-chat-chips::-webkit-scrollbar {
    display: none;
}

.icn-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.icn-chip-btn:hover {
    background: #f0fdf4;
    border-color: #25D366;
    color: #075E54;
    transform: translateY(-1px);
}

/* Direct WhatsApp Transfer Bar */
.icn-chat-direct-wa {
    background: #f8fafc;
    padding: 6px 12px;
    border-top: 1px solid #eef2f6;
    flex-shrink: 0;
}

.icn-direct-wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: #25D366;
    color: #ffffff !important;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.35);
    transition: all 0.2s ease;
}

.icn-direct-wa-btn:hover {
    background: #1eb956;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.45);
}

/* Chat Input Bar */
.icn-chat-input-bar {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icn-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
}

.icn-chat-input:focus {
    border-color: #128C7E;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.15);
}

.icn-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #128C7E, #075E54);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.icn-chat-send:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, #25D366, #128C7E);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .icn-chatbot-wrapper {
        bottom: 16px;
        right: 14px;
    }

    .icn-chat-panel {
        bottom: 60px;
        right: 0;
        width: calc(100vw - 28px);
        height: min(540px, calc(100vh - 90px));
        border-radius: 18px;
    }

    .icn-chat-teaser {
        width: calc(100vw - 40px);
        right: 0;
        bottom: 60px;
    }

    .icn-chat-trigger {
        padding: 9px 14px 9px 12px;
    }

    .icn-trigger-title {
        font-size: 12.5px;
    }

    .icn-chat-trigger-icon {
        width: 28px;
        height: 28px;
        font-size: 17px;
    }
}

/* Accessibility / Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .icn-chat-trigger-pulse,
    .icn-chat-badge,
    .icn-dot {
        animation: none !important;
    }
    .icn-chat-panel,
    .icn-chat-teaser,
    .icn-msg {
        animation: none !important;
    }
}
