/**
 * AskSean Chat Styles
 * Modern, clean chat interface with fixed text wrapping
 */

/* Chat Container */
.asksean-chat {
    display: flex;
    flex-direction: column;
    height: 600px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    padding: 12px 20px !important;  /* Much smaller padding */
}

.chat-header h3 {
    font-size: 1em !important;  /* Smaller text */
    margin: 0 !important;
} color: white;
}

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

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(74, 222, 128, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

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

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.user .message-avatar {
    background: #e5e7eb;
    color: #4b5563;
}

/* FIXED: Message Content with proper text wrapping */
.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    /* Critical fixes for text wrapping */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    /* Prevent horizontal overflow */
    overflow-x: hidden;
    overflow-y: visible;
}

.message.assistant .message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

/* Message Content Formatting */
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
    /* Ensure headers wrap properly */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content h2 {
    font-size: 1.3em;
    color: #1f2937;
}

.message-content h3 {
    font-size: 1.15em;
    color: #374151;
}

.message-content h4 {
    font-size: 1.05em;
    color: #4b5563;
}

.message-content p {
    margin: 0 0 12px 0;
    line-height: 1.6;
    /* Ensure paragraphs wrap properly */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
    /* Ensure list items don't overflow */
    max-width: 100%;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.6;
    /* Ensure list items wrap properly */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content strong {
    font-weight: 600;
    color: #1f2937;
}

.message.user .message-content strong {
    color: white;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
    color: #e11d48;
    /* Ensure inline code wraps */
    word-wrap: break-word;
    word-break: break-all;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message-content pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    /* Ensure code blocks don't break layout */
    max-width: 100%;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    /* Allow horizontal scroll for code blocks */
    word-break: normal;
    word-wrap: normal;
    white-space: pre;
}

.message-content a {
    color: #667eea;
    text-decoration: underline;
    word-break: break-word;
}

.message.user .message-content a {
    color: white;
    text-decoration: underline;
}

.message-content a:hover {
    text-decoration: none;
}

/* Message Metadata */
.message-meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.7;
}

.message-model {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 20px;
    background: #f8f9fa;
}

.quick-btn {
    padding: 8px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    color: #4b5563;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 20px;
    background: #f8f9fa;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite;
}

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

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

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

/* Chat Input */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
    max-height: 120px;
    line-height: 1.5;
}

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

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

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

.send-button svg {
    width: 20px;
    height: 20px;
}

/* Input Footer */
.input-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
}

.char-count.exceeded {
    color: #ef4444;
    font-weight: 600;
}

/* Error Message */
.error-message {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
    z-index: 1000;
}

.error-close {
    background: none;
    border: none;
    color: #991b1b;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .asksean-chat {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .quick-actions {
        padding: 10px;
    }
    
    .quick-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
}

/* Full Page Chat Styles */
.chat-container-full .asksean-chat {
    height: 100%;
    max-height: none;
}

/* Loading State */
.chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.chat-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading Message */
.loading-message .message-content {
    background: #f3f4f6;
}

.loading-text {
    color: #6b7280;
    font-style: italic;
    margin-bottom: 8px;
}

.typing-indicator.active {
    display: flex !important;
    gap: 4px;
    margin: 0;
    padding: 0;
}

/* Copy Button */
.copy-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #f3f4f6;
    color: #667eea;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

/* Notification Toast */
.notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 10000;
    font-size: 14px;
}

/* Dark Mode Styles */
body.dark-mode {
    background: #1f2937;
}

body.dark-mode .asksean-chat {
    background: #111827;
}

body.dark-mode .chat-header {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
}

body.dark-mode .chat-messages {
    background: #1f2937;
}

body.dark-mode .message.assistant .message-content {
    background: #374151;
    color: #f3f4f6;
}

body.dark-mode .message-content h2,
body.dark-mode .message-content h3,
body.dark-mode .message-content h4,
body.dark-mode .message-content strong {
    color: #f3f4f6;
}

body.dark-mode .message-content code {
    background: #4b5563;
    color: #fbbf24;
}

body.dark-mode .chat-input-container {
    background: #111827;
    border-top-color: #374151;
}

body.dark-mode .chat-input {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
}

body.dark-mode .chat-input:focus {
    border-color: #6366f1;
}

body.dark-mode .quick-btn {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-mode .quick-btn:hover {
    background: #6366f1;
    border-color: #6366f1;
}

body.dark-mode .error-message {
    background: #7f1d1d;
    color: #fecaca;
}

body.dark-mode .loading-message .message-content {
    background: #374151;
}

body.dark-mode .loading-text {
    color: #9ca3af;
}

body.dark-mode .copy-btn:hover {
    background: #374151;
    color: #818cf8;
}

/* Enhanced Message Animation */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message.assistant {
    animation: slideInLeft 0.3s ease-out;
}

.message.user {
    animation: slideInRight 0.3s ease-out;
}

/* Smooth Scrolling */
.chat-messages {
    scroll-behavior: smooth;
}

/* Response Time Display - Now Hidden */
.response-time {
    display: none;
}

/* Model Display - Now Hidden */
.message-model {
    display: none;
}
