/* ==================================================================================
   BLOG PAGES - Enhanced UX/UI Styles
   
   Modern, professional blog design with improved readability, animations, and UX
   ================================================================================== */

/* ==================================================================================
   BLOG INDEX PAGE - Card Grid & Layout
   ================================================================================== */

/* Blog Card Enhancements */
.blog-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.blog-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(26, 54, 93, 0.1);
}

.blog-card img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-card:hover img {
    transform: scale(1.05);
}

/* Featured Article Enhancements */
.blog-featured-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: none;
    position: relative;
}

.blog-featured-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(26, 54, 93, 0.02) 0%, rgba(56, 178, 172, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.blog-featured-card:hover::before {
    opacity: 1;
}

/* Reading Time Badge */
.reading-time {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(26, 54, 93, 0.05);
    border-radius: 20px;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.reading-time i {
    font-size: 0.875rem;
}

/* Category Pills */
.blog-category {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    background: linear-gradient(135deg, #1a365d 0%, #38b2ac 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.blog-category:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
}

/* Author Avatar */
.blog-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a365d 0%, #38b2ac 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.blog-card:hover .blog-author-avatar {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
}

/* Blog Grid Layout */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* ==================================================================================
   BLOG POST PAGE - Enhanced Reading Experience
   ================================================================================== */

/* Blog Post Page - Account for fixed navbar */
.blog-post-page {
    padding-top: 90px; /* Account for fixed navbar height */
    min-height: 100vh;
}

.blog-post-page .container {
    padding-top: 2rem !important;
}

/* Ensure reading progress bar is visible above navbar */
.reading-progress-bar {
    z-index: 1051 !important; /* Higher than navbar z-index */
}

/* Responsive navbar spacing */
@media (max-width: 768px) {
    .blog-post-page {
        padding-top: 70px; /* Smaller padding on mobile */
    }
}

/* Article Header */
.blog-post-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e9ecef;
}

.blog-post-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: #1a202c !important;
    letter-spacing: -0.02em;
}

/* Ensure title is always dark, even on gradient backgrounds */
.blog-post header .blog-post-title,
.blog-post-header .blog-post-title {
    color: #1a202c !important;
}

.blog-post-subtitle {
    font-size: 1.25rem;
    color: #6b7280;
    font-weight: 400;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.blog-post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    color: #6b7280;
    font-size: 0.95rem;
}

.blog-post-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.blog-post-meta-item i {
    color: #1a365d;
    font-size: 1.1rem;
}

/* Featured Image */
.blog-featured-image {
    width: 100%;
    height: 450px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .blog-featured-image {
        height: 300px;
    }
}

/* Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #1a365d 0%, #38b2ac 100%);
    z-index: 1050;
    transition: width 0.1s ease-out;
}

/* Article Content - Enhanced Typography */
.article-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: #374151;
    max-width: 100%;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    scroll-margin-top: 100px;
    font-weight: 700;
    color: #1a202c;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.article-content h1 {
    font-size: 2.5rem;
    border-bottom: 3px solid #1a365d;
    padding-bottom: 0.75rem;
}

.article-content h2 {
    font-size: 2rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.article-content h3 {
    font-size: 1.625rem;
}

.article-content h4 {
    font-size: 1.375rem;
    color: #4b5563;
}

.article-content p {
    margin-bottom: 1.75rem;
    text-align: justify;
}

.article-content p:first-of-type::first-letter {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    float: left;
    margin-right: 0.5rem;
    margin-top: 0.1rem;
    color: #1a365d;
}

/* Lists */
.article-content ul,
.article-content ol {
    margin-bottom: 1.75rem;
    padding-left: 2rem;
}

.article-content ul {
    list-style-type: none;
}

.article-content ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.article-content ul li::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: #38b2ac;
    font-size: 0.75rem;
    top: 0.35rem;
}

.article-content ol li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

/* Blockquotes */
.article-content blockquote {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-left: 5px solid #38b2ac;
    padding: 1.5rem 2rem;
    margin: 2.5rem 0;
    font-style: italic;
    color: #4b5563;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
}

.article-content blockquote::before {
    content: '"';
    font-size: 4rem;
    position: absolute;
    top: -10px;
    left: 10px;
    color: #38b2ac;
    opacity: 0.2;
    font-family: Georgia, serif;
}

.article-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Code Blocks */
.article-content code {
    background: #f1f3f4;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e53e3e;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 500;
}

.article-content pre {
    background: #1a202c;
    color: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2rem 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    position: relative;
}

.article-content pre code {
    background: transparent;
    color: #f7fafc;
    padding: 0;
    font-size: 0.95rem;
}

/* Tables */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.article-content th,
.article-content td {
    border: 1px solid #e9ecef;
    padding: 1rem;
    text-align: left;
}

.article-content th {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.875rem;
}

.article-content tbody tr {
    transition: background-color 0.2s ease;
}

.article-content tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.article-content tbody tr:hover {
    background-color: #e9ecef;
}

/* Images */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    margin: 2rem 0;
}

/* Links */
.article-content a {
    color: #1a365d;
    text-decoration: underline;
    text-decoration-color: #38b2ac;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.article-content a:hover {
    color: #38b2ac;
    text-decoration-color: #1a365d;
}

/* Callout Boxes */
.article-content .callout {
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 8px;
    border-left: 4px solid;
}

.article-content .callout-info {
    background: #eff6ff;
    border-color: #3b82f6;
}

.article-content .callout-warning {
    background: #fffbeb;
    border-color: #f59e0b;
}

.article-content .callout-success {
    background: #f0fdf4;
    border-color: #10b981;
}

.article-content .callout-danger {
    background: #fef2f2;
    border-color: #ef4444;
}

/* ==================================================================================
   TABLE OF CONTENTS
   ================================================================================== */

.table-of-contents {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.table-of-contents h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.table-of-contents ul li {
    margin-bottom: 0.5rem;
}

.table-of-contents ul li a {
    color: #4b5563;
    text-decoration: none;
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.table-of-contents ul li a:hover {
    background: rgba(26, 54, 93, 0.05);
    color: #1a365d;
    transform: translateX(4px);
}

.table-of-contents ul li a.active {
    background: rgba(26, 54, 93, 0.1);
    color: #1a365d;
    font-weight: 600;
}

/* Nested TOC items */
.table-of-contents ul ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.table-of-contents ul ul li a {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ==================================================================================
   SOCIAL SHARING
   ================================================================================== */

.article-share {
    padding: 2rem 0;
    border-top: 2px solid #e9ecef;
    margin-top: 3rem;
}

.article-share h5 {
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 1rem;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.share-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid;
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.share-button-twitter {
    background: #1DA1F2;
    color: white;
    border-color: #1DA1F2;
}

.share-button-twitter:hover {
    background: #1a8cd8;
}

.share-button-linkedin {
    background: #0077B5;
    color: white;
    border-color: #0077B5;
}

.share-button-linkedin:hover {
    background: #006399;
}

.share-button-copy {
    background: white;
    color: #6b7280;
    border-color: #d1d5db;
}

.share-button-copy:hover {
    background: #f9fafb;
    color: #1a202c;
}

/* ==================================================================================
   RELATED ARTICLES
   ================================================================================== */

.related-articles {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 3px solid #e9ecef;
}

.related-articles h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 2rem;
}

.related-article-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.related-article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1) !important;
}

.related-article-card img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.related-article-card:hover img {
    transform: scale(1.03);
}

/* ==================================================================================
   AUTHOR BIO
   ================================================================================== */

.author-bio {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 2rem;
    margin: 3rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.author-bio-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a365d 0%, #38b2ac 100%);
    color: white;
    font-weight: 700;
    font-size: 2rem;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
}

.author-bio-content h5 {
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 0.5rem;
}

.author-bio-content p {
    color: #6b7280;
    margin-bottom: 0;
    line-height: 1.6;
}

/* ==================================================================================
   TAGS
   ================================================================================== */

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 2rem 0;
}

.article-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(26, 54, 93, 0.05) 0%, rgba(56, 178, 172, 0.05) 100%);
    color: #1a365d;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(26, 54, 93, 0.1);
}

.article-tag:hover {
    background: linear-gradient(135deg, #1a365d 0%, #38b2ac 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.3);
}

/* ==================================================================================
   ANIMATIONS
   ================================================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Staggered animation for cards */
.blog-card:nth-child(1) { animation-delay: 0.1s; }
.blog-card:nth-child(2) { animation-delay: 0.2s; }
.blog-card:nth-child(3) { animation-delay: 0.3s; }
.blog-card:nth-child(4) { animation-delay: 0.4s; }
.blog-card:nth-child(5) { animation-delay: 0.5s; }
.blog-card:nth-child(6) { animation-delay: 0.6s; }

/* Admin Banner Responsiveness */
.alert {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.alert .text-muted {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .alert .btn {
        width: 100%;
        justify-content: center;
    }
    
    .alert .d-flex.gap-2 {
        width: 100%;
    }
}

/* ==================================================================================
   RESPONSIVE DESIGN
   ================================================================================== */

@media (max-width: 992px) {
    /* Center all blog content on tablets */
    .blog-page,
    .blog-page section,
    .blog-page .container,
    .blog-post-header,
    .blog-post-title,
    .blog-post-subtitle,
    .blog-post-meta,
    .article-share h5,
    .related-articles h3,
    .author-bio-content h5 {
        text-align: center !important;
    }
    
    .blog-card,
    .blog-card-body,
    .related-article-card {
        text-align: center !important;
    }
    
    .blog-post-title {
        font-size: 2.5rem;
        color: #1a202c !important;
    }
    
    .article-content {
        font-size: 1.0625rem;
    }
    
    .article-content h1 {
        font-size: 2rem;
    }
    
    .article-content h2 {
        font-size: 1.75rem;
    }
    
    .article-content p:first-of-type::first-letter {
        font-size: 3rem;
    }
}

@media (max-width: 768px) {
    /* Center all blog content on mobile tablets */
    .blog-page,
    .blog-page section,
    .blog-page section *:not(form):not(form *):not(.table):not(.table *),
    .blog-page .container,
    .blog-page .container *:not(form):not(form *):not(.table):not(.table *),
    .blog-post-header,
    .blog-post-header *,
    .blog-post-title,
    .blog-post-subtitle,
    .blog-post-meta,
    .blog-post-meta-item,
    .article-content h1,
    .article-content h2,
    .article-content h3,
    .article-content h4,
    .article-share,
    .article-share *:not(form):not(form *),
    .related-articles,
    .related-articles *:not(form):not(form *),
    .author-bio,
    .author-bio *:not(form):not(form *),
    .blog-card,
    .blog-card *:not(form):not(form *),
    .related-article-card,
    .related-article-card * {
        text-align: center !important;
    }
    
    /* Center meta items */
    .blog-post-meta {
        gap: 1rem;
        font-size: 0.875rem;
        justify-content: center !important;
    }
    
    /* Paragraphs in articles should be centered on mobile */
    .article-content p {
        text-align: center !important;
    }
    
    .article-content {
        font-size: 1rem;
    }
    
    .article-content h1 {
        font-size: 1.75rem;
    }
    
    .article-content h2 {
        font-size: 1.5rem;
    }
    
    .article-content h3 {
        font-size: 1.25rem;
    }
    
    .article-content p:first-of-type::first-letter {
        font-size: 2.5rem;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center !important;
    }
    
    .share-button {
        width: 100%;
        justify-content: center;
    }
    
    .author-bio {
        padding: 1.5rem;
    }
    
    .author-bio-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin: 0 auto;
    }
}

/* ==================================================================================
   ACCESSIBILITY IMPROVEMENTS
   ================================================================================== */

/* Focus styles for keyboard navigation */
.blog-card:focus,
.article-tag:focus,
.share-button:focus,
.table-of-contents a:focus {
    outline: 3px solid #38b2ac;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #1a365d;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .blog-card,
    .article-tag,
    .table-of-contents {
        border: 2px solid currentColor;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reading-progress-bar {
        transition: none;
    }
}

/* Print styles */
@media print {
    .blog-featured-card,
    .blog-card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
    
    .share-buttons,
    .reading-progress-bar {
        display: none;
    }
    
    .article-content {
        font-size: 12pt;
        line-height: 1.5;
    }
}
