/*
 * Syntax Highlighting CSS
 * 
 * ONLY syntax highlighting, code blocks, tables, and content formatting
 * NO bubble styling - that's handled in message-bubbles.css
 */

/* ==================== CODE BLOCKS & SYNTAX HIGHLIGHTING ==================== */

/* Code blocks */
pre {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
    font-size: 14px;
    line-height: 1.45;
    margin: 8px 0;
}

.dark pre {
    background: #0d1117;
    border-color: #30363d;
    color: #f0f6fc;
}

/* Inline code */
code {
    background: rgba(175, 184, 193, 0.2);
    padding: 0.15em 0.3em;
    border-radius: 4px;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
    font-size: 85%;
}

.dark code {
    background: rgba(110, 118, 129, 0.4);
    color: #f0f6fc;
}

/* Ensure code in pre doesn't get double background */
pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Language-specific styling for Markdig code blocks */
.language-javascript, .language-js {
    color: #24292f;
}

.dark .language-javascript, .dark .language-js {
    color: #f0f6fc;
}

.language-typescript, .language-ts {
    color: #24292f;
}

.dark .language-typescript, .dark .language-ts {
    color: #f0f6fc;
}

.language-python {
    color: #24292f;
}

.dark .language-python {
    color: #f0f6fc;
}

.language-csharp, .language-cs {
    color: #24292f;
}

.dark .language-csharp, .dark .language-cs {
    color: #f0f6fc;
}

/* ==================== PRISM.JS TOKEN STYLING ==================== */

/* Keywords */
.token.keyword,
.token.operator,
.token.important {
    color: #d73a49;
    font-weight: bold;
}

.dark .token.keyword,
.dark .token.operator,
.dark .token.important {
    color: #ff7b72;
}

/* Strings */
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
    color: #032f62;
}

.dark .token.string,
.dark .token.char,
.dark .token.attr-value,
.dark .token.regex,
.dark .token.variable {
    color: #a5d6ff;
}

/* Comments */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #6a737d;
    font-style: italic;
}

.dark .token.comment,
.dark .token.prolog,
.dark .token.doctype,
.dark .token.cdata {
    color: #8b949e;
}

/* Numbers */
.token.number,
.token.boolean,
.token.constant,
.token.symbol,
.token.deleted {
    color: #005cc5;
}

.dark .token.number,
.dark .token.boolean,
.dark .token.constant,
.dark .token.symbol,
.dark .token.deleted {
    color: #79c0ff;
}

/* Functions */
.token.function,
.token.class-name,
.token.maybe-class-name {
    color: #6f42c1;
}

.dark .token.function,
.dark .token.class-name,
.dark .token.maybe-class-name {
    color: #d2a8ff;
}

/* Properties */
.token.property,
.token.tag,
.token.selector,
.token.attr-name,
.token.namespace,
.token.builtin {
    color: #22863a;
}

.dark .token.property,
.dark .token.tag,
.dark .token.selector,
.dark .token.attr-name,
.dark .token.namespace,
.dark .token.builtin {
    color: #7ee787;
}

/* Punctuation */
.token.punctuation {
    color: #24292f;
}

.dark .token.punctuation {
    color: #f0f6fc;
}

/* ==================== TABLES ==================== */

/* Professional table styling with row highlighting */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark table {
    background: #1f2937;
}

@media (min-width: 768px) {
    table {
        display: table;
        white-space: normal;
    }
}

th, td {
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    text-align: left;
    font-size: 0.875rem;
    line-height: 1.4;
}

.dark th, .dark td {
    border-color: #374151;
}

th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #374151;
    position: sticky;
    top: 0;
    z-index: 10;
}

.dark th {
    background-color: #111827;
    color: #e5e7eb;
}

/* Row highlighting like legacy app */
tbody tr {
    transition: background-color 0.15s ease-in-out;
}

tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.dark tbody tr:nth-child(even) {
    background-color: #1f2937;
}

tbody tr:hover {
    background-color: #e0f2fe !important;
    cursor: pointer;
}

.dark tbody tr:hover {
    background-color: #1e3a8a !important;
}

/* Enhanced table borders */
table th:first-child,
table td:first-child {
    border-left: none;
}

table th:last-child,
table td:last-child {
    border-right: none;
}

table thead tr:first-child th {
    border-top: none;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ==================== CONTENT FORMATTING ==================== */

/* Headers in messages */
.msg-text h1,
.msg-text h2,
.msg-text h3,
.msg-text h4,
.msg-text h5,
.msg-text h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.25;
    color: #1f2937;
}

.dark .msg-text h1,
.dark .msg-text h2,
.dark .msg-text h3,
.dark .msg-text h4,
.dark .msg-text h5,
.dark .msg-text h6 {
    color: #f9fafb;
}

.msg-text h1:first-child,
.msg-text h2:first-child,
.msg-text h3:first-child,
.msg-text h4:first-child,
.msg-text h5:first-child,
.msg-text h6:first-child {
    margin-top: 0;
}

.msg-text h1 { 
    font-size: 1.5em; 
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 4px;
}

.dark .msg-text h1 {
    border-bottom-color: #374151;
}

.msg-text h2 { 
    font-size: 1.25em;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 2px;
}

.dark .msg-text h2 {
    border-bottom-color: #374151;
}

.msg-text h3 { font-size: 1.125em; }
.msg-text h4 { font-size: 1em; }
.msg-text h5 { font-size: 0.875em; }
.msg-text h6 { font-size: 0.85em; }

/* Paragraph spacing */
.msg-text p {
    margin: 8px 0;
    line-height: 1.5;
}

.msg-text p + p {
    margin-top: 12px;
}

/* Lists */
ul, ol {
    margin: 8px 0;
    padding-left: 24px;
}

li {
    margin: 4px 0;
    line-height: 1.5;
}

/* Nested lists */
li ul, li ol {
    margin: 4px 0;
    padding-left: 20px;
}

/* Task lists */
.task-list-item {
    list-style-type: none;
    margin-left: -24px;
    padding-left: 24px;
}

.task-list-item input[type="checkbox"] {
    margin-right: 6px;
    margin-left: -16px;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid #3b82f6;
    margin: 12px 0;
    padding: 12px 16px;
    color: #4b5563;
    background-color: #f8fafc;
    border-radius: 0 6px 6px 0;
    font-style: italic;
}

.dark blockquote {
    border-left-color: #60a5fa;
    color: #d1d5db;
    background-color: #1f2937;
}

/* ==================== LINK STYLING ==================== */

/* Enhanced link styling for better user experience */
.msg-text a {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease-in-out;
    background: linear-gradient(to right, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.1));
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.dark .msg-text a {
    color: #60a5fa;
    background: linear-gradient(to right, rgba(96, 165, 250, 0.1), rgba(96, 165, 250, 0.1));
    border-color: rgba(96, 165, 250, 0.2);
}

/* Hover effects for links */
.msg-text a:hover {
    color: #1d4ed8;
    background: linear-gradient(to right, rgba(37, 99, 235, 0.15), rgba(37, 99, 235, 0.15));
    border-color: rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.dark .msg-text a:hover {
    color: #3b82f6;
    background: linear-gradient(to right, rgba(96, 165, 250, 0.15), rgba(96, 165, 250, 0.15));
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 2px 4px rgba(96, 165, 250, 0.2);
}

/* Link icon indicator */
.msg-text a::after {
    content: "🔗";
    font-size: 0.75em;
    margin-left: 4px;
    opacity: 0.6;
    transition: opacity 0.2s ease-in-out;
}

.msg-text a:hover::after {
    opacity: 1;
}

/* External link icon using FontAwesome */
.msg-text a[href^="http"]::after,
.msg-text a[href^="https"]::after {
    content: "\f35d";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75em;
    margin-left: 4px;
    opacity: 0.6;
    transition: opacity 0.2s ease-in-out;
}

/* Focus states for accessibility */
.msg-text a:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    background: linear-gradient(to right, rgba(37, 99, 235, 0.2), rgba(37, 99, 235, 0.2));
}

.dark .msg-text a:focus {
    outline-color: #60a5fa;
    background: linear-gradient(to right, rgba(96, 165, 250, 0.2), rgba(96, 165, 250, 0.2));
}

/* ==================== REMOVE MARGINS FROM FIRST/LAST ELEMENTS ==================== */

/* Remove margins from first and last elements in message bubbles */
.msg-text > *:first-child {
    margin-top: 0 !important;
}

.msg-text > *:last-child {
    margin-bottom: 0 !important;
}