/* =========================================
   AI CHAT STYLES
   ========================================= */

/* Modal Overlay */
#ai-chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

#ai-chat-modal.active {
    display: flex;
}

/* Chat Container */
.ai-chat-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

/* Empty State */
.ai-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #64748b;
}

.ai-chat-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ai-chat-empty h4 {
    margin: 0 0 8px 0;
    color: #334155;
    font-size: 18px;
}

.ai-chat-empty p {
    margin: 0;
    font-size: 14px;
}

/* Message Bubbles */
.ai-message-bubble {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

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

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

.ai-message-bubble.user {
    align-self: flex-end;
}

.ai-message-bubble.assistant {
    align-self: flex-start;
}

.ai-message-bubble.system {
    align-self: center;
    max-width: 90%;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-message-bubble.user .ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-bubble.assistant .ai-message-content {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ai-message-bubble.system .ai-message-content {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    text-align: center;
    font-size: 13px;
}

.ai-message-timestamp {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.ai-message-bubble.user .ai-message-timestamp {
    text-align: right;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 80px;
    margin-bottom: 16px;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    margin: 0 2px;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {

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

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

/* Input Area */
.ai-chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 12px 12px;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.ai-chat-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ai-chat-send:hover:not(:disabled) {
    transform: translateY(-2px);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Credits Display */
.ai-chat-credits {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
}

.ai-chat-credits-icon {
    color: #f59e0b;
    font-size: 16px;
}

.ai-chat-credits-count {
    font-weight: 600;
    color: #f59e0b;
}

/* Prompt Suggestion Card */
.prompt-suggestion-card {
    margin: 16px 0;
    padding: 16px;
    background: #f0f9ff;
    border: 2px solid #0ea5e9;
    border-radius: 12px;
    animation: fadeIn 0.3s ease-out;
}

.prompt-suggestion-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-suggestion-text {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background: white;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #0c4a6e;
    resize: vertical;
}

.prompt-suggestion-buttons {
    display: flex;
    gap: 8px;
}

.btn-copy-prompt,
.btn-generate-now {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-prompt {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #0ea5e9;
}

.btn-copy-prompt:hover:not(:disabled) {
    background: #bae6fd;
}

.btn-generate-now {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
}

.btn-generate-now:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-copy-prompt:disabled,
.btn-generate-now:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Scrollbar Styling */
.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-chat-header {
        border-radius: 0;
    }

    .ai-chat-input-area {
        border-radius: 0;
    }

    .ai-message-bubble {
        max-width: 85%;
    }
}

/* Manual Generation Button */
.ai-chat-manual-gen-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.ai-chat-manual-gen-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.ai-chat-manual-gen-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-manual-gen-btn i {
    font-size: 14px;
}

/* Diagram Action Card (for automatic generation) */
.diagram-action-card {
    margin: 12px 0;
    padding: 14px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #10b981;
    border-radius: 12px;
    animation: fadeIn 0.3s ease-out;
}

.diagram-action-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.diagram-action-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #065f46;
}

.btn-generate-diagram {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-generate-diagram:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-generate-diagram:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Quote Button */
.ai-chat-quote-btn {
    position: fixed !important;
    /* Fixed relative to viewport prevents scrolling issues */
    z-index: 2147483647 !important;
    /* Maximum possible Z-Index */
    background: #1e293b;
    color: white;
    border: 1px solid #334155;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.2s ease-out;
    pointer-events: auto;
    /* Ensure clickable */
}

.ai-chat-quote-btn:hover {
    background: #0f172a;
    transform: translateY(-2px);
    border-color: #475569;
}