/* Posts/News Page Styles */

/* Featured Post Styles */
.card-featured {
    border: none;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-featured:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.featured-image-wrapper {
    height: 400px;
    position: relative;
    overflow: hidden;
}

.featured-image-wrapper .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card-featured:hover .featured-image-wrapper .card-img-top {
    transform: scale(1.08);
}

.featured-card-body {
    padding: 2rem;
}

.featured-title {
    font-size: 2rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.featured-title:hover {
    color: #007bff;
}

.featured-excerpt {
    font-size: 1.1rem;
    color: #6c757d;
    line-height: 1.7;
    margin-bottom: 0;
}

.btn-featured {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
}

/* Sidebar Posts Styles */
.sidebar-posts {
    background: #ffffff;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    position: sticky;
    top: 100px;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.sidebar-posts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-post-item {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 1rem;
    transition: all 0.3s ease;
}

.sidebar-post-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sidebar-post-item:hover {
    transform: translateX(5px);
}

.sidebar-post-link {
    display: flex;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.sidebar-post-link:hover {
    text-decoration: none;
    color: inherit;
}

.sidebar-post-image {
    width: 100px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8f9fa;
}

.sidebar-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.sidebar-post-item:hover .sidebar-post-image img {
    transform: scale(1.1);
}

.sidebar-post-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    font-size: 1.5rem;
}

.sidebar-post-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-post-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #212529;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

.sidebar-post-item:hover .sidebar-post-title {
    color: #007bff;
}

.sidebar-post-date {
    color: #6c757d;
    font-size: 0.8rem;
}

/* Modern Search Bar Styles */
.search-container {
    position: relative;
}

.search-wrapper {
    position: relative;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    min-width: 300px;
}

.search-input-group:hover {
    border-color: #007bff;
    box-shadow: 0 4px 20px rgba(0,123,255,0.15);
}

.search-input-group:focus-within {
    border-color: #007bff;
    box-shadow: 0 4px 20px rgba(0,123,255,0.2);
    transform: translateY(-1px);
}

.search-icon {
    color: #6c757d;
    margin-right: 12px;
    font-size: 14px;
}

.search-input {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-size: 14px;
    color: #495057;
    padding: 8px 0;
}

.search-input::placeholder {
    color: #adb5bd;
}

.search-button {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.search-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* Modern Button Styles */
.btn-modern {
    border-radius: 8px;
    font-weight: 500;
    padding: 10px 20px;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.btn-primary.btn-modern {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary.btn-modern:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    color: white;
}

/* Modern Card Styles */
.card-modern {
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-modern:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.card-image-wrapper {
    position: relative;
    overflow: hidden;
    height: 200px;
    background: #f8f9fa;
}

.card-image-wrapper .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card-modern:hover .card-image-wrapper .card-img-top {
    transform: scale(1.1);
}

.card-image-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.badge-modern {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #007bff, #0056b3) !important;
}

.card-title-modern {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    font-size: 1.1rem;
}

.card-title-modern:hover {
    color: #007bff;
}

.card-body {
    padding: 1.5rem;
}

.card-body.d-flex.flex-column {
    min-height: 200px;
}

.post-meta {
    display: flex;
    align-items: center;
}

.post-meta i {
    font-size: 0.875rem;
}

/* Empty State */
.empty-state {
    padding: 3rem 1rem;
}

.empty-icon {
    opacity: 0.5;
    display: block;
    margin: 0 auto;
}

.empty-state h4 {
    color: #495057;
    font-weight: 600;
}

.empty-state p {
    color: #6c757d;
}

/* Text Gradient */
.text-gradient {
    background: linear-gradient(135deg, #007bff, #0056b3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Section Title */
.section-title {
    color: #212529;
    font-weight: 700;
}

.section-title.h2 {
    font-size: 2rem;
}

/* Pagination */
.pagination {
    margin: 0;
}

.page-item .page-link {
    border-radius: 8px;
    margin: 0 4px;
    border: 1px solid #e9ecef;
    color: #495057;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.page-item.active .page-link {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-color: #007bff;
    color: white;
}

.page-item .page-link:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar-posts {
        position: static;
        margin-top: 2rem;
    }
    
    .featured-image-wrapper {
        height: 300px;
    }
    
    .featured-title {
        font-size: 1.75rem;
    }
    
    .featured-excerpt {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .search-input-group {
        min-width: 250px;
    }
    
    .card-image-wrapper {
        height: 180px;
    }
    
    .section-title.h2 {
        font-size: 1.75rem;
    }
    
    .featured-image-wrapper {
        height: 250px;
    }
    
    .featured-card-body {
        padding: 1.5rem;
    }
    
    .featured-title {
        font-size: 1.5rem;
    }
    
    .featured-excerpt {
        font-size: 0.95rem;
    }
    
    .btn-featured {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .sidebar-posts {
        padding: 1.25rem;
    }
    
    .sidebar-post-image {
        width: 80px;
        height: 70px;
    }
    
    .sidebar-post-title {
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .search-input-group {
        min-width: 200px;
    }
    
    .d-flex.flex-column.flex-md-row {
        flex-direction: column !important;
    }
    
    .d-flex.gap-3.align-items-center {
        width: 100%;
        flex-direction: column;
        gap: 1rem !important;
    }
    
    .search-container {
        width: 100%;
    }
    
    .search-input-group {
        width: 100%;
        min-width: auto;
    }
}

/* Post Detail Page Styles */
.post-detail {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
}

.post-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 1.5rem;
}

.post-meta i {
    color: #6c757d;
}

/* Content Styling */
.content {
    line-height: 1.8;
    font-size: 1.05rem;
    color: #495057;
    margin-top: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Ensure proper spacing around content elements */
.content > * {
    margin-bottom: 0.75em;
}

.content > *:last-child {
    margin-bottom: 0;
}

/* Better spacing for paragraphs after images */
.content .image-grid + p,
.content .image-grid + * {
    margin-top: 1em;
    clear: both;
}

/* Reduce spacing for consecutive paragraphs */
.content p + p {
    margin-top: 0.5em;
}

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: #212529;
    font-weight: 600;
}

/* Reduce spacing for headings that only contain images */
.content h1:has(img):not(:has(*:not(img))),
.content h2:has(img):not(:has(*:not(img))),
.content h3:has(img):not(:has(*:not(img))),
.content h4:has(img):not(:has(*:not(img))),
.content h5:has(img):not(:has(*:not(img))),
.content h6:has(img):not(:has(*:not(img))) {
    margin-top: 0.75em;
    margin-bottom: 0.5em;
}

/* Remove margin for empty headings */
.content h1:empty,
.content h2:empty,
.content h3:empty,
.content h4:empty,
.content h5:empty,
.content h6:empty {
    margin: 0;
    padding: 0;
    height: 0;
    line-height: 0;
    overflow: hidden;
}

/* Remove margin for headings with only <br> */
.content h1:has(br:only-child),
.content h2:has(br:only-child),
.content h3:has(br:only-child),
.content h4:has(br:only-child),
.content h5:has(br:only-child),
.content h6:has(br:only-child) {
    margin: 0;
    padding: 0;
    height: 0;
    line-height: 0;
    overflow: hidden;
}

.content h1 { 
    font-size: 2em; 
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5em;
    margin-top: 1.25em;
}

.content h2 { 
    font-size: 1.75em; 
}

.content h3 { 
    font-size: 1.5em; 
}

.content h4 { 
    font-size: 1.25em; 
}

.content h5 { 
    font-size: 1.1em; 
}

.content h6 { 
    font-size: 1em; 
}

.content p {
    margin-bottom: 0.75em;
    text-align: justify;
    line-height: 1.7;
}

/* Clean up paragraphs that only contain images */
.content p:has(img:only-child) {
    margin: 0;
    padding: 0;
}

.content p:has(img) {
    overflow: hidden;
    clear: both;
    margin-bottom: 0;
}

/* Remove extra spacing after image paragraphs */
.content p:has(img) + p {
    margin-top: 0.75em;
}

/* Image Grid Layout (adopted from sekolah-app) */
.image-grid {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0;
}

.image-grid.single {
    grid-template-columns: 1fr;
}

.image-grid.double {
    grid-template-columns: 1fr 1fr;
}

.image-grid.triple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}

.image-grid.triple img:first-child {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.image-grid.triple img:nth-child(2) {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.image-grid.triple img:nth-child(3) {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    justify-self: center;
    max-width: 50%;
}

.image-grid.quad {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}

.image-grid.quad img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.image-grid img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0;
    transition: transform 0.3s ease;
    object-fit: cover;
}

.image-grid img:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}

/* Default image styling (fallback) */
.content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5em auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transition: transform 0.3s ease;
}

.content img:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}

.content ul, .content ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.content li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

.content blockquote {
    border-left: 4px solid #007bff;
    padding: 1em 1.5em;
    margin: 1.5em 0;
    font-style: italic;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 8px;
}

.content a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.content a:hover {
    color: #0056b3;
    border-bottom-color: #0056b3;
}

.content code {
    background: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e83e8c;
}

.content pre {
    background: #f8f9fa;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.content pre code {
    background: none;
    padding: 0;
    color: #495057;
}

/* Image Grid Layout - Legacy support */
.image-grid {
    display: grid;
    gap: 1rem;
    margin: 2em 0;
    clear: both;
}

.image-grid.single {
    grid-template-columns: 1fr;
}

.image-grid.double {
    grid-template-columns: 1fr 1fr;
}

.image-grid.triple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}

.image-grid.triple img:first-child {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.image-grid.triple img:nth-child(2) {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.image-grid.triple img:nth-child(3) {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    justify-self: center;
    max-width: 80%;
}

.image-grid.quad {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, auto);
}

.image-grid img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    object-fit: cover;
}

.image-grid img:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}

/* Comments Section */
.comments-section {
    margin-top: 2rem;
}

.comment-card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.comment-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.comment-card .card-body {
    padding: 1.5rem;
}

.comment-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
}

.comment-card .card-text {
    color: #495057;
    line-height: 1.6;
    margin-top: 0.75rem;
}

.empty-comments {
    padding: 2rem;
}

.empty-icon {
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .post-detail {
        padding: 1.25rem;
    }
    
    .post-title {
        font-size: 1.75rem;
    }
    
    .content {
        font-size: 1rem;
    }
    
    .content p {
        margin-bottom: 0.75em;
        text-align: left;
    }
    
    .content p + p {
        margin-top: 0.5em;
    }
    
    .content h1, .content h2, .content h3 {
        margin-top: 1.25em;
        margin-bottom: 0.625em;
    }
    
    .content img {
        margin: 1.5em 0;
    }
    
    /* Responsive Image Grid (adopted from sekolah-app) */
    .image-grid.double,
    .image-grid.triple,
    .image-grid.quad {
        grid-template-columns: 1fr;
    }

    .image-grid.triple img:nth-child(3) {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
        max-width: 100%;
    }
    
    .image-grid img {
        border-radius: 8px;
    }
}

/* Admin action buttons in post detail */
.post-detail .btn-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.post-detail .btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.post-detail .btn-success {
    background-color: #28a745;
    border-color: #28a745;
}

.post-detail .btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.post-detail .btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

.post-detail .btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

