/* ==========================================
   Isrisoft Technologies - Generative AI Chatbot Styles
   ========================================== */

/* 1. Floating Widget Trigger Button */
#isri-chatbot-trigger {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 10px 30px rgba(236, 72, 153, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 99999;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
}

#isri-chatbot-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.5);
}

#isri-chatbot-trigger:active {
    transform: scale(0.95);
}

/* Ensure normal system mouse arrow & pointer are visible over chatbot */
#isri-chatbot-container,
#isri-chatbot-container * {
    cursor: auto;
}

#isri-chatbot-container button,
#isri-chatbot-container a,
#isri-chatbot-container .isri-chip-btn,
#isri-chatbot-trigger,
.isri-ctrl-btn,
.isri-send-btn,
.isri-action-btn {
    cursor: pointer !important;
}

#isri-chatbot-container input {
    cursor: text !important;
}

/* Hide custom laggy cursor rings over chatbot so native arrow is clear */
body.custom-cursor-active #isri-chatbot-container:hover ~ .custom-cursor-dot,
body.custom-cursor-active #isri-chatbot-container:hover ~ .custom-cursor-ring,
body.custom-cursor-active #isri-chatbot-trigger:hover ~ .custom-cursor-dot,
body.custom-cursor-active #isri-chatbot-trigger:hover ~ .custom-cursor-ring {
    opacity: 0 !important;
}

/* Pulsing aura ring around trigger button */
#isri-chatbot-trigger::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    z-index: -1;
    opacity: 0.5;
    animation: isri-pulse-ring 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes isri-pulse-ring {
    0% { transform: scale(0.95); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 0; }
    100% { transform: scale(0.95); opacity: 0; }
}

/* Notification badge on trigger button */
.isri-chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #10b981;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    border: 2px solid var(--bg-primary, #0d1222);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    animation: isri-badge-bounce 3s ease infinite;
}

@keyframes isri-badge-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Tooltip tag next to launcher */
.isri-chatbot-tooltip {
    position: absolute;
    right: 72px;
    background: var(--bg-secondary, #13192e);
    color: var(--text-primary, #f8fafc);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    padding: 0.4rem 0.85rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

#isri-chatbot-trigger:hover .isri-chatbot-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* 2. Chat Window Overlay Container */
#isri-chatbot-container {
    position: fixed;
    bottom: 95px;
    right: 25px;
    width: 390px;
    height: 590px;
    max-height: calc(100vh - 120px);
    background: var(--bg-secondary, rgba(13, 18, 34, 0.94));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 92, 246, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

body:not(.dark-theme) #isri-chatbot-container {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 30px rgba(139, 92, 246, 0.1);
}

#isri-chatbot-container.isri-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 3. Header Section */
.isri-chat-header {
    padding: 1.1rem 1.25rem;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 2;
}

.isri-chat-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.isri-avatar-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.isri-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid var(--bg-secondary, #0d1222);
    border-radius: 50%;
}

.isri-chat-title h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    margin: 0 0 2px 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.isri-chat-title span {
    font-size: 0.75rem;
    color: #10b981;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.isri-chat-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.isri-ctrl-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.isri-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #ffffff);
}

.isri-ctrl-btn.active {
    color: #ec4899;
}

/* 4. Gemini API Key Settings Panel */
.isri-chat-settings-panel {
    background: rgba(139, 92, 246, 0.08);
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    padding: 0.85rem 1.25rem;
    display: none;
    animation: isri-slide-down 0.25s ease;
}

.isri-chat-settings-panel.open {
    display: block;
}

@keyframes isri-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.isri-settings-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-purple, #8b5cf6);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.isri-settings-input-group {
    display: flex;
    gap: 0.5rem;
}

.isri-settings-input-group input {
    flex: 1;
    background: var(--bg-primary, #070a13);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: var(--text-primary, #ffffff);
    font-size: 0.8rem;
    outline: none;
}

.isri-settings-input-group button {
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.isri-settings-hint {
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 0.4rem;
}

.isri-settings-hint a {
    color: var(--accent-pink, #ec4899);
    text-decoration: underline;
}

/* 5. Chat Messages Body */
.isri-chat-body {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.isri-chat-body::-webkit-scrollbar {
    width: 5px;
}

.isri-chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Welcome Card */
.isri-welcome-card {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-primary, #ffffff);
    line-height: 1.5;
}

.isri-welcome-card i {
    font-size: 1.5rem;
    color: #ec4899;
    margin-bottom: 0.5rem;
    display: block;
}

/* Chat Message Item */
.isri-msg-item {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: isri-msg-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes isri-msg-appear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.isri-msg-item.bot {
    align-self: flex-start;
}

.isri-msg-item.user {
    align-self: flex-end;
}

.isri-msg-bubble {
    padding: 0.85rem 1.1rem;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.isri-msg-item.bot .isri-msg-bubble {
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    color: var(--text-primary, #ffffff);
    border-bottom-left-radius: 4px;
}

body:not(.dark-theme) .isri-msg-item.bot .isri-msg-bubble {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #e2e8f0;
}

.isri-msg-item.user .isri-msg-bubble {
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.isri-msg-time {
    font-size: 0.68rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 0.3rem;
    padding: 0 0.4rem;
}

.isri-msg-item.user .isri-msg-time {
    text-align: right;
}

/* Markdown formatting inside bubbles */
.isri-msg-bubble p {
    margin: 0 0 0.5rem 0;
}
.isri-msg-bubble p:last-child {
    margin-bottom: 0;
}
.isri-msg-bubble ul, .isri-msg-bubble ol {
    margin: 0.4rem 0;
    padding-left: 1.2rem;
}
.isri-msg-bubble li {
    margin-bottom: 0.25rem;
}
.isri-msg-bubble strong {
    font-weight: 700;
    color: inherit;
}
.isri-msg-bubble a {
    color: #ec4899;
    text-decoration: underline;
}

/* Interactive Action Buttons inside responses */
.isri-msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.isri-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    color: var(--text-primary, #ffffff);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.isri-action-btn:hover {
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.isri-action-btn.whatsapp-btn {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.isri-action-btn.whatsapp-btn:hover {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 6. Quick Reply Suggestions Chips */
.isri-quick-chips {
    padding: 0.6rem 1.25rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.02));
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.05));
}

.isri-quick-chips::-webkit-scrollbar {
    display: none;
}

.isri-chip-btn {
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
    color: var(--text-primary, #ffffff);
    padding: 0.35rem 0.8rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

body:not(.dark-theme) .isri-chip-btn {
    background: #e2e8f0;
    color: #1e293b;
}

.isri-chip-btn:hover {
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-2px);
}

/* 7. Typing Indicator */
.isri-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.85rem 1.1rem;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.isri-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-pink, #ec4899);
    border-radius: 50%;
    animation: isri-bounce 1.4s infinite ease-in-out both;
}

.isri-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.isri-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes isri-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 8. Footer Input Form */
.isri-chat-footer {
    padding: 0.85rem 1.25rem;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.isri-input-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-primary, #070a13);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
    border-radius: 50px;
    padding: 0.35rem 0.4rem 0.35rem 1.1rem;
    transition: all 0.25s ease;
}

body:not(.dark-theme) .isri-input-box {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.isri-input-box:focus-within {
    border-color: var(--accent-purple, #8b5cf6);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.25);
}

.isri-input-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary, #ffffff);
    font-family: inherit;
    font-size: 0.9rem;
}

body:not(.dark-theme) .isri-input-box input {
    color: #0f172a;
}

.isri-input-box input::placeholder {
    color: var(--text-secondary, #94a3b8);
}

.isri-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%));
    color: #ffffff !important;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    font-size: 1.05rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.isri-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.isri-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #isri-chatbot-container {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        height: 78vh;
        max-height: 560px;
        border-radius: 20px;
    }
    #isri-chatbot-trigger {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }
}
