/**
 * AI Chatbot Widget - Markdown Support Styles
 * 
 * Ensures proper rendering of markdown in chatbot messages
 */

/* Chatbot Message Container */
.chatbot-message-content,
.ai-chatbot-message,
.chatbot-message {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* Headings */
.chatbot-message-content h1,
.ai-chatbot-message h1,
.chatbot-message h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 16px 0 12px 0;
    color: #1a1a1a;
    border-bottom: 2px solid #e1e4e8;
    padding-bottom: 8px;
}

.chatbot-message-content h2,
.ai-chatbot-message h2,
.chatbot-message h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 14px 0 10px 0;
    color: #1a1a1a;
    border-bottom: 1px solid #e1e4e8;
    padding-bottom: 6px;
}

.chatbot-message-content h3,
.ai-chatbot-message h3,
.chatbot-message h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #1a1a1a;
}

.chatbot-message-content h4,
.ai-chatbot-message h4,
.chatbot-message h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: #1a1a1a;
}

.chatbot-message-content h5,
.ai-chatbot-message h5,
.chatbot-message h5 {
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: #1a1a1a;
}

.chatbot-message-content h6,
.ai-chatbot-message h6,
.chatbot-message h6 {
    font-size: 13px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: #666;
}

/* Text Formatting */
.chatbot-message-content strong,
.chatbot-message-content b,
.ai-chatbot-message strong,
.ai-chatbot-message b,
.chatbot-message strong,
.chatbot-message b {
    font-weight: 700;
    color: #1a1a1a;
}

.chatbot-message-content em,
.chatbot-message-content i,
.ai-chatbot-message em,
.ai-chatbot-message i,
.chatbot-message em,
.chatbot-message i {
    font-style: italic;
}

.chatbot-message-content u,
.ai-chatbot-message u,
.chatbot-message u {
    text-decoration: underline;
}

.chatbot-message-content s,
.chatbot-message-content del,
.ai-chatbot-message s,
.ai-chatbot-message del,
.chatbot-message s,
.chatbot-message del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Lists */
.chatbot-message-content ul,
.ai-chatbot-message ul,
.chatbot-message ul {
    margin: 8px 0;
    padding-left: 24px;
    list-style-type: disc;
}

.chatbot-message-content ol,
.ai-chatbot-message ol,
.chatbot-message ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-type: decimal;
}

.chatbot-message-content li,
.ai-chatbot-message li,
.chatbot-message li {
    margin: 4px 0;
    line-height: 1.6;
}

.chatbot-message-content ul ul,
.chatbot-message-content ol ul,
.ai-chatbot-message ul ul,
.ai-chatbot-message ol ul,
.chatbot-message ul ul,
.chatbot-message ol ul {
    list-style-type: circle;
}

.chatbot-message-content ul ul ul,
.chatbot-message-content ol ul ul,
.ai-chatbot-message ul ul ul,
.ai-chatbot-message ol ul ul,
.chatbot-message ul ul ul,
.chatbot-message ol ul ul {
    list-style-type: square;
}

/* Links */
.chatbot-message-content a,
.ai-chatbot-message a,
.chatbot-message a {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.chatbot-message-content a:hover,
.ai-chatbot-message a:hover,
.chatbot-message a:hover {
    color: #0052a3;
    border-bottom-color: #0052a3;
}

.chatbot-message-content a:visited,
.ai-chatbot-message a:visited,
.chatbot-message a:visited {
    color: #551a8b;
}

/* Code */
.chatbot-message-content code,
.ai-chatbot-message code,
.chatbot-message code {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 85%;
    color: #24292e;
}

.chatbot-message-content pre,
.ai-chatbot-message pre,
.chatbot-message pre {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
}

.chatbot-message-content pre code,
.ai-chatbot-message pre code,
.chatbot-message pre code {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Blockquotes */
.chatbot-message-content blockquote,
.ai-chatbot-message blockquote,
.chatbot-message blockquote {
    border-left: 4px solid #dfe2e5;
    padding: 8px 16px;
    margin: 12px 0;
    color: #666;
    background: #f6f8fa;
    border-radius: 0 4px 4px 0;
}

.chatbot-message-content blockquote p,
.ai-chatbot-message blockquote p,
.chatbot-message blockquote p {
    margin: 0;
}

/* Horizontal Rule */
.chatbot-message-content hr,
.ai-chatbot-message hr,
.chatbot-message hr {
    border: none;
    border-top: 2px solid #e1e4e8;
    margin: 16px 0;
}

/* Tables */
.chatbot-message-content table,
.ai-chatbot-message table,
.chatbot-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 14px;
}

.chatbot-message-content table th,
.chatbot-message-content table td,
.ai-chatbot-message table th,
.ai-chatbot-message table td,
.chatbot-message table th,
.chatbot-message table td {
    border: 1px solid #e1e4e8;
    padding: 8px 12px;
    text-align: left;
}

.chatbot-message-content table th,
.ai-chatbot-message table th,
.chatbot-message table th {
    background: #f6f8fa;
    font-weight: 600;
}

.chatbot-message-content table tr:nth-child(even),
.ai-chatbot-message table tr:nth-child(even),
.chatbot-message table tr:nth-child(even) {
    background: #f6f8fa;
}

/* Paragraphs */
.chatbot-message-content p,
.ai-chatbot-message p,
.chatbot-message p {
    margin: 8px 0;
    line-height: 1.6;
}

.chatbot-message-content p:first-child,
.ai-chatbot-message p:first-child,
.chatbot-message p:first-child {
    margin-top: 0;
}

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

/* Task Lists */
.chatbot-message-content input[type="checkbox"],
.ai-chatbot-message input[type="checkbox"],
.chatbot-message input[type="checkbox"] {
    margin-right: 6px;
}

.chatbot-message-content .task-list-item,
.ai-chatbot-message .task-list-item,
.chatbot-message .task-list-item {
    list-style-type: none;
}

/* Inline Elements */
.chatbot-message-content mark,
.ai-chatbot-message mark,
.chatbot-message mark {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 2px;
}

.chatbot-message-content kbd,
.ai-chatbot-message kbd,
.chatbot-message kbd {
    background: #fafbfc;
    border: 1px solid #d1d5da;
    border-bottom-color: #c6cbd1;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 #c6cbd1;
    color: #444d56;
    display: inline-block;
    font-family: monospace;
    font-size: 11px;
    line-height: 10px;
    padding: 3px 5px;
    vertical-align: middle;
}

/* Nested Elements Spacing */
.chatbot-message-content ul li > ul,
.chatbot-message-content ul li > ol,
.chatbot-message-content ol li > ul,
.chatbot-message-content ol li > ol,
.ai-chatbot-message ul li > ul,
.ai-chatbot-message ul li > ol,
.ai-chatbot-message ol li > ul,
.ai-chatbot-message ol li > ol,
.chatbot-message ul li > ul,
.chatbot-message ul li > ol,
.chatbot-message ol li > ul,
.chatbot-message ol li > ol {
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Ensure proper text wrapping */
.chatbot-message-content,
.ai-chatbot-message,
.chatbot-message {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Images in messages */
.chatbot-message-content img,
.ai-chatbot-message img,
.chatbot-message img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

/* Details/Summary (collapsible sections) */
.chatbot-message-content details,
.ai-chatbot-message details,
.chatbot-message details {
    margin: 8px 0;
}

.chatbot-message-content summary,
.ai-chatbot-message summary,
.chatbot-message summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
    user-select: none;
}

.chatbot-message-content summary:hover,
.ai-chatbot-message summary:hover,
.chatbot-message summary:hover {
    color: #0066cc;
}

/* Footnotes */
.chatbot-message-content .footnote-ref,
.ai-chatbot-message .footnote-ref,
.chatbot-message .footnote-ref {
    font-size: 12px;
    vertical-align: super;
    margin-left: 2px;
}

.chatbot-message-content .footnotes,
.ai-chatbot-message .footnotes,
.chatbot-message .footnotes {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid #e1e4e8;
    font-size: 13px;
    color: #666;
}

/* Abbreviations */
.chatbot-message-content abbr,
.ai-chatbot-message abbr,
.chatbot-message abbr {
    text-decoration: underline dotted;
    cursor: help;
}

/* Subscript and Superscript */
.chatbot-message-content sub,
.ai-chatbot-message sub,
.chatbot-message sub {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
    bottom: -0.25em;
}

.chatbot-message-content sup,
.ai-chatbot-message sup,
.chatbot-message sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
    top: -0.5em;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chatbot-message-content h1,
    .ai-chatbot-message h1,
    .chatbot-message h1 {
        font-size: 20px;
    }
    
    .chatbot-message-content h2,
    .ai-chatbot-message h2,
    .chatbot-message h2 {
        font-size: 18px;
    }
    
    .chatbot-message-content h3,
    .ai-chatbot-message h3,
    .chatbot-message h3 {
        font-size: 16px;
    }
    
    .chatbot-message-content pre,
    .ai-chatbot-message pre,
    .chatbot-message pre {
        font-size: 12px;
        padding: 8px;
    }
    
    .chatbot-message-content table,
    .ai-chatbot-message table,
    .chatbot-message table {
        font-size: 12px;
    }
}

/* Dark Mode Support (if chatbot has dark mode) */
@media (prefers-color-scheme: dark) {
    .chatbot-dark-mode .chatbot-message-content,
    .chatbot-dark-mode .ai-chatbot-message,
    .chatbot-dark-mode .chatbot-message {
        color: #e1e4e8;
    }
    
    .chatbot-dark-mode .chatbot-message-content h1,
    .chatbot-dark-mode .chatbot-message-content h2,
    .chatbot-dark-mode .chatbot-message-content h3,
    .chatbot-dark-mode .chatbot-message-content h4,
    .chatbot-dark-mode .chatbot-message-content h5,
    .chatbot-dark-mode .chatbot-message-content h6,
    .chatbot-dark-mode .ai-chatbot-message h1,
    .chatbot-dark-mode .ai-chatbot-message h2,
    .chatbot-dark-mode .ai-chatbot-message h3,
    .chatbot-dark-mode .ai-chatbot-message h4,
    .chatbot-dark-mode .ai-chatbot-message h5,
    .chatbot-dark-mode .ai-chatbot-message h6 {
        color: #f0f6fc;
        border-color: #30363d;
    }
    
    .chatbot-dark-mode .chatbot-message-content code,
    .chatbot-dark-mode .ai-chatbot-message code {
        background: #161b22;
        border-color: #30363d;
        color: #e1e4e8;
    }
    
    .chatbot-dark-mode .chatbot-message-content pre,
    .chatbot-dark-mode .ai-chatbot-message pre {
        background: #161b22;
        border-color: #30363d;
    }
    
    .chatbot-dark-mode .chatbot-message-content blockquote,
    .chatbot-dark-mode .ai-chatbot-message blockquote {
        border-color: #30363d;
        background: #161b22;
        color: #8b949e;
    }
    
    .chatbot-dark-mode .chatbot-message-content a,
    .chatbot-dark-mode .ai-chatbot-message a {
        color: #58a6ff;
    }
    
    .chatbot-dark-mode .chatbot-message-content a:hover,
    .chatbot-dark-mode .ai-chatbot-message a:hover {
        color: #79c0ff;
    }
}

