/* Blog Post Template Styles */

/* Base Layout */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #fafafa;
    overflow-x: hidden;
}

main {
    flex: 1;
    width: 100%;
}

.blog-post-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    width: 100%;
}

.blog-post-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 50px;
    width: 100%;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    overflow: hidden;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
    flex-shrink: 0;
}

.breadcrumb a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb .separator {
    color: #999;
    user-select: none;
    flex-shrink: 0;
}

.breadcrumb .current {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Blog Meta */
.blog-meta {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.blog-date,
.blog-reading-time {
    color: #666;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.blog-date::before {
    content: "📅";
    font-size: 1.1rem;
}

.blog-reading-time::before {
    content: "⏱️";
    font-size: 1.1rem;
}

/* Main Article Content */
.blog-post-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.blog-article-content {
    max-width: 750px;
    width: 100%;
}

/* Typography - Article Content */
.blog-article-content h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 0.5em;
    letter-spacing: -0.02em;
    color: #1a1a1a;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content h2 {
    font-size: 1.875rem;
    line-height: 1.3;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.75em;
    letter-spacing: -0.015em;
    color: var(--primary-color);
    padding-bottom: 0.3em;
    border-bottom: 3px solid #e8f4f8;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content h3 {
    font-size: 1.5rem;
    line-height: 1.4;
    font-weight: 600;
    margin-top: 1.8em;
    margin-bottom: 0.6em;
    color: #2c3e50;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content h4 {
    font-size: 1.25rem;
    line-height: 1.4;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #2c3e50;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content p {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 1.5em;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Links in Article */
.blog-article-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 2px solid rgba(82, 125, 156, 0.3);
    transition: all 0.3s ease;
    padding-bottom: 1px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content a:hover {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-dark);
    background-color: rgba(82, 125, 156, 0.05);
}

/* Images */
.blog-article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2.5em auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Lists */
.blog-article-content ul,
.blog-article-content ol {
    margin-bottom: 1.75em;
    padding-left: 1.5em;
}

.blog-article-content ul li,
.blog-article-content ol li {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 0.75em;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content ul li {
    list-style-type: none;
    position: relative;
    padding-left: 1.5em;
}

.blog-article-content ul li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.5em;
    position: absolute;
    left: 0;
    top: -0.15em;
}

.blog-article-content ol li {
    list-style-type: decimal;
    list-style-position: outside;
}

/* Nested lists */
.blog-article-content ul ul,
.blog-article-content ol ol,
.blog-article-content ul ol,
.blog-article-content ol ul {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

/* Strong/Bold */
.blog-article-content strong {
    font-weight: 600;
    color: #1a1a1a;
}

/* Emphasis/Italic */
.blog-article-content em {
    font-style: italic;
    color: #34495e;
}

/* Code */
.blog-article-content code {
    font-family: 'Monaco', 'Courier New', monospace;
    background-color: #f5f5f5;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e74c3c;
    border: 1px solid #e0e0e0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content pre {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2em 0;
    border: 1px solid #e0e0e0;
    max-width: 100%;
}

.blog-article-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: #333;
    white-space: pre;
}

/* Blockquote */
.blog-article-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5em;
    margin: 2em 0;
    font-style: italic;
    color: #555;
    background-color: #f8fbfd;
    padding: 1.5em 1.5em 1.5em 2em;
    border-radius: 0 8px 8px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-article-content blockquote p {
    margin-bottom: 0.5em;
}

.blog-article-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal Rule */
.blog-article-content hr {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 3em 0;
}

/* Tables */
.blog-article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 1rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.blog-article-content th,
.blog-article-content td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
}

.blog-article-content th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.blog-article-content tr:hover {
    background-color: #f8fbfd;
}

/* Author Box */
.author-box {
    margin-top: 50px;
    padding: 30px;
    background: linear-gradient(135deg, #f8fbfd 0%, #e8f4f8 100%);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

.author-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.author-link {
    flex-shrink: 0;
    text-decoration: none;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.author-link:hover .author-avatar {
    transform: scale(1.05);
}

.author-name-link {
    text-decoration: none;
}

.author-details h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 600;
    transition: color 0.3s;
}

.author-name-link:hover h3 {
    color: var(--primary-dark);
}

.author-details p {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* Back to Blog Link */
.back-to-blog {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.3s;
    padding: 12px 24px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
}

.back-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(-5px);
}

.back-link span {
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.back-link:hover span {
    transform: translateX(-3px);
}

/* Sidebar */
.blog-sidebar {
    position: relative;
    width: 100%;
}

.sidebar-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    width: 100%;
}

.sidebar-card h3 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

.sidebar-card p {
    font-size: 1rem;
    line-height: 1.6;
    color: #666;
    margin-bottom: 20px;
}

/* Download Card */
.download-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    text-align: center;
}

.download-card h3 {
    color: white;
}

.download-card p {
    color: rgba(255, 255, 255, 0.95);
}

/* Mobile Download Card (appears in place of author box on mobile) */
.mobile-download-card {
    display: none;
}

.app-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.app-buttons a {
    display: inline-block;
    width: 100%;
    max-width: 200px;
}

.app-badge {
    height: 50px;
    width: auto;
    max-width: 100%;
    transition: transform 0.3s;
}

.app-badge:hover {
    transform: translateY(-3px);
}

/* Table of Contents Card */
.toc-card {
    margin-bottom: 20px;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toc-header h3 {
    margin-bottom: 0;
}

/* TOC Toggle Button - Hidden on desktop, visible on mobile */
.toc-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--primary-color);
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.3s;
}

.toc-toggle:hover {
    color: var(--primary-dark);
}

.toc-toggle-icon {
    display: block;
    font-weight: bold;
}

.table-of-contents {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.table-of-contents::-webkit-scrollbar {
    width: 6px;
}

.table-of-contents::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.table-of-contents::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.table-of-contents::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.table-of-contents a {
    display: block;
    padding: 8px 12px;
    color: #666;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.table-of-contents a:hover {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    background-color: #f8fbfd;
    padding-left: 16px;
}

.table-of-contents a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
    background-color: #f8fbfd;
}

/* Tablet Styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .blog-post-wrapper {
        grid-template-columns: 1fr;
    }

    .blog-sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        order: 0;
    }

    .sidebar-card {
        margin-bottom: 0;
    }

    .blog-article-content h1 {
        font-size: 2.25rem;
    }

    .blog-article-content h2 {
        font-size: 1.75rem;
    }
}

/* Desktop Styles (1024px+) */
@media (min-width: 1024px) {
    .blog-post-wrapper {
        grid-template-columns: 1fr 380px;
        gap: 60px;
    }

    .blog-post-content {
        padding: 50px;
    }

    .blog-article-content h1 {
        font-size: 3rem;
    }

    .blog-article-content h2 {
        font-size: 2rem;
    }

    .blog-article-content h3 {
        font-size: 1.625rem;
    }

    .app-buttons {
        flex-direction: row;
        justify-content: center;
    }

    /* Sticky sidebar on desktop */
    .blog-sidebar {
        position: sticky;
        top: 100px;
        align-self: flex-start;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        padding-right: 4px;
    }

    .blog-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .blog-sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .blog-sidebar::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }

    .blog-sidebar::-webkit-scrollbar-thumb:hover {
        background: #999;
    }

    .toc-card {
        margin-bottom: 20px;
    }

    .download-card {
        margin-bottom: 0;
    }
}

/* Mobile Styles */
@media (max-width: 767px) {
    .blog-post-container {
        padding: 20px 16px;
    }

    .blog-post-wrapper {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* TOC appears before content on mobile */
    .blog-sidebar {
        order: -1;
        margin-bottom: 0;
    }

    .blog-post-content {
        padding: 20px 16px;
        border-radius: 8px;
        order: 0;
    }

    .sidebar-card {
        padding: 20px;
        margin-bottom: 16px;
    }

    /* Hide download card in sidebar on mobile */
    .blog-sidebar .download-card {
        display: none;
    }

    /* Hide author box on mobile */
    .author-box {
        display: none;
    }

    /* Show mobile download card in place of author box */
    .mobile-download-card {
        display: block;
        margin-top: 50px;
        padding: 30px 20px;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
        border-radius: 12px;
        color: white;
        text-align: center;
    }

    .mobile-download-card h3 {
        font-size: 1.4rem;
        margin-bottom: 16px;
        font-weight: 700;
        color: white;
    }

    .mobile-download-card p {
        font-size: 1rem;
        line-height: 1.6;
        color: rgba(255, 255, 255, 0.95);
        margin-bottom: 20px;
    }

    /* Show TOC toggle button on mobile */
    .toc-toggle {
        display: block;
    }

    /* TOC collapsed by default on mobile */
    .toc-card .table-of-contents {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        padding-right: 0;
    }

    /* TOC expanded state on mobile */
    .toc-card.toc-expanded .table-of-contents {
        max-height: 500px;
        overflow-y: auto;
        padding-right: 8px;
        transition: max-height 0.3s ease-in;
    }

    /* Rotate toggle icon when expanded */
    .toc-card.toc-expanded .toc-toggle {
        transform: rotate(180deg);
    }

    /* Make TOC header clickable area larger */
    .toc-header {
        cursor: pointer;
        user-select: none;
        padding: 4px 0;
        margin-bottom: 0;
        transition: background-color 0.3s;
        border-radius: 4px;
    }

    .toc-header:hover {
        background-color: rgba(82, 125, 156, 0.05);
    }

    .toc-card.toc-expanded .toc-header {
        margin-bottom: 16px;
    }

    .table-of-contents a {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .blog-article-content {
        max-width: 100%;
    }

    .blog-article-content h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    .blog-article-content h2 {
        font-size: 1.4rem;
        margin-top: 1.5em;
    }

    .blog-article-content h3 {
        font-size: 1.2rem;
    }

    .blog-article-content p,
    .blog-article-content ul li,
    .blog-article-content ol li {
        font-size: 1rem;
        line-height: 1.7;
    }

    .blog-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-bottom: 16px;
    }

    .blog-date,
    .blog-reading-time {
        font-size: 0.9rem;
    }

    .back-to-blog {
        margin-top: 30px;
        padding-top: 20px;
    }

    .back-link {
        width: 100%;
        justify-content: center;
        padding: 10px 20px;
        font-size: 1rem;
    }

    .breadcrumb {
        font-size: 0.85rem;
        gap: 6px;
    }

    /* Better app buttons on mobile */
    .app-buttons {
        gap: 10px;
    }

    .app-buttons a {
        max-width: 180px;
    }

    .app-badge {
        height: 45px;
    }

    /* Better code blocks on mobile */
    .blog-article-content pre {
        padding: 15px;
        font-size: 0.85rem;
    }

    /* Better images on mobile */
    .blog-article-content img {
        margin: 1.5em auto;
        border-radius: 8px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .top-nav,
    .blog-sidebar,
    .back-to-blog,
    footer {
        display: none;
    }

    .blog-post-content {
        box-shadow: none;
        padding: 0;
    }

    .blog-article-content a {
        color: #000;
        text-decoration: underline;
        border: none;
    }

    .blog-article-content img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}