/* Chatbot Widget Styles */

/* Trigger Button */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, #1f7b68, #215bc6);
    color: white;
    border: none;
    border-radius: 999px;
    padding: 12px 24px 12px 16px;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-trigger-icon svg {
    width: 24px;
    height: 24px;
}

.chatbot-status-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: #4ade80;
    border: 3px solid white;
    border-radius: 50%;
}

/* Chat Panel */
.chatbot-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    width: 360px; /* adjusted from 380px to appear more compact */
    max-width: calc(100vw - 48px);
    max-height: min(600px, 80vh);
    background-color: white;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
}

.chatbot-panel.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

/* Header */
.chatbot-header {
    background: linear-gradient(90deg, #1f7b68, #215bc6);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-icon {
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.15);
    border: 0.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}



.chatbot-header-icon svg {
    width: 20px;
    height: 20px;
    pointer-events: none; /* clicks pass through to the parent div */
}

.chatbot-header-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
}

.chatbot-header-subtitle {
    font-weight: 400;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.chatbot-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.chatbot-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-new-chat-btn {
    background: transparent;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chatbot-new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-close-btn {
    background: transparent;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-close-btn svg {
    width: 20px;
    height: 20px;
}

/* Body */
.chatbot-body {
    flex: 1;
    background-color: #f8fafc;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages */
.chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message {
    background-color: white;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Animated typing indicator: three bouncing dots */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
}

.typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #94a3b8;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

.user-message {
    background-color: #1f7b68;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.chatbot-suggestions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap; /* Allows chips to wrap if they exceed row width */
}

.chatbot-chip {
    background-color: white;
    border: 1px solid #1f7b68;
    color: #1f7b68;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.chatbot-chip:hover {
    background-color: #f0fdfa;
}

.chatbot-agent-link {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chatbot-agent-link:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

/* Footer / Input */
.chatbot-footer {
    padding: 12px 16px;
    background-color: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-mic-btn {
    background-color: #f1f5f9;
    border: none;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chatbot-mic-btn:hover {
    background-color: #e2e8f0;
    color: #1f7b68;
}

.chatbot-mic-btn svg {
    width: 18px;
    height: 18px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #1f7b68;
    border-radius: 999px;
    padding: 8px 16px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
}

.chatbot-input::placeholder {
    color: #94a3b8;
}

.chatbot-send-btn {
    background-color: #78a594;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn.send-btn--active {
    background-color: #1f7b68;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

.chatbot-send-btn svg {
    width: 18px;
    height: 18px;
    margin-right: -2px; /* slight visual balance for paper plane */
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-panel {
        width: calc(100% - 32px);
        bottom: 16px;
        right: 16px;
        max-height: calc(100vh - 32px);
    }
    
    .chatbot-trigger {
        bottom: 16px;
        right: 16px;
    }
}

/* ── Agent Cards ───────────────────────────────────────────────────────────── */

.chatbot-agent-cards {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    min-height: min-content;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    margin-top: 8px;
    padding-bottom: 8px;
    width: 100%;
}

/* Subtle scrollbar affordance */
.chatbot-agent-cards::-webkit-scrollbar {
    height: 5px;
}
.chatbot-agent-cards::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-agent-cards::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.chatbot-agent-cards::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chatbot-agent-card {
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    animation: chatbot-card-in 0.25s ease both;
    
    display: flex;
    flex-direction: column;
    flex: 0 0 280px;
    width: 280px;
    scroll-snap-align: start;
}

.chatbot-agent-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.10);
    transform: translateY(-1px);
}

@keyframes chatbot-card-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Card header row */
.chatbot-ac-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.chatbot-ac-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    flex-shrink: 0;
}

.chatbot-ac-info {
    flex: 1;
    min-width: 0;
}

.chatbot-ac-name {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    display: block;
    word-break: break-word;
    overflow-wrap: break-word;
}

.chatbot-ac-name .chatbot-ac-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    margin-bottom: 2px;
}

.chatbot-ac-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
    white-space: nowrap;
}

.chatbot-badge--verified { background: #f0f9ff; color: #0369a1; }
.chatbot-badge--irdai    { background: #fdf4ff; color: #7e22ce; }
.chatbot-badge--trusted  { background: #fefce8; color: #854d0e; }

.chatbot-ac-stars {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 2px;
    margin-top: 3px;
    font-size: 12px;
}

.chatbot-star--full  { color: #f59e0b; }
.chatbot-star--half  { color: #fbbf24; opacity: .7; }
.chatbot-star--empty { color: #e2e8f0; }

.chatbot-ac-rating-val  { font-size: 11px; font-weight: 700; color: #374151; margin-left: 2px; }
.chatbot-ac-review-count { font-size: 10px; color: #9ca3af; }

.chatbot-ac-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
    color: #6b7280;
    margin-top: 3px;
}

/* Match % badge (top-right) */
.chatbot-ac-match {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    padding: 5px 8px;
    border-radius: 10px;
    min-width: 42px;
}

.chatbot-match--green { background: #f0fdf4; color: #15803d; }
.chatbot-match--amber { background: #fffbeb; color: #b45309; }
.chatbot-match--red   { background: #fff1f2; color: #be123c; }

/* Segment tags */
.chatbot-ac-segs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.chatbot-seg-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid;
}

/* Action buttons */
.chatbot-ac-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.chatbot-ac-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 7px 4px;
    border-radius: 8px;
    text-decoration: none;
    border: 1.5px solid transparent;
    transition: all 0.18s ease;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.chatbot-ac-btn--call {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}
.chatbot-ac-btn--call:hover {
    background: #dcfce7;
    border-color: #86efac;
}

.chatbot-ac-btn--wa {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}
.chatbot-ac-btn--wa:hover {
    background: #dcfce7;
    border-color: #86efac;
}

.chatbot-ac-btn--profile {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}
.chatbot-ac-btn--profile:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* Ensure SweetAlert renders above the chatbot panel */
.swal2-container.swal-chatbot-zindex {
    z-index: 9999999999 !important;
}

/* Waiting / disabled state */
.chatbot-input:disabled {
    color: #94a3b8;
    background: #f1f5f9;
    cursor: not-allowed;
}

.chatbot-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    background-color: #78a594;
}
