/* Theme Colors */
:root {
    --theme-color: #f40;
    --ai-color: #ff7;
    --white: #fff;
    --light-white: #f5f5f5;
    --dark-white: #d1d9e0;
    --light-gray: #f6f8fa;
    --dark-gray: #666;
    --background: #fff;
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2328;
    background-color: #ffffff;
    font-size: 16px;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

/* Links */
a:any-link {
    color: var(--theme-color);
    text-decoration-line: unset;
    cursor: pointer;
}

a:hover {
    color: var(--theme-color);
    opacity: 0.8;
}

/* Override link color for specific buttons */
a.view-markdown,
a.view-markdown:any-link {
    color: #ffffff !important;
    text-decoration: none !important;
}

/* Layout */
.container {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 0fr 1fr auto;
    grid-template-areas: 
        "header"
        "ask-ai"
        "main"
        "footer";
}

/* Header */
.main-header {
    grid-area: header;
    background: #ffffff;
    border-bottom: 1px solid #d1d9e0;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: relative;
}

.site-title {
    color: var(--theme-color);
    text-decoration: none;
    font-size: 20px;
    font-weight: 600;
}

.logo {
    grid-column: 2;
    padding: 20px;
}

.logo .likeButton {
    height: 60px;
    width: auto;
    cursor: pointer;
    background: transparent;
    border: none;
}

.header-actions {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
}

/* Ask AI Button */
.ask-ai-btn {
    background: var(--theme-color);
    color: var(--white);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    margin: 0;
}

.ask-ai-btn:hover {
    filter: brightness(1.1);
}

.ai-icon {
    font-size: 16px;
    width: 20px;
    height: 20px;
    color: var(--ai-color);
    display: inline-block;
    font-family: 'icomoon' !important;
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* Ask AI Panel */
.ask-ai-panel {
    grid-area: ask-ai;
    background: #f6f8fa;
    border-bottom: 1px solid #d1d9e0;
    padding: 24px;
    overflow: hidden;
}

.ask-ai-panel[style*="block"] {
    display: block !important;
}

.container:has(.ask-ai-panel[style*="block"]) {
    grid-template-rows: auto auto 1fr auto;
}

.ask-ai-content {
    max-width: 1000px;
    margin: 0 auto;
}

.ask-ai-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.ask-ai-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    font-size: 14px;
}

.auth-check {
    background: #f6f8fa;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
}

/* Main Content */
.main-content {
    grid-area: main;
    max-width: 1000px;
    margin: 0 auto;
    /* padding: 24px; */
    padding-top: 80px;
    width: 100%;
}

@media (max-width: 1000px) {
    .main-content {
        /* padding: 20px; */
        padding: 0px;
        max-width: 100%;
    }
}

/* Timeline */
.timeline-container {
    max-width: 600px;
    margin: 0 auto;
}

.timeline-header h2 {
    color: #1f2328;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
}

.timeline-feed {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.timeline-post {
    background: #ffffff;
    border: 1px solid #d1d9e0;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.2s;
}

.timeline-post:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-title a {
    color: var(--theme-color);
    text-decoration: none;
    font-size: 18px;
    font-weight: 600;
}

.post-title a:hover {
    color: var(--theme-color);
}

.post-date {
    color: #656d76;
    font-size: 14px;
}

.post-excerpt {
    color: #656d76;
    margin: 16px 0;
    line-height: 1.5;
}

.post-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.read-more {
    color: var(--theme-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.read-more:hover {
    text-decoration: underline;
}

.view-markdown, .view-translation {
    color: #656d76;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.view-markdown {
    background: var(--theme-color) !important;
    color: #ffffff !important;
    border: 1px solid var(--theme-color);
}

.view-markdown:hover {
    filter: brightness(1.1);
    color: #ffffff !important;
    background: var(--theme-color) !important;
}

.view-translation:hover {
    background: #f6f8fa;
}

.post-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.post-lang {
    background: #f6f8fa;
    color: #656d76;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Article */
.article-container {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 40px;
    max-width: 1000px;
    margin: 0 auto;
}

article.article-content {
    padding: 10px;
}

.article-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.article-date {
    color: #656d76;
    font-size: 14px;
}

.article-lang {
    background: #f6f8fa;
    color: #656d76;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.article-actions {
    display: flex;
    gap: 12px;
    padding: 15px 0;
}

.action-btn {
    color: var(--theme-color);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f6f8fa;
    border-color: var(--theme-color);
}

.markdown-btn {
    background: var(--dark-white);
    color: var(--white);
    border-color: var(--white);
}

.markdown-btn:link,
.markdown-btn:visited {
    color: var(--white) !important;
}

.markdown-btn:hover {
    filter: brightness(0.9);
    color: var(--theme-color) !important;
    border-color: var(--white);
}

/* Sidebar styles */
.article-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.toc {
    background: #f6f8fa;
    border: 1px solid #d1d9e0;
    border-radius: 8px;
    padding: 16px;
}

.toc h3 {
    color: #1f2328;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.toc-list {
    list-style: none;
    padding: 0;
}

.toc-item {
    margin-bottom: 8px;
}

/* Hierarchy indentation for TOC */
.toc-item.toc-h1 .toc-link {
    padding-left: 0;
    font-weight: 600;
    font-size: 14px;
}

.toc-item.toc-h2 .toc-link {
    padding-left: 0;
    font-weight: 500;
    font-size: 14px;
}

.toc-item.toc-h3 .toc-link {
    padding-left: 16px;
    font-weight: 400;
    font-size: 13px;
}

.toc-item.toc-h4 .toc-link {
    padding-left: 32px;
    font-weight: 400;
    font-size: 12px;
    opacity: 0.9;
}

.toc-item.toc-h5 .toc-link {
    padding-left: 48px;
    font-weight: 400;
    font-size: 12px;
    opacity: 0.8;
}

.toc-item.toc-h6 .toc-link {
    padding-left: 64px;
    font-weight: 400;
    font-size: 11px;
    opacity: 0.7;
}

.toc-link {
    color: #656d76;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    display: block;
    padding: 4px 0;
    transition: color 0.2s;
}

.toc-link:hover {
    color: var(--theme-color);
}

.article-title {
    color: #1f2328;
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.25;
}

.article-body {
    color: #1f2328;
    line-height: 1.6;
}

.article-body h1, .article-body h2, .article-body h3 {
    color: #1f2328;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.article-body p {
    margin-bottom: 16px;
}

.article-body ol, .article-body ul {
    margin: 16px 0;
    padding-left: 24px;
}

.article-body li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.article-body ol li {
    list-style-type: decimal;
}

.article-body ul li {
    list-style-type: disc;
}

.article-body pre {
    background: #1B1D1E !important;
    border: 1px solid #3E3D32;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    margin: 16px 0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* File name display for code blocks - top bar style */
.article-body pre[data-filename]::before {
    content: attr(data-filename);
    display: block;
    background: #2D2D30;
    color: #AE81FF;
    padding: 8px 16px;
    font-size: 12px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    border-bottom: 1px solid #3E3D32;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.article-body pre code {
    display: block;
    background: none !important;
    padding: 30px 16px;
    color: #F8F8F2 !important;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    overflow-x: auto;
    line-height: 1.4;
}

/* Adjust padding when filename is present */
.article-body pre[data-filename] code {
    padding: 16px;
}

/* Inline code (not in pre blocks) */
.article-body code {
    background: var(--light-white);
    color: var(--dark-gray);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 13px;
}

/* Molokai syntax highlighting */
.article-body pre code .hljs-keyword { color: #F92672; }
.article-body pre code .hljs-string { color: #E6DB74; }
.article-body pre code .hljs-comment { color: #88846F; font-style: italic; }
.article-body pre code .hljs-number { color: #AE81FF; }
.article-body pre code .hljs-variable { color: #FD971F; }
.article-body pre code .hljs-function { color: #A6E22E; }
.article-body pre code .hljs-tag { color: #F92672; }
.article-body pre code .hljs-attr { color: #A6E22E; }
.article-body pre code .hljs-value { color: #E6DB74; }

/* Fix inline span colors in code blocks */
.article-body pre code span[style*="color:#8fa1b3"] { color: #AE81FF !important; } /* $ prompt */
.article-body pre code span[style*="color:#c0c5ce"] { color: #F8F8F2 !important; } /* commands */
.article-body pre code span[style*="color:#75715E"] { color: #88846F !important; } /* real comments */

/* Shell/Bash specific fixes */
.article-body pre code span[style*="color:#65737e"] { 
    color: #F8F8F2 !important; /* Default to white for variables and code */
}

/* Comments in shell scripts - lines that contain # followed by text */
.article-body pre code span[style*="color:#65737e"]:has-text("#") {
    color: #88846F !important;
}

/* Alternative approach - check content */
.article-body pre code {
    /* Reset all gray colored text to white by default */
}

.article-body pre code span[style*="color:#65737e"] {
    /* Check if the content starts with # */
    color: #F8F8F2 !important;
}

/* Override for actual comments - this is a workaround */
.article-body pre code span[style*="color:#65737e"]:first-child:before {
    content: attr(data-comment);
}

/* Detect comments by position and content pattern */
.article-body pre code span[style*="color:#65737e"] {
    color: #F8F8F2 !important; /* Environment variables = white */
}

/* Only style as comment if the line actually starts with # */
.article-body pre code > span:first-child[style*="color:#65737e"] {
    color: #88846F !important; /* Real comments = gray */
}

/* Footer */
.main-footer {
    grid-area: footer;
    background: var(--light-white);
    border-top: 1px solid #d1d9e0;
    padding: 32px 24px;
    text-align: center;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 40px;
}

.footer-social a {
    color: var(--dark-gray) !important;
    text-decoration: none !important;
    font-size: 16px;
    transition: all 0.2s ease;
}

.footer-social a:hover {
    color: var(--theme-color) !important;
    opacity: 0.8;
}

.main-footer p {
    color: #656d76;
    font-size: 14px;
    margin: 0;
}

/* Chat Messages */
.chat-message.comment-style {
    background: #ffffff;
    border: 1px solid #d1d9e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.chat-message.ai-message.comment-style {
    border-left: 4px solid var(--ai-color);
    background: #faf8ff;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.message-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f6f8fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid #d1d9e0;
}

.display-name {
    font-weight: 600;
    color: #1f2328;
    font-size: 14px;
}

.handle {
    color: #656d76;
    font-size: 13px;
}

.timestamp {
    color: #656d76;
    font-size: 12px;
}

.message-content {
    color: #1f2328;
    line-height: 1.5;
    white-space: pre-wrap;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Loading Animation */
.ai-loading-simple {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 20px;
    margin: 8px 0;
    font-size: 14px;
    color: #495057;
    border: 1px solid #dee2e6;
    animation: slideIn 0.3s ease-out;
}

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

/* Comment System Styles */
.comment-section {
    max-width: 800px;
    margin: 0 auto;
    margin-top: 48px;
    padding-top: 32px;
}

.comment-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.comment-section h3 {
    color: #1f2328;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 32px;
    text-align: center;
}

/* OAuth Comment System - Hide on homepage by default, show on post pages */
.timeline-container .comment-section {
    display: block; /* Show on homepage */
}

.timeline-container .comment-section .comments-list > :nth-child(n+6) {
    display: none; /* Hide comments after the 5th one */
}

.article-container .comment-section,
.article-content + .comment-section {
    display: block; /* Show all comments on post pages */
}

/* Responsive */
@media (max-width: 1000px) {
    .article-container {
        grid-template-columns: 1fr;
        gap: 24px;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
}

@media (max-width: 1000px) {
    .main-header {
        padding: 0px;
    }
    
    .header-content {
        max-width: 100%;
        padding: 0 20px;
        grid-template-columns: auto 1fr auto;
        gap: 0;
    }
    
    /* OAuth app mobile fixes */
    .comment-item {
        padding: 0px !important;
        margin: 0px !important;
    }
    
    .auth-section {
        padding: 0px !important;
    }
    
    .comments-list {
        padding: 0px !important;
    }
    
    .comment-section {
        max-width: 100% !important;
        padding: 0px !important;
        margin: 0px !important;
    }
    
    .comment-container {
        max-width: 100% !important;
        padding: 0px !important;
        margin: 0px !important;
    }
    
    .comment-content {
        padding: 10px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    .comment-header {
        padding: 10px !important;
    }
    
    /* Fix comment-meta URI overflow */
    .comment-meta {
        word-break: break-all !important;
        overflow-wrap: break-word !important;
    }
    
    /* Hide site title text on mobile */
    .site-title {
        display: none;
    }
    
    /* Left align logo on mobile */
    .logo {
        grid-column: 1;
        justify-self: left;
        padding: 5px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    
    /* Reduce logo size on mobile */
    .logo .likeButton {
        width: 40pt;
        height: 40pt;
    }
    
    /* Position AI button on the right */
    .header-actions {
        grid-column: 3;
        justify-self: end;
    }
    
    /* Ask AI button mobile style - icon only */
    .ask-ai-btn {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
        gap: 0;
        font-size: 0; /* Hide all text content */
    }
    
    .ask-ai-btn .ai-icon {
        margin: 0;
        font-size: 16px;
    }
    
    .ask-ai-panel {
        padding: 16px;
    }
    
    /* Article content mobile optimization */
    .article-body {
        overflow-x: hidden;
    }
    
    .article-body pre {
        margin: 16px 0;
        border-radius: 4px;
        max-width: 100%;
        overflow-x: auto;
    }
    
    .article-body pre code {
        padding: 20px 12px;
        word-wrap: break-word;
        white-space: pre-wrap;
    }
    
    /* Mobile filename display */
    .article-body pre[data-filename]::before {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .article-body pre[data-filename] code {
        padding: 12px;
    }
    
    .article-body code {
        word-break: break-all;
    }
    
    .ask-ai-form {
        flex-direction: column;
    }
    
    .timeline-container {
        max-width: 100%;
        padding: 0;
    }
    
    .timeline-post {
        padding: 16px;
    }
    
				.article-title {
					   font-size: 24px;
					   padding: 30px 0px;
				}

    .message-header .avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    /* Center content on mobile */
    body {
        margin: 0;
        padding: 0;
    }
    
    .container {
        width: 100%;
        padding: 0;
    }
}