/* ── Variables ────────────────────────────── */
:root {
    --green:       #16a34a;
    --green-dark:  #15803d;
    --green-deeper:#14532d;
    --green-light: #dcfce7;
    --green-xlight:#f0fdf4;
    --black:       #111827;
    --gray:        #4b5563;
    --gray-mid:    #9ca3af;
    --gray-light:  #e5e7eb;
    --white:       #ffffff;
    --radius:      12px;
    --radius-sm:   8px;
    --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover:0 4px 12px rgba(22,163,74,0.12), 0 2px 4px rgba(0,0,0,0.06);
}

/* ── Page Header ──────────────────────────── */
.blog-page-header {
    background: linear-gradient(135deg, #111827 0%, #14532d 100%);
    color: white;
    padding: 2rem 2.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.blog-page-header h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 0.25rem; color: white; }
.blog-page-header p  { margin: 0; color: #d1fae5; font-size: 0.9rem; }

/* ── Layout ───────────────────────────────── */
.blog-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

.blog-layout-full { max-width: 820px; }

/* ── Post Grid (index) ────────────────────── */
/* Wrapper inside .blog-layout > div turns into a 2-col grid */
.blog-layout > div:first-child {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    align-items: start;
}

/* Full-width empty state / pagination don't stretch as a grid cell */
.blog-empty,
.blog-pagination {
    grid-column: 1 / -1;
}

.post-card-grid-item {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}
.post-card-grid-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* Image wrapper keeps a fixed 16:9 aspect ratio */
.post-card-img-link {
    display: block;
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    overflow: hidden;
    background: var(--green-xlight);
    text-decoration: none;
}

.post-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: transform 0.3s;
}
.post-card-grid-item:hover .post-card-img { transform: scale(1.03); }

.post-card-img-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-xlight);
}

.post-card-body {
    padding: 1rem 1.25rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Legacy .post-card kept for show/edit pages that may reuse it */
.post-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.25rem;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.post-card:hover { box-shadow: var(--shadow-hover); }

.post-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.blog-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.22rem 0.65rem;
    border-radius: 20px;
    background: var(--green-light);
    color: var(--green-deeper);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.post-date { font-size: 0.8rem; color: var(--gray-mid); }

.post-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--black);
    text-decoration: none;
    line-height: 1.4;
    display: block;
    margin-bottom: 0.6rem;
}
.post-title:hover { color: var(--green); }

.post-excerpt {
    font-size: 0.875rem;
    color: var(--gray);
    line-height: 1.6;
    flex: 1;
    margin: 0 0 1rem;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--green-xlight);
    font-size: 0.8rem;
    color: var(--gray-mid);
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-author { font-weight: 500; color: var(--gray); }

/* ── Article (show page) ──────────────────── */
.article-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

.article-hero-img {
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.article-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.25rem;
}

.article-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--black);
    line-height: 1.3;
    margin: 0 0 1rem;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    border-top: 1px solid var(--green-xlight);
    border-bottom: 1px solid var(--green-xlight);
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.article-excerpt {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray);
    line-height: 1.7;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--green-xlight);
    font-style: italic;
}

.article-body {
    font-size: 0.95rem;
    color: var(--black);
    line-height: 1.85;
}

/* ── Prose / TinyMCE HTML output ── */
.article-body.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
    margin: 1.25rem auto;
}
.article-body.prose a {
    color: var(--green);
    text-decoration: underline;
}
.article-body.prose a:hover {
    color: var(--green-dark);
}
.article-body.prose blockquote {
    border-left: 4px solid var(--green);
    margin: 1.5rem 0;
    padding: 0.75rem 1.5rem;
    background: var(--green-xlight);
    border-radius: 0 6px 6px 0;
    color: var(--green-deeper);
    font-style: italic;
}
.article-body.prose pre {
    background: var(--black);
    color: #e2e8f0;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 1rem 0;
}
.article-body.prose h1,
.article-body.prose h2,
.article-body.prose h3,
.article-body.prose h4 {
    color: var(--black);
    margin: 1.75rem 0 0.75rem;
    line-height: 1.3;
    font-weight: 700;
}
.article-body.prose ul,
.article-body.prose ol {
    padding-left: 1.75rem;
    margin: 0.75rem 0;
}
.article-body.prose li { margin-bottom: 0.3rem; }
.article-body.prose table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.article-body.prose td,
.article-body.prose th {
    border: 1px solid var(--gray-light);
    padding: 0.6rem 0.85rem;
}
.article-body.prose th {
    background: var(--green-xlight);
    font-weight: 600;
    color: var(--green-deeper);
}
.article-body.prose figure {
    margin: 1.5rem 0;
    text-align: center;
}
.article-body.prose figcaption {
    font-size: 0.82rem;
    color: var(--gray-mid);
    margin-top: 0.4rem;
}
.article-excerpt {
    font-size: 1.05rem;
    color: var(--gray);
    line-height: 1.65;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--green-xlight);
}
.article-excerpt p { margin: 0; }

.article-tags {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--green-xlight);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.tag-badge {
    font-size: 0.78rem;
    padding: 0.22rem 0.7rem;
    background: var(--green-xlight);
    color: var(--green-dark);
    border-radius: 20px;
    border: 1px solid var(--green-light);
    font-weight: 500;
}

/* ── Comments ─────────────────────────────── */
.comment-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.comment-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-light);
}

.comment-form-wrap {
    background: var(--green-xlight);
    border: 1px solid var(--green-light);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.comment-form-wrap h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 0.75rem;
}

.comment-form-wrap textarea,
.comment-form-wrap input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
    background: white;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.comment-form-wrap textarea:focus,
.comment-form-wrap input[type="text"]:focus { border-color: var(--green); }

.comment-card {
    display: flex;
    gap: 0.875rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--green-xlight);
}
.comment-card:last-child { border-bottom: none; }

.comment-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--green-light);
}

.comment-avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--green-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.comment-author { font-weight: 700; font-size: 0.875rem; color: var(--black); }
.comment-time   { font-size: 0.78rem; color: var(--gray-mid); margin-left: 0.35rem; }
.comment-text   { font-size: 0.875rem; color: var(--gray); line-height: 1.6; margin: 0.3rem 0 0.6rem; }

.reply-list { margin-left: 1rem; }

.reply-card {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--green-xlight);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--green-light);
}

.reply-input-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-left: 1rem;
}

.reply-input-row input {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 0.83rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.reply-input-row input:focus { border-color: var(--green); }

/* ── My Posts ─────────────────────────────── */
.my-post-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s;
}
.my-post-card:hover { box-shadow: var(--shadow-hover); }

.my-post-top {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.my-post-thumb {
    width: 84px;
    height: 62px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--green-light);
}

.my-post-thumb-placeholder {
    width: 84px;
    height: 62px;
    border-radius: var(--radius-sm);
    background: var(--green-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.my-post-info { flex: 1; min-width: 0; }

.my-post-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black);
    text-decoration: none;
}
.my-post-name:hover { color: var(--green); }

.my-post-excerpt {
    font-size: 0.83rem;
    color: var(--gray);
    margin: 0.3rem 0 0.5rem;
    line-height: 1.5;
}

.my-post-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.8rem; color: var(--gray-mid); }

.my-post-actions { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: flex-start; flex-wrap: wrap; }

.my-post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--green-xlight);
    font-size: 0.78rem;
    color: var(--gray-mid);
}

/* ── Status Badge ─────────────────────────── */
.status-badge {
    font-size: 0.72rem;
    padding: 0.18rem 0.55rem;
    border-radius: 20px;
    font-weight: 600;
    display: inline-block;
}
.status-published { background: var(--green-light); color: var(--green-deeper); }
.status-draft     { background: #fef3c7; color: #92400e; }
.status-archived  { background: #f3f4f6; color: #374151; }

/* ── Form ─────────────────────────────────── */
.blog-form {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--green-xlight);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--green-dark);
    margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.875rem; }
.form-group label { font-size: 0.875rem; font-weight: 600; color: var(--black); }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    padding: 0.6rem 0.875rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--green); }

.form-group textarea { resize: vertical; }
.form-hint { font-size: 0.78rem; color: var(--gray-mid); margin: 0; }

.is-invalid { border-color: #ef4444 !important; }
.invalid-feedback { font-size: 0.8rem; color: #ef4444; }

.upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--green-light);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    cursor: pointer;
    text-align: center;
    background: var(--green-xlight);
    transition: border-color 0.2s, background 0.2s;
}
.upload-box:hover { border-color: var(--green); }
.upload-box input[type="file"] { display: none; }
.upload-box-label { font-weight: 600; color: var(--green); font-size: 0.9rem; }
.upload-box-sub   { font-size: 0.78rem; color: var(--gray-mid); margin-top: 0.25rem; }

.current-image-preview {
    margin-bottom: 0.5rem;
}
.current-image-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--green-light);
}

/* ── Sidebar ──────────────────────────────── */
.blog-sidebar { display: flex; flex-direction: column; gap: 1rem; }

.sidebar-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.sidebar-card h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--black);
    margin: 0 0 0.875rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-light);
}

.sidebar-cat-link {
    display: block;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--green-xlight);
    font-size: 0.875rem;
    color: var(--gray);
    text-decoration: none;
    transition: color 0.15s;
}
.sidebar-cat-link:hover { color: var(--green); }
.sidebar-cat-link:last-child { border-bottom: none; }

.sidebar-post-item {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--green-xlight);
}
.sidebar-post-item:last-child { border-bottom: none; }
.sidebar-post-item a {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--black);
    text-decoration: none;
    display: block;
    line-height: 1.4;
    margin-bottom: 0.2rem;
}
.sidebar-post-item a:hover { color: var(--green); }
.sidebar-post-item small { font-size: 0.78rem; color: var(--gray-mid); }

/* ── Empty State ──────────────────────────── */
.blog-empty {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.blog-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.blog-empty h3   { font-size: 1.2rem; font-weight: 700; color: var(--black); margin: 0 0 0.5rem; }
.blog-empty p    { color: var(--gray-mid); font-size: 0.9rem; margin: 0 0 1.25rem; }

/* ── Pagination ───────────────────────────── */
.blog-pagination {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.blog-pagination a,
.blog-pagination strong,
.blog-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}
.blog-pagination a      { color: var(--green); border: 1px solid var(--green-light); background: var(--white); }
.blog-pagination a:hover{ background: var(--green-light); }
.blog-pagination strong { background: var(--green); color: white; border: 1px solid var(--green); }

/* ── Buttons ──────────────────────────────── */
.btn-green {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--green);
    color: white;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-green:hover { background: var(--green-dark); color: white; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    color: var(--green);
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    border: 2px solid var(--green-light);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-outline:hover { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: #ef4444;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    border: 2px solid #fecaca;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ── Share Button ─────────────────────────── */
.blog-share-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: var(--green-xlight);
    color: var(--green-dark);
    border: 1px solid var(--green-light);
    border-radius: 6px;
    padding: .28rem .65rem;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.blog-share-btn:hover { background: var(--green-light); border-color: var(--green); }

/* ── Back Link ────────────────────────────── */
.back-link {
    color: var(--green);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 1rem;
}
.back-link:hover { text-decoration: underline; }

/* ── Alert ────────────────────────────────── */
.alert-success {
    background: var(--green-light);
    border: 1px solid var(--green);
    color: var(--green-deeper);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ── Section Block ────────────────────────── */
.section-block {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.section-block h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--green-light);
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 1024px) {
    .blog-layout { grid-template-columns: 1fr; }
    .blog-sidebar { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
}

@media (max-width: 900px) {
    .article-layout { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    /* Single column on small screens */
    .blog-layout > div:first-child { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .blog-page-header { padding: 1.5rem 1rem; }
    .blog-page-header h1 { font-size: 1.4rem; }
    .my-post-top { flex-wrap: wrap; }
    .article-card { padding: 1.25rem; }
    .article-title { font-size: 1.3rem; }
    .blog-sidebar { grid-template-columns: 1fr; }
}
