/* General Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 40px 20px;
    color: #333;
}

/* Main Container with top/bottom bars */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #ffffff;
    padding: 20px;
    border-top: 5px solid #333;
    border-bottom: 5px solid #333;
}

/* Header on Public Page */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.page-header h1 {
    margin: 0;
    font-size: 28px;
}

.button-primary {
    background-color: #007bff;
    color: white;
    padding: 10px 18px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease;
}
.button-primary:hover {
    background-color: #0056b3;
}
.button-primary i {
    margin-right: 5px;
}


/* User Info and Logout (for Dashboard) */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    color: #555;
}

.user-info strong {
    color: #333;
}

.logout-button {
    background-color: #dc3545;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.logout-button:hover {
    background-color: #c82333;
}

/* Dashboard Specific */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.dashboard-header h1 {
    margin: 0;
}

.posts-table-container {
    overflow-x: auto;
}
.posts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.posts-table th, .posts-table td {
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: left;
}
.posts-table th {
    background-color: #f4f4f4;
}
.posts-table tr:nth-child(even) {
    background-color: #f9f9f9;
}
.action-btn {
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    margin-right: 5px;
}
.action-btn i {
    margin-right: 4px;
}
.edit-btn {
    background-color: #28a745;
}
.edit-btn:hover {
    background-color: #218838;
}
.delete-btn {
    background-color: #dc3545;
}
.delete-btn:hover {
    background-color: #c82333;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 20px;
}
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 20px;
}


/* Responsive Grid Layout (for public index.php) */
.blog-grid {
    padding-top: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for mobile */
    gap: 20px;
}

/* On tablets and larger, use auto-fill */
@media (min-width: 768px) {
    .blog-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 30px;
    }
}


/* Post Card Link */
.post-card-link {
    text-decoration: none;
    color: inherit;
}

/* Blog Post Card */
.blog-post-card {
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid #eee;
}

.blog-post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Image container */
.post-image-container {
    position: relative;
}

.post-image-container img {
    width: 100%;
    height: 200px; /* Give a fixed height to the images in the grid */
    object-fit: cover; /* Crop images to fit */
    display: block;
}

/* Category Tag on Image */
.category-tag {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: #f1c40f;
    color: #141414;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Post Content Area */
.post-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.post-content h2 {
    font-size: 20px;
    margin: 0 0 15px 0;
    line-height: 1.3;
}

/* Post Meta (author, date, comments) */
.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    color: #6c757d;
    font-size: 13px;
    margin-bottom: 15px;
    align-items: center;
}

.post-meta i {
    margin-right: 5px;
    color: #888;
}

/* Excerpt */
.post-content p {
    font-size: 15px;
    line-height: 1.6;
    color: #495057;
    margin: 0;
    flex-grow: 1;
}


/* Single Post Page (post.php) */
.single-post-container {
    max-width: 800px;
    margin: 20px auto 0 auto;
}
.post-full-title {
    font-size: 42px;
    margin-bottom: 20px;
    line-height: 1.2;
}
.post-full-image {
    margin-bottom: 30px;
}
.post-full-image img {
    width: 100%;
    max-height: 450px;
    object-fit: cover;
    border-radius: 5px;
}
.post-full-content {
    font-size: 18px;
    line-height: 1.8;
    color: #333;
}
.back-link {
    display: inline-block;
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}
.back-link:hover {
    text-decoration: underline;
}
.back-link i {
    margin-right: 5px;
}

/* Tab Interface for Post Editor */
.tab-nav {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 16px;
    color: #555;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* Align with the container's border */
}

.tab-button.active {
    color: #007bff;
    border-bottom-color: #007bff;
    font-weight: bold;
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* CKEditor adjustments */
.ck-editor__editable_inline {
    min-height: 200px;
    max-height: 400px; /* Sesuaikan tinggi maksimum sesuai kebutuhan */
    overflow-y: auto;
    border: 1px solid #ddd; /* Tambahkan border agar terlihat seperti textarea */
    padding: 10px;
    border-radius: 4px;
    background-color: #fff;
}
/* Toolbar fix for placement */
.ck.ck-editor__top {
    position: sticky;
    top: 0;
    z-index: 1000; /* Pastikan toolbar selalu di atas */
    background: #f8f8f8; /* Background untuk toolbar */
    border-bottom: 1px solid #ddd;
}

/* Mobile specific adjustments */
@media (max-width: 767px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .button-primary {
        padding: 8px 12px;
        font-size: 14px;
    }

    .action-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .blog-post-card .post-content h2 {
        font-size: 16px; /* Smaller title for mobile */
        margin-bottom: 10px;
    }
    .blog-post-card .post-content p {
        /* Truncate to 2 lines */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 13px; /* Smaller text for mobile */
        line-height: 1.4;
        flex-grow: 0; /* Override flex-grow to ensure consistent height */
    }

    .post-image-container img {
        height: 100px; /* Set height to 100px for mobile */
    }

    .post-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

.post-full-content p {
    text-indent: 40px;
}

/* Pagination Styling */
.pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    user-select: none;
}
.pagination a, .pagination span {
    color: #007bff;
    padding: 10px 18px;
    text-decoration: none;
    border: 1px solid #dee2e6;
    transition: background-color .3s, color .3s;
    border-radius: 5px;
    font-weight: 500;
}
.pagination a:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}
.pagination span.disabled {
    color: #a0a0a0;
    background-color: #f8f9fa;
    cursor: not-allowed;
    border-color: #f0f2f5;
}
.pagination a.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    cursor: default;
}
.pagination a.active:hover {
    background-color: #0056b3;
}

/* Status Badge Styling */
.status-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    color: white;
}
.status-draft {
    background-color: #6c757d;
}
.status-pending {
    background-color: #ffc107;
    color: #333;
}
.status-published {
    background-color: #28a745;
}
.status-admin {
    background-color: #dc3545;
}
.status-editor {
    background-color: #007bff;
}
.status-kontributor {
    background-color: #6c757d;
}
