/*
  Blog Detail Page - MealPrepBudgeter
  Layout: 75% main content (left), 25% sidebar (right)
*/

/* ===== Blog Detail Layout ===== */
.blog-detail-section {
    padding: 60px 0 100px;
    overflow-x: hidden;
}

.blog-detail-wrapper {
    display: grid;
    grid-template-columns: 3fr 1fr; /* 75% main, 25% sidebar */
    gap: 50px;
    align-items: start;
}

/* ===== Detail Banner with Icon ===== */
.blog-detail-banner {
    position: relative;
    padding: 80px 20px 70px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #1a2d4a 100%);
    text-align: center;
    overflow: hidden;
}

.blog-detail-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("https://images.unsplash.com/photo-1554224155-8d04cb21cd6c?auto=format&fit=crop&q=60&w=1920") center/cover;
    opacity: 0.12;
    z-index: 0;
}

.blog-detail-banner .page-banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(11, 28, 63, 0.9) 0%, rgba(26, 45, 74, 0.88) 100%);
    z-index: 1;
}

.blog-detail-banner .container {
    position: relative;
    z-index: 2;
}

.blog-detail-banner-icon {
    width: 70px;
    height: 70px;
    background: rgba(227, 30, 36, 0.2);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin: 0 auto 24px;
}

.blog-detail-banner h1 {
    font-size: 42px;
    color: var(--white);
    margin-bottom: 16px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.blog-detail-banner h1 span {
    color: var(--primary-color);
}

/* ===== Main Article Content ===== */
.blog-detail-main {
    min-width: 0;
}

.blog-detail-featured-img {
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 36px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
}

.blog-detail-featured-img img {
    width: 100%;
    height: auto;
    display: block;
}

/* Article Meta */
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px 28px;
    align-items: center;
    padding-bottom: 24px;
    margin-bottom: 28px;
    border-bottom: 2px solid #e9ecef;
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--light-text);
}

.article-meta-item i {
    color: var(--primary-color);
    font-size: 16px;
}

.article-meta-item strong {
    color: var(--secondary-color);
}

.article-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.article-meta-tags a {
    padding: 6px 14px;
    background: rgba(227, 30, 36, 0.08);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    border-radius: 30px;
}

.article-meta-tags a:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* Article Content Styling */
.article-content {
    font-size: 17px;
    line-height: 1.85;
}

.article-content h2 {
    font-size: 28px;
    color: var(--secondary-color);
    margin: 48px 0 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid rgba(227, 30, 36, 0.2);
}

.article-content h2:first-of-type {
    margin-top: 0;
}

.article-content h3 {
    font-size: 22px;
    color: var(--secondary-color);
    margin: 36px 0 16px;
}

.article-content p {
    margin-bottom: 20px;
    color: var(--text-color);
}

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

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

.article-content ul {
    list-style: disc;
}

.article-content ol {
    list-style: decimal;
}

.article-content li {
    margin-bottom: 10px;
}

.article-content li::marker {
    color: var(--primary-color);
}

/* Tables - use .table-responsive wrapper for mobile scrolling */
.table-responsive,
.article-content > table {
    width: 100%;
    margin: 28px 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
}

.table-responsive + .table-responsive {
    margin-top: 0;
}

/* Fallback: when article has direct table (no wrapper), allow horizontal scroll */
@media (max-width: 768px) {
    .article-content:has(> table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

.article-content table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
}

.table-responsive table {
    margin: 0;
}

.article-content th,
.article-content td {
    padding: 14px 18px;
    text-align: left;
}

.article-content th {
    background: var(--secondary-color);
    color: var(--white);
    font-weight: 700;
}

.article-content tr:nth-child(even) {
    background: #f8f9fa;
}

.article-content tr:hover {
    background: rgba(227, 30, 36, 0.04);
}

/* Comparison Sections */
.comparison-section {
    margin: 36px 0;
}

.comparison-section h3 {
    margin-bottom: 20px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.comparison-card {
    padding: 24px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e9ecef;
}

.comparison-card h4 {
    font-size: 18px;
    color: var(--secondary-color);
    margin-bottom: 16px;
}

.comparison-card ul {
    margin: 0;
    padding-left: 20px;
}

.comparison-card li {
    margin-bottom: 8px;
}

.comparison-card p {
    margin: 0;
}

@media (max-width: 768px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

/* FAQ Section */
.article-faq {
    margin-top: 48px;
}

.article-faq h2 {
    margin-bottom: 24px;
}

.faq-item {
    background: var(--white);
    border: 2px solid #e9ecef;
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
}

.faq-item:hover {
    border-color: rgba(227, 30, 36, 0.3);
}

.faq-question {
    padding: 20px 24px;
    font-weight: 700;
    font-size: 17px;
    color: var(--secondary-color);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.faq-question i {
    color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 2px;
}

.faq-answer {
    padding: 0 24px 20px 52px;
    color: var(--light-text);
    line-height: 1.75;
}

/* ===== Sidebar ===== */
.blog-detail-sidebar {
    position: sticky;
    top: calc(var(--header-height, 80px) + 24px);
    min-width: 280px;
}

.sidebar-widget {
    background: var(--white);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 28px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.sidebar-widget:last-child {
    margin-bottom: 0;
}

.sidebar-widget h3 {
    font-size: 18px;
    color: var(--secondary-color);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(227, 30, 36, 0.2);
}

/* Sidebar Search */
.sidebar-search-form {
    display: flex;
    gap: 0;
    width: 100%;
    min-width: 0;
}

.sidebar-search-form input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e9ecef;
    border-right: none;
    border-radius: 12px 0 0 12px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}

.sidebar-search-form input:focus {
    border-color: var(--primary-color);
}

.sidebar-search-form input::placeholder {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-search-form button {
    flex-shrink: 0;
    padding: 14px 20px;
    background: var(--primary-color);
    color: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 0 12px 12px 0;
    cursor: pointer;
}

.sidebar-search-form button:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Recent Posts */
.recent-post-item {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}

.recent-post-item:last-child {
    margin-bottom: 0;
}

.recent-post-img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.recent-post-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recent-post-content {
    min-width: 0;
}

.recent-post-content h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--secondary-color);
    line-height: 1.4;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.recent-post-content h4 a:hover {
    color: var(--primary-color);
}

.recent-post-date {
    font-size: 13px;
    color: var(--light-text);
    margin-top: 4px;
}

/* Info Card */
.sidebar-info-card {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #1a2d4a 100%);
    color: var(--white);
    padding: 28px;
    border-radius: 16px;
}

.sidebar-info-card h3 {
    color: var(--white);
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.sidebar-info-card p {
    font-size: 15px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-info-card .btn {
    margin-top: 16px;
}

.sidebar-info-card .btn-outline {
    border-color: var(--white);
    color: var(--white);
}

.sidebar-info-card .btn-outline:hover {
    background: var(--white);
    color: var(--secondary-color);
}

/* Category Card */
.sidebar-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-category-list li {
    margin-bottom: 10px;
}

.sidebar-category-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 10px;
    font-weight: 600;
    color: var(--secondary-color);
}

.sidebar-category-list a:hover {
    background: rgba(227, 30, 36, 0.08);
    color: var(--primary-color);
}

.sidebar-category-list .count {
    font-size: 13px;
    color: var(--light-text);
    font-weight: 500;
}

/* ===== Responsive ===== */

/* Container: keep content contained on desktop, match site container */
.blog-detail-section .container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
}

.blog-detail-wrapper {
    max-width: 100%;
    box-sizing: border-box;
}

.blog-detail-main,
.blog-detail-sidebar {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.article-content {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.article-content a {
    word-break: break-word;
}

.article-content img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 992px) {
    .blog-detail-wrapper {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .blog-detail-sidebar {
        position: static;
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }

    .blog-detail-sidebar .sidebar-widget {
        min-width: 0;
    }

    .blog-detail-banner h1 {
        font-size: 36px;
    }
}

@media (max-width: 768px) {
    .blog-detail-section {
        padding: 40px 0 70px;
    }

    .blog-detail-section .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .blog-detail-banner {
        padding: 60px 16px 50px;
    }

    .blog-detail-banner h1 {
        font-size: 28px;
        line-height: 1.3;
    }

    .blog-detail-featured-img {
        margin-left: -16px;
        margin-right: -16px;
        border-radius: 0;
    }

    .blog-detail-featured-img img {
        width: 100%;
    }

    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding-bottom: 20px;
        margin-bottom: 24px;
    }

    .article-content {
        font-size: 16px;
    }

    .article-content h2 {
        font-size: 22px;
        margin: 36px 0 16px;
    }

    .article-content h3 {
        font-size: 18px;
        margin: 28px 0 12px;
    }

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

    .article-content .table-responsive {
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
        border-radius: 0;
    }

    .article-content table {
        min-width: 400px;
    }

    .article-content th,
    .article-content td {
        padding: 12px 14px;
        font-size: 14px;
    }

    .blog-detail-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar-widget {
        padding: 20px;
    }

    /* Stack search form on tablet and below for better responsiveness */
    .sidebar-search-form {
        flex-direction: column;
    }

    .sidebar-search-form input {
        border-right: 2px solid #e9ecef;
        border-radius: 12px 12px 0 0;
    }

    .sidebar-search-form button {
        border-radius: 0 0 12px 12px;
        width: 100%;
    }

    .faq-question {
        font-size: 15px;
        padding: 16px 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .faq-question i {
        margin-top: 0;
    }

    .faq-answer {
        padding: 0 18px 16px 18px;
        margin-left: 0;
    }

    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .blog-detail-section .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .blog-detail-banner {
        padding: 50px 12px 40px;
    }

    .blog-detail-banner h1 {
        font-size: 24px;
    }

    .blog-detail-banner-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .blog-detail-featured-img {
        margin-left: -12px;
        margin-right: -12px;
    }

    .article-content .table-responsive {
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .article-content table {
        min-width: 300px;
    }

    .article-content th,
    .article-content td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .recent-post-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .recent-post-img {
        width: 100%;
        height: 120px;
    }
}
