/**
 * Modal Chat Styles
 * Handles the "Have Questions?" button and modal chat window
 */

:root {
    --mistral-primary: #1aa39e;
    --mistral-accent: rgba(26,163,158,0.12);
    --mistral-bg: #f6fbfb;
    --mistral-card: #ffffff;
    --mistral-muted: #6b7280;
    --mistral-shadow: 0 12px 40px rgba(16,24,32,0.08);
    --mistral-shadow-sm: 0 6px 18px rgba(16,24,32,0.04);
}

/* "Have Questions?" Button - Fixed Bottom Right */
.mistral-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99998;
    padding: 14px 20px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, var(--mistral-primary) 0%, #158c88 100%);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--mistral-shadow);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mistral-chat-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(26, 163, 158, 0.2);
}

.mistral-chat-button:active {
    transform: translateY(-2px);
}

.mistral-chat-button svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Modal Overlay */
.mistral-chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Chat Container */
.mistral-chat-modal {
    border: 1px solid #1aa39e;
    margin-bottom: 10px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100000;
    width: 60%;
    max-width: 95vw;
    height: 650px;
    max-height: 85vh;
    background: var(--mistral-card);
    border-radius: 17px;
    box-shadow: var(--mistral-shadow);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Modal Header */
.mistral-chat-modal-header {
    background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)), var(--mistral-primary);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 14px 14px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mistral-chat-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.mistral-chat-modal-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.mistral-chat-modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.mistral-chat-modal-close:active {
    transform: scale(0.95);
}

/* Modal Content Container */
.mistral-chat-modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(26,163,158,0.04) 0%, rgba(255,255,255,0) 30%);
    padding: 16px;
}

/* Initial Message Container in Modal */
.mistral-chat-modal-content .mistral-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    flex: 1;
}

.mistral-chat-modal-content .mistral-initial .center-box {
    background: var(--mistral-card);
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--mistral-shadow-sm);
    text-align: center;
    width: 100%;
}

.mistral-chat-modal-content .mistral-initial .lead {
    font-size: 16px;
    margin-bottom: 10px;
    color: #07122a;
    font-weight: 600;
}

.mistral-chat-modal-content .mistral-initial .sub {
    color: var(--mistral-muted);
    font-size: 13px;
    margin-bottom: 14px;
}

.mistral-chat-modal-content .mistral-initial .center-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.mistral-chat-modal-content .mistral-initial input[type="text"] {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--mistral-primary);
    font-size: 14px;
    color: #0f1720;
    background: white;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mistral-chat-modal-content .mistral-initial input[type="text"]::placeholder {
    color: rgba(15, 23, 32, 0.45);
}

.mistral-chat-modal-content .mistral-initial button {
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--mistral-primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mistral-chat-modal-content .mistral-initial button:hover {
    background: #158c88;
}

.mistral-chat-modal-content .mistral-initial button:active {
    transform: scale(0.95);
}

.mistral-chat-modal-content .muted {
    color: var(--mistral-muted);
    font-size: 12px;
}

/* Messages Container in Modal */
.mistral-chat-modal-content .mistral-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: white;
    border-radius: 8px;
    display: none;
    scroll-behavior: smooth;
    border: 1px solid rgba(16, 24, 32, 0.06);
}

.mistral-chat-modal-content .mistral-chat-messages.show {
    display: flex !important;
    flex-direction: column;
}

.mistral-chat-modal-content .mistral-chat-messages .chat-row {
    display: flex;
    margin-bottom: 12px;
}

.mistral-chat-modal-content .mistral-chat-messages .chat-row.bot {
    justify-content: flex-start;
}

.mistral-chat-modal-content .mistral-chat-messages .chat-row.user {
    justify-content: flex-end;
}

.mistral-chat-modal-content .mistral-bubble {
    display: inline-block;
    padding: 10px 12px;
    border-radius: 10px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: var(--mistral-shadow-sm);
    word-wrap: break-word;
    white-space: normal;
}

.mistral-chat-modal-content .mistral-bubble span {
    display: block;
    color: inherit;
}

/* HTML content styling */
.mistral-chat-modal-content .mistral-bubble p {
    margin: 0 0 8px 0;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble b,
.mistral-chat-modal-content .mistral-bubble strong {
    font-weight: 600;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble i,
.mistral-chat-modal-content .mistral-bubble em {
    font-style: italic;
}

.mistral-chat-modal-content .mistral-bubble ul,
.mistral-chat-modal-content .mistral-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble li {
    margin: 4px 0;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble a {
    color: inherit;
    text-decoration: underline;
}

.mistral-chat-modal-content .mistral-bubble h1,
.mistral-chat-modal-content .mistral-bubble h2,
.mistral-chat-modal-content .mistral-bubble h3,
.mistral-chat-modal-content .mistral-bubble h4,
.mistral-chat-modal-content .mistral-bubble h5,
.mistral-chat-modal-content .mistral-bubble h6 {
    margin: 8px 0 4px 0;
    font-weight: 600;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: inherit;
}

.mistral-chat-modal-content .mistral-bubble pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 3px;
    overflow-x: auto;
    margin: 8px 0;
}

.mistral-chat-modal-content .mistral-bubble.bot {
    background: linear-gradient(180deg,#e9f6f6,#e1efef);
    color: #07121a;
}

.mistral-chat-modal-content .mistral-bubble.user {
    background: var(--mistral-primary);
    color: white;
}

/* Message Feedback Buttons */
.mistral-chat-modal-content .message-feedback {
    display: none;
    margin-top: 6px;
}

.mistral-chat-modal-content .message-feedback.show {
    display: flex !important;
    gap: 8px;
    align-items: center;
}

.mistral-chat-modal-content .feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #1aa39e;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.mistral-chat-modal-content .feedback-btn:hover {
    opacity: 1;
    color: #158c88;
    transform: scale(1.1);
}

.mistral-chat-modal-content .feedback-btn.selected {
    opacity: 1;
    color: #107571;
}

/* Typing Indicator */
.mistral-chat-modal-content .typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.mistral-chat-modal-content .dot {
    width: 6px;
    height: 6px;
    background: var(--mistral-muted);
    border-radius: 50%;
    opacity: 0.7;
    animation: bounce 1s infinite ease-in-out;
}

.mistral-chat-modal-content .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.mistral-chat-modal-content .dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
}

/* Input Bar for After Chat Started */
.mistral-chat-modal-content #mistral-modal-input-container {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(16, 24, 32, 0.06);
}

.mistral-input-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: linear-gradient(180deg, white, #fbffff);
    border: 1px solid rgba(16, 24, 32, 0.03);
}

.mistral-input-bar input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(16, 24, 32, 0.06);
    color: #0f1720;
    background: white;
    font-size: 14px;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mistral-input-bar input::placeholder {
    color: rgba(15, 23, 32, 0.45);
}

.mistral-input-bar button {
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--mistral-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mistral-input-bar button:hover {
    background: #158c88;
}

.mistral-input-bar button:active {
    transform: scale(0.95);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .mistral-chat-button {
        bottom: 20px;
        right: 20px;
        padding: 12px 16px;
        font-size: 14px;
    }

    .mistral-chat-modal {
        top: auto;
        left: auto;
        transform: none;
        bottom: 20px;
        right: 20px;
        width: calc(100vw - 40px);
        height: 70vh;
    }
}

@media (max-width: 480px) {
    .mistral-chat-button {
        bottom: 15px;
        right: 15px;
        padding: 10px 14px;
        font-size: 12px;
        gap: 6px;
    }

    .mistral-chat-button svg {
        width: 18px;
        height: 18px;
    }

    .mistral-chat-modal {
        top: auto;
        left: auto;
        transform: none;
        bottom: 15px;
        right: 15px;
        width: calc(100vw - 30px);
        height: 75vh;
        border-radius: 12px;
    }

    .mistral-chat-modal-header {
        padding: 14px 16px;
    }

    .mistral-chat-modal-header h2 {
        font-size: 16px;
    }

    .mistral-chat-modal-content {
        padding: 12px;
    }

    .mistral-chat-modal-content .mistral-bubble {
        max-width: 85%;
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* Smooth transitions for modal state changes */
.mistral-initial.started {
    display: none !important;
    pointer-events: none;
}

.mistral-chat-messages.show {
    display: flex !important;
}

/* Scrollbar styling for messages */
.mistral-chat-modal-content .mistral-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.mistral-chat-modal-content .mistral-chat-messages::-webkit-scrollbar-track {
    background: rgba(16, 24, 32, 0.02);
    border-radius: 4px;
}

.mistral-chat-modal-content .mistral-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(16, 24, 32, 0.1);
    border-radius: 4px;
}

.mistral-chat-modal-content .mistral-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 24, 32, 0.15);
}
