/**
 * KARIMIGO SPI Widget - Enhanced Styling v8.4.0
 * Modern, clean design with beautiful typography, rich formatting, and voice indicators
 * 
 * CHANGELOG v8.4.0:
 * - ✅ All previous features preserved
 * - ✅ Enhanced conversational UI elements
 * - ✅ Better voice state indicators
 * - ✅ Improved mobile responsiveness
 * - ✅ Smoother animations
 */

/* ============================================
   WIDGET CONTAINER
   ============================================ */
.karimigo-spi-widget {
    position: static !important;
    width: 100%;
    max-width: 100%;
    float: none !important;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin: 20px 0;
    font-family: 'Segoe UI', 'Poppins', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

/* ============================================
   VOICE STATE INDICATORS
   ============================================ */

/* Voice Listening State - Green glow */
.karimigo-spi-widget.voice-listening {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4),
        0 8px 24px rgba(0, 0, 0, 0.15);
    animation: listening-pulse 2s ease-in-out infinite;
}

@keyframes listening-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

/* Voice Speaking State - Purple glow */
.karimigo-spi-widget.voice-speaking {
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.4),
        0 8px 24px rgba(0, 0, 0, 0.15);
    animation: speaking-pulse 1s ease-in-out infinite;
}

@keyframes speaking-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.4),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(147, 51, 234, 0.2),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

/* User Speaking State - Blue glow */
.karimigo-spi-widget.user-speaking {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5),
        0 8px 24px rgba(0, 0, 0, 0.15);
    animation: user-speaking-pulse 1s ease-in-out infinite;
}

@keyframes user-speaking-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.3),
            0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

/* Combined state: AI speaking + User interrupting */
.karimigo-spi-widget.voice-speaking.user-speaking {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.5),
        0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Conversation Active State */
.karimigo-spi-widget.conversation-active .karimigo-spi-input-area {
    border-top: 2px solid #6366f1;
}

.karimigo-spi-widget.conversation-active .karimigo-spi-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

/* ============================================
   WIDGET HEADER
   ============================================ */
.karimigo-spi-header {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%) !important;
    color: white !important;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(107, 70, 193, 0.2);
    transition: background 0.3s ease;
}

.karimigo-ai-avatar {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
}

.karimigo-header-text {
    flex: 1;
}

.karimigo-header-text h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: white !important;
}

.karimigo-header-text p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    color: white !important;
}

.karimigo-mute-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.karimigo-mute-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Mute Button - Active Listening State */
.karimigo-mute-btn.listening-active {
    background: rgba(34, 197, 94, 0.3) !important;
    color: #22c55e !important;
    animation: mute-btn-pulse 1.5s ease-in-out infinite;
}

@keyframes mute-btn-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* ============================================
   MESSAGES CONTAINER
   ============================================ */
.karimigo-spi-messages {
    max-height: 500px;
    overflow-y: auto;
    padding: 24px;
    background: #f8f9fa;
    min-height: 300px;
}

.karimigo-spi-messages::-webkit-scrollbar {
    width: 8px;
}

.karimigo-spi-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.karimigo-spi-messages::-webkit-scrollbar-thumb {
    background: #6B46C1;
    border-radius: 10px;
}

.karimigo-spi-messages::-webkit-scrollbar-thumb:hover {
    background: #9333EA;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */
.karimigo-spi-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
}

.user-message .message-avatar {
    background: #e2e8f0;
}

.message-content {
    flex: 1;
    max-width: 85%;
}

.ai-message .message-content {
    background: linear-gradient(180deg, #ffffff 0%, #f8f5ff 100%) !important;
    color: #111827 !important;
    border-radius: 12px 12px 12px 4px !important;
    padding: 16px 20px !important;
    border: 1px solid rgba(107, 70, 193, 0.22) !important;
    border-left: 4px solid #9333EA !important;
    box-shadow: 0 10px 28px rgba(107, 70, 193, 0.10), 0 2px 10px rgba(0, 0, 0, 0.06) !important;
}

.user-message .message-content {
    background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%) !important;
    color: #111111 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px 12px 4px 12px !important;
    padding: 12px 16px !important;
    margin-left: auto !important;
    /* keeps user bubbles on the right */
}




.message-time {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 8px;
    text-align: right;
}

.user-message .message-time {
    color: #6b7280;
}

/* ============================================
   INTERIM TRANSCRIPT
   ============================================ */
.interim-transcript {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    font-size: 14px;
    color: #92400e;
    font-style: italic;
    animation: fadeInTranscript 0.3s ease;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}

.interim-transcript i {
    color: #f59e0b;
    margin-right: 8px;
    animation: mic-blink 1s infinite;
}

@keyframes mic-blink {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(1.1);
    }
}

@keyframes fadeInTranscript {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RICH AI RESPONSES
   ============================================ */
.ai-response-rich {
    font-size: 15px;
    line-height: 1.7;
    color: #1e293b;
}

.ai-response-rich p {
    margin: 12px 0 !important;
    color: #475569 !important;
}

.ai-response-rich p:first-child {
    margin-top: 0;
}

.ai-response-rich p:last-child {
    margin-bottom: 0;
}

.ai-response-rich strong {
    color: #6B46C1 !important;
    font-weight: 600 !important;
    font-size: 1.02em !important;
}

.kmg-ai-markdown a,
.ai-response-rich a {
    color: #4f46e5;
    text-decoration: none;
    border-bottom: 1px solid rgba(79, 70, 229, 0.25);
    font-weight: 600;
}

.kmg-ai-markdown a:hover,
.ai-response-rich a:hover {
    border-bottom-color: rgba(79, 70, 229, 0.65);
}

.kmg-inline-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.94em;
    padding: 0.12em 0.35em;
    border-radius: 6px;
    background: rgba(147, 51, 234, 0.08);
    border: 1px solid rgba(147, 51, 234, 0.18);
    color: #3b0764;
}

.kmg-code-block {
    background: #0b1020;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 14px 0;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.kmg-code-block code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
}

.kmg-streaming {
    position: relative;
}

.kmg-stream-caret {
    display: inline-block;
    width: 8px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: -0.2em;
    background: linear-gradient(180deg, #6B46C1 0%, #9333EA 100%);
    border-radius: 6px;
    animation: kmg-caret-blink 0.9s steps(1, end) infinite;
}

@keyframes kmg-caret-blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

/* ============================================
   HEADINGS
   ============================================ */
.ai-response-rich h4,
.ai-heading {
    color: #1e293b;
    font-size: 17px;
    font-weight: 600;
    margin: 16px 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.section-header .emoji {
    font-size: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.section-header h4 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 18px;
    color: #1e293b;
}

/* ============================================
   NUMBERED LISTS - Beautiful Numbered Badges
   ============================================ */
.ai-numbered-list,
.ai-response-rich ol {
    margin: 16px 0;
    padding: 0;
    counter-reset: item;
    list-style: none;
}

.ai-numbered-list li,
.ai-response-rich ol li {
    margin: 12px 0;
    padding-left: 40px;
    position: relative;
    font-size: 15px;
    line-height: 1.7;
    color: #475569;
    counter-increment: item;
}

.ai-numbered-list li::before,
.ai-response-rich ol li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 2px;
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(107, 70, 193, 0.3);
}

/* ============================================
   BULLET LISTS - Green Checkmarks
   ============================================ */
.ai-bullet-list,
.ai-response-rich ul {
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.ai-bullet-list li,
.ai-response-rich ul li {
    margin: 12px 0;
    padding-left: 36px;
    position: relative;
    font-size: 15px;
    line-height: 1.7;
    color: #475569;
}

.ai-bullet-list li::before,
.ai-response-rich ul li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: #10b981;
    font-weight: bold;
    font-size: 20px;
}

/* ============================================
   PRICE BOX - Gradient Beauty
   ============================================ */
.price-box {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    margin: 16px 0;
    text-align: center;
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.3);
}

.price-box .product-name {
    font-size: 14px;
    opacity: 0.95;
    margin-bottom: 10px;
    font-weight: 500;
}

.price-box .price-main {
    font-size: 36px;
    font-weight: 700;
    margin: 10px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.price-box .stock-info {
    font-size: 14px;
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    display: inline-block;
    font-weight: 500;
}

/* ============================================
   ALERT BOXES - Color-Coded Messages
   ============================================ */
.alert-box {
    padding: 16px 18px;
    border-radius: 10px;
    margin: 16px 0;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.alert-box.success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left: 4px solid #10b981;
}

.alert-box.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
}

.alert-box.info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left: 4px solid #3b82f6;
}

.alert-box .icon {
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
}

.alert-box .content p {
    margin: 0;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.6;
}

/* ============================================
   HIGHLIGHT BOX
   ============================================ */
.highlight-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 14px 18px;
    border-radius: 8px;
    margin: 16px 0;
}

.highlight-box strong {
    color: #92400e;
}

.highlight-box p {
    margin: 0;
    color: #78350f;
}

/* ============================================
   STOCK BOX
   ============================================ */
.stock-box {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 20px;
    margin: 16px 0;
    text-align: center;
}

.stock-box.available {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #10b981;
}

.stock-box.unavailable {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
}

.stock-box .status {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.stock-box .quantity {
    font-size: 14px;
    color: #475569;
    margin: 6px 0;
}

.stock-box .action {
    font-size: 14px;
    color: #64748b;
    margin-top: 8px;
}

/* ============================================
   PRODUCT HIGHLIGHT
   ============================================ */
.product-highlight {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px;
    margin: 16px 0;
}

.product-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.price-tag {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.stock-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.stock-badge.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.stock-badge.out-stock {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   WELCOME MESSAGE
   ============================================ */
.ai-welcome-message {
    font-size: 15px;
}

.ai-welcome-message .greeting {
    font-size: 16px;
    margin-bottom: 16px;
}

.ai-welcome-message .cta-text {
    font-size: 16px;
    margin-top: 16px;
    color: #1e293b;
}

/* ============================================
   QUICK ACTION BUTTONS
   ============================================ */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 0 0;
    padding-top: 16px;
}

.quick-action-btn {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(107, 70, 193, 0.25);
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.35);
}

/* ============================================
   CTA BOX
   ============================================ */
.cta-box {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    margin: 16px 0;
    text-align: center;
    box-shadow: 0 4px 16px rgba(107, 70, 193, 0.3);
}

.cta-box h4 {
    color: white;
    margin: 0 0 10px 0;
    border: none;
    padding: 0;
    font-size: 19px;
}

.cta-box p {
    color: rgba(255, 255, 255, 0.95);
    margin: 8px 0 18px 0;
    font-size: 15px;
}

.cta-button {
    background: white;
    color: #6B46C1;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    background: #f8f9fa;
}

/* ============================================
   INPUT AREA
   ============================================ */
.karimigo-spi-input-area {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
    transition: border-top 0.3s ease;
}

#karimigo-spi-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

#karimigo-spi-input:focus {
    outline: none;
    border-color: #6B46C1;
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.1);
}

.karimigo-send-btn,
.karimigo-voice-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.karimigo-send-btn {
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%) !important;
    color: white !important;
}

.karimigo-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.3);
}

.karimigo-voice-btn {
    background: #f1f5f9;
    color: #64748b;
}

.karimigo-voice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.karimigo-voice-btn:not(:disabled):hover {
    background: #e2e8f0;
    color: #6B46C1;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.karimigo-typing-indicator {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px 12px 12px 4px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #6B46C1;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ============================================
   MUTE TOAST NOTIFICATION
   ============================================ */
.karimigo-mute-toast {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 999999;
    animation: toastSlideIn 0.3s ease, toastSlideOut 0.3s ease 2.2s forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus states */
.ai-response-rich *:focus,
.karimigo-send-btn:focus,
.karimigo-mute-btn:focus,
.karimigo-voice-btn:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .karimigo-spi-widget.voice-listening {
        border: 3px solid #22c55e;
    }

    .karimigo-spi-widget.voice-speaking {
        border: 3px solid #9333ea;
    }

    .interim-transcript {
        border: 2px solid #f59e0b;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .karimigo-spi-widget.voice-listening,
    .karimigo-spi-widget.voice-speaking,
    .karimigo-mute-btn.listening-active,
    .interim-transcript i,
    .typing-dots span,
    .karimigo-spi-message {
        animation: none;
    }

    .karimigo-send-btn:hover,
    .karimigo-mute-btn:hover,
    .quick-action-btn:hover,
    .cta-button:hover {
        transform: none;
    }
}

/* ============================================
   MODE SELECTION OVERLAY
   ============================================ */
.karimigo-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    padding: 20px;
}

.karimigo-mode-choice-container {
    background: white;
    padding: 40px;
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.karimigo-mode-choice-container h3 {
    font-size: 28px;
    margin-bottom: 12px;
    color: #1e293b;
    border: none;
    padding: 0;
}

.karimigo-mode-choice-container p {
    color: #64748b;
    font-size: 16px;
    margin-bottom: 30px;
}

.karimigo-mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 480px) {
    .karimigo-mode-options {
        grid-template-columns: 1fr;
    }
}

.karimigo-mode-option {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.karimigo-mode-option:hover {
    background: white;
    border-color: #6B46C1;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(107, 70, 193, 0.1);
}

.karimigo-mode-icon {
    font-size: 40px;
    margin-bottom: 15px;
}

.karimigo-mode-option h4 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #1e293b;
    border: none;
    padding: 0;
}

.karimigo-mode-option p {
    font-size: 14px;
    margin-bottom: 0;
    line-height: 1.4;
}

.karimigo-mode-option[data-mode="voice"]:hover {
    background: linear-gradient(135deg, rgba(107, 70, 193, 0.05) 0%, rgba(147, 51, 234, 0.05) 100%);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .karimigo-spi-widget {
        border-radius: 12px;
        margin: 16px 0;
    }

    .karimigo-spi-header {
        padding: 16px 18px;
    }

    .karimigo-ai-avatar {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .karimigo-header-text h3 {
        font-size: 16px;
    }

    .karimigo-spi-messages {
        padding: 16px;
        max-height: 400px;
    }

    .ai-response-rich {
        font-size: 14px;
    }

    .price-box .price-main {
        font-size: 28px;
    }

    .karimigo-spi-input-area {
        padding: 16px;
    }

    #karimigo-spi-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .karimigo-send-btn,
    .karimigo-voice-btn {
        width: 40px;
        height: 40px;
    }

    .message-content {
        max-width: 90%;
    }

    .quick-actions {
        gap: 8px;
    }

    .quick-action-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .karimigo-mute-toast {
        bottom: 80px;
        right: 20px;
        font-size: 13px;
        padding: 10px 20px;
    }

    .interim-transcript {
        font-size: 13px;
        padding: 10px 14px;
        margin: 10px 0;
    }

    .karimigo-spi-widget.voice-listening,
    .karimigo-spi-widget.voice-speaking {
        animation: none;
        box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .karimigo-spi-widget.voice-speaking {
        box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   CHAT MODE CHOICE (Voice + Text / Text only)
   Uses SPI header gradient as primary color
   ============================================ */
.karimigo-mode-choice {
    margin-top: 4px;
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 100%);
    color: #f9fafb;
    border-radius: 14px;
    padding: 16px 18px 18px;
    box-shadow: 0 14px 40px rgba(76, 29, 149, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.25);
    position: relative;
    overflow: hidden;
}

.karimigo-mode-choice::before {
    content: "";
    position: absolute;
    inset: -40%;
    background:
        radial-gradient(circle at top left, rgba(254, 243, 199, 0.45) 0, transparent 55%),
        radial-gradient(circle at bottom right, rgba(191, 219, 254, 0.4) 0, transparent 55%);
    opacity: 0.6;
    pointer-events: none;
}

.karimigo-mode-choice p {
    position: relative;
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.5;
    z-index: 1;
}

.karimigo-mode-choice p strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.mode-choice-buttons {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    z-index: 1;
}

.kmg-mode-btn {
    flex: 1 1 130px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.16);
    color: #f9fafb;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition:
        background 0.20s ease,
        transform 0.15s ease,
        box-shadow 0.20s ease,
        border-color 0.20s ease;
}

.kmg-mode-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 10px 26px rgba(76, 29, 149, 0.5);
    transform: translateY(-1px);
}

.kmg-mode-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Subtle distinction for Text-only while staying in same palette */
.kmg-mode-btn[data-mode="text"] {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.55);
    opacity: 0.95;
}

/* Voice button gets a soft focus indicator (not green) */
.kmg-mode-btn[data-mode="voice"]::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #e0e7ff;
    box-shadow: 0 0 0 4px rgba(191, 219, 254, 0.7);
    margin-right: 4px;
}

@media (max-width: 480px) {
    .mode-choice-buttons {
        flex-direction: column;
    }
}


/* ============================================
   CHAT MODE OVERLAY (Voice & Text / Text Only)
   ============================================ */

#kmg-mode-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#kmg-mode-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}

.kmg-mode-overlay-panel {
    position: relative;
    z-index: 1;
    width: min(92vw, 480px);
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    padding: 22px 24px 18px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.kmg-mode-overlay-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #020617;
}

.kmg-mode-overlay-sub {
    margin: 0 0 18px;
    font-size: 14px;
    color: #4b5563;
}

.kmg-mode-overlay-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.kmg-mode-overlay-btn {
    flex: 1 1 160px;
    border-radius: 9999px;
    border: none;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease,
        background-color 0.08s ease,
        color 0.08s ease;
}

/* 🎙 Voice & Text primary – match SPI header gradient, no green */
.kmg-mode-overlay-btn[data-mode="voice"] {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #f9fafb;
    box-shadow: 0 14px 28px rgba(99, 102, 241, 0.45);
}

.kmg-mode-overlay-btn[data-mode="voice"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(99, 102, 241, 0.65);
}

/* ⌨ Text Only secondary */
.kmg-mode-overlay-btn[data-mode="text"] {
    background: #f9fafb;
    color: #111827;
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.9);
}

.kmg-mode-overlay-btn[data-mode="text"]:hover {
    background: #e5e7eb;
}

.kmg-mode-overlay-note {
    margin: 4px 0 0;
    font-size: 12px;
    color: #6b7280;
}

@media (max-width: 768px) {
    #kmg-mode-overlay {
        padding: 16px;
    }

    .kmg-mode-overlay-panel {
        width: 100%;
        border-radius: 18px;
        padding: 18px 16px 16px;
    }
}


/* ================================
 * Karimigo SPI – Duplex Mic Active
 * ================================ */
.karimigo-spi-widget .karimigo-voice-btn.kmg-mic-active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f9fafb;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4),
        0 0 18px rgba(34, 197, 94, 0.75);
    transform: translateY(-1px) scale(1.02);
    transition: all 0.18s ease-out;
    animation: kmgMicPulse 1.25s ease-in-out infinite;
}

.karimigo-spi-widget .karimigo-voice-btn.kmg-mic-active i {
    color: #ecfdf5;
}

/* Subtle pulsing ring to show \"listening\" */
@keyframes kmgMicPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.75),
            0 0 18px rgba(34, 197, 94, 0.9);
        transform: translateY(-1px) scale(1.02);
    }

    60% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.0),
            0 0 10px rgba(34, 197, 94, 0.5);
        transform: translateY(-1px) scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.0),
            0 0 18px rgba(34, 197, 94, 0.85);
        transform: translateY(-1px) scale(1.02);
    }
}

/* ================================
 * Karimigo Duplex Voice – Mic states
 * ================================ */
.karimigo-spi-widget.user-recording .karimigo-voice-btn {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35);
}

.karimigo-spi-widget.user-recording .karimigo-voice-btn i {
    animation: kmg-voice-pulse 1s ease-in-out infinite;
}

@keyframes kmg-voice-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.08);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Base AI message text */
.karimigo-spi-message-ai {
    color: #111827;
    /* near-black, very readable on white */
}

/* Label before values: "Price:", "Range:", etc. */
.karimigo-spi-message-ai .kmg-label {
    font-weight: 600;
    color: #111827;
}

/* Semantic colours */
.karimigo-spi-message-ai .kmg-text-success {
    color: #0a7a36;
    /* deep green */
}

.karimigo-spi-message-ai .kmg-text-warning {
    color: #b45309;
    /* strong orange */
}

.karimigo-spi-message-ai .kmg-text-danger {
    color: #b91c1c;
    /* strong red */
}

/* Optional accent for headings/links if we use kmg-text-accent */
.karimigo-spi-message-ai .kmg-text-accent {
    color: #1d4ed8;
    /* strong blue */
}

/* Feature / step lists */
.karimigo-spi-message-ai .kmg-feature-list,
.karimigo-spi-message-ai .kmg-step-list {
    margin: 8px 0 8px 18px;
    padding: 0;
}

.karimigo-spi-message-ai .kmg-feature-list li,
.karimigo-spi-message-ai .kmg-step-list li {
    margin-bottom: 4px;
}