/* --- RESET & VARIABLES (Post Detail Scope) --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-light: #f4f6f9;
    --bg-white: #ffffff;
    --brand-blue: #0d6efd;
    --brand-blue-hover: #0b5ed7;
    --brand-gold: #ffc107;
    --text-dark: #111827;
    --text-muted: #666666;
    --border-color: #e5e7eb;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
}

/* --- MAIN LAYOUT (Matches your exact grid percentages) --- */
.container {
    max-width: 1400px;
    margin: 25px auto;
    padding: 0 20px;
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

.main {
    width: 70%;
    display: flex;
    flex-direction: column;
}

/* --- POST DETAIL CARD (Article Card) --- */
.card.post-detail-card {
    background: var(--bg-white);
    padding: 32px;
    margin-bottom: 20px;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
    border: 1px solid #e8edf3;
}

/* Breadcrumb Navigation */
.breadcrumb {
    font-size: 13.5px;
    margin-bottom: 16px;
    color: #64748b;
}

.breadcrumb a {
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb a:hover {
    text-decoration: underline;
    color: #000000;
}

/* Header Section */
.post-header {
    margin-bottom: 20px;
}

.post-main-title {
    font-family: 'Poppins', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 32px;
    line-height: 1.5;
    margin-bottom: 14px;
    color: #0f172a;
    font-weight: 700;
    letter-spacing: 0px;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 9px 12px;
    align-items: center;
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: 14px;
}

.post-category {
    background: #eff6ff;
    color: #2563eb;
    padding: 5px 12px;
    border-radius: 999px;
    font-weight: 600;
    border: 1px solid #dbeafe;
}

/* Optional Featured Image */
.featured-image-wrap {
    margin-bottom: 25px;
    border-radius: 8px;
    overflow: hidden;
}

.featured-image-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

/* Short Description Box */
.short-description {
    background: #f8fafc;
    border-left: 4px solid var(--brand-blue);
    padding: 16px 18px;
    border-radius: 9px;
    margin-bottom: 18px;
    font-size: 15.5px;
    line-height: 1.6;
    color: #334155;
    font-weight: 600;
}

/* Dividers */
.section-divider {
    border: 0;
    height: 1px;
    background: #e5e7eb;
    margin: 18px 0;
}

/* --- RICH CONTENT & TABLE FORMATTING --- */
.post-content {
    font-size: 16.5px;
    line-height: 1.65;
    color: #1e293b;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5 {
    color: #0f172a;
    margin: 24px 0 9px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.post-content h1 {
    font-size: 26px;
    padding-bottom: 7px;
    border-bottom: 1px solid #e5e7eb;
}
.post-content h2 {
    font-size: 22px;
}
.post-content h3 {
    font-size: 19px;
}

.post-content p {
    margin: 0 0 9px;
}

/* Empty blocks are removed in post.php as well; these rules are a safe visual fallback. */
.post-content p:empty,
.post-content p:has(> br:only-child),
.post-content p:has(> br:first-child:last-child) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.post-content ul,
.post-content ol {
    margin: 0 0 10px 24px;
    padding-left: 8px;
}

.post-content li {
    margin-bottom: 4px;
}

.post-content > :first-child { margin-top: 0; }
.post-content > :last-child { margin-bottom: 0; }

/* Keep table spacing compact and consistent. Do not stack margins on figure + table. */
.post-content figure.table {
    width: 100%;
    margin: 16px 0 18px;
    padding: 0;
    overflow-x: auto;
    border: 0;
}

.post-content figure.table + h1,
.post-content figure.table + h2,
.post-content figure.table + h3,
.post-content figure.table + h4,
.post-content figure.table + h5 {
    margin-top: 20px;
}

.post-content table,
.custom-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0 !important;
    background: #fff;
    border: 1px solid #dfe5ec;
    border-radius: 8px;
    overflow: hidden;
}

.post-content table th,
.post-content table td,
.custom-table th,
.custom-table td {
    border: 0;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 13px;
    font-size: clamp(15px, 1.8vw, 16.5px);
    text-align: left;
    vertical-align: middle;
}

.post-content table tr > :last-child,
.custom-table tr > :last-child { border-right: 0; }

.post-content table tbody tr:last-child td,
.custom-table tbody tr:last-child td { border-bottom: 0; }

.post-content table th,
.custom-table th {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
}

.post-content tr:nth-child(even),
.custom-table tr:nth-child(even) {
    background: #fbfcfe;
}

.post-content tr:hover,
.custom-table tr:hover {
    background: #f5f9ff;
}

.post-content a,
.custom-table a {
    color: var(--brand-blue);
    text-decoration: none;
    word-break: break-word;
    font-weight: 600;
}

.post-content a:hover,
.custom-table a:hover {
    color: #000;
    text-decoration: underline;
}

/* Lists / callouts should never create accidental large vertical gaps. */
.post-content blockquote {
    margin: 14px 0;
    padding: 10px 14px;
    border-left: 3px solid #2563eb;
    background: #f8fafc;
    border-radius: 0 7px 7px 0;
}

/* --- RELATED POSTS SECTION --- */
.related-posts {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid #e5e7eb;
}

.related-posts h3 {
    margin-bottom: 12px;
    font-size: 20px;
    color: var(--text-dark);
}

.related-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.related-card {
    background: #f8fafc;
    padding: 13px 15px;
    border-radius: 9px;
    transition: background 0.2s ease, transform 0.2s ease;
    border: 1px solid #f1f5f9;
}

.related-card:hover {
    background: #eef5ff;
    transform: translateX(4px);
}

.related-card a {
    text-decoration: none;
    color: var(--brand-blue);
    font-weight: 600;
    font-size: 16px;
    display: block;
}

.related-card a:hover {
    color: #000000;
    text-decoration: underline;
}

/* --- BUTTON & ERROR STATES --- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--brand-blue);
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s ease;
    margin-top: 10px;
}

.btn:hover {
    background: var(--brand-blue-hover);
}

.error-card {
    text-align: center;
    padding: 50px 20px !important;
}

.error-card h2 {
    color: #dc2626;
    margin-bottom: 12px;
}

.error-card p {
    color: var(--text-muted);
    margin-bottom: 20px;
}


/* ========================================================
   --- TABLET RESPONSIVE (Max-Width: 1024px) --- 
======================================================== */
@media (max-width: 1024px) {
    .container {
        gap: 20px;
        padding: 0 16px;
    }

    .main {
        width: 65%;
    }

    .card.post-detail-card {
        padding: 26px;
    }

    .post-main-title {
        font-size: 29px;
    }

    .post-content {
        font-size: 16px;
    }
}


/* ========================================================
   --- MOBILE RESPONSIVE (Max-Width: 768px & 540px) --- 
======================================================== */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        padding: 0 12px;
        margin: 15px auto;
        gap: 15px;
    }

    .main {
        width: 100%;
    }

    .card.post-detail-card {
        padding: 22px;
    }

    .post-main-title {
        font-size: 24px;
    }
}

@media (max-width: 540px) {
    .container {
        padding: 0 10px;
    }

    .card.post-detail-card {
        padding: 17px;
        border-radius: 10px;
    }

    .breadcrumb {
        font-size: 13px;
        margin-bottom: 15px;
    }

    .post-main-title {
        font-size: 22px;
        margin-bottom: 10px;
    }

    .post-meta {
        gap: 10px;
        font-size: 13px;
        margin-bottom: 18px;
    }

    .short-description {
        padding: 14px;
        font-size: 15px;
        margin-bottom: 20px;
    }

    .post-content {
        font-size: 15px;
        line-height: 1.62;
    }

    .post-content h1 { font-size: 21px; }
    .post-content h2 { font-size: 19px; }
    .post-content h3 { font-size: 17px; }

    /* Makes table scroll smoothly horizontally on small 540px phone screens */
    .post-content figure.table,
    .post-content table,
    .custom-table {
        display: block;
        width: 100% !important;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .post-content table th,
    .post-content table td,
    .custom-table th,
    .custom-table td {
        padding: 9px 10px;
        font-size: 14px;
    }

    .related-card {
        padding: 12px;
    }

    .related-card a {
        font-size: 15px;
    }

    .btn {
        width: 100%;
        text-align: center;
        padding: 12px;
    }
}