/* blog-admin.css - Professional and Integrated with main styles.css */

/*
   This stylesheet focuses on specific layouts and components for the blog admin
   interface, relying heavily on variables and base styles defined in styles.css.
*/

/* ========== Admin Container (Main Wrapper for Admin Content) ========== */
/* This ensures the admin panel itself appears as a central, well-defined card-like block */
.admin-container {
    max-width: 1000px; /* Slightly wider admin content area for forms/tables */
    margin: 40px auto; /* Consistent top/bottom margin and center */
    background: var(--surface);
    padding: 30px; /* Generous internal padding */
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-m);
    border: 1px solid var(--border);
}
@media (max-width: 768px) {
    .admin-container {
        margin: 20px 16px; /* Adjust margins for smaller screens */
        padding: 20px;
    }
}


/* ========== Auth Section (Admin Login Form) ========== */
/* Specific styling for the login card on the blog admin page */
.admin-login-card {
    max-width: 460px; /* Keep login form narrow and centered */
    margin: 40px auto;
    padding: 24px; /* Internal padding for the login card body */
    text-align: center;
}
.admin-login-card .auth-card-header { /* Style the header of the login card */
    padding-bottom: 24px; /* More space below title */
}
.admin-login-card h1 { /* Title within the login card header */
    font-size: 2em; /* Larger title for login page */
    margin-bottom: 0;
}
.admin-login-card .auth-card-body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px; /* Space out elements */
}
.admin-login-card input {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.admin-login-card input:focus {
    border-color: var(--brand-primary);
    box-shadow: var(--focus);
}
.admin-login-card .button {
    width: 100%; /* Full width buttons */
    margin-top: 8px; /* Space above buttons */
}
#authStatus {
    margin-top: 15px;
    color: var(--text-secondary);
    font-size: 0.9em;
    padding: 8px 12px;
    background-color: var(--bg);
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    text-align: center;
}
#authStatus.success {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--success);
}
#authStatus.error {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}


/* ========== Section Headings within Admin Content ========== */
/* Rely on body/h1 styles from styles.css for main page title. */
.admin-container h1 {
    text-align: center;
    font-size: 2.2em; /* Main title for the admin page after login */
    margin-bottom: 30px;
}
.admin-container h2 {
    margin-top: 40px; /* Consistent top margin for sections */
    margin-bottom: 20px;
    font-size: 1.8em;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}


/* ========== Separator Line ========== */
hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 40px 0; /* Consistent spacing between major blocks */
}


/* ========== Blog List Table ========== */
.blog-list table {
    width: 100%;
    border-collapse: separate; /* Allows border-radius on cells */
    border-spacing: 0; /* Remove default spacing */
    margin-top: 20px;
    background: var(--surface);
    border-radius: var(--radius-m);
    overflow: hidden; /* Ensures rounded corners apply correctly */
    border: 1px solid var(--border);
    box-shadow: var(--shadow-s);
}
.blog-list th, .blog-list td {
    padding: 12px 15px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.blog-list th {
    background-color: var(--bg); /* Light background for header */
    font-weight: bold;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}
.blog-list tbody tr:last-child td {
    border-bottom: none; /* No bottom border for last row */
}
.blog-list td {
    color: var(--text-secondary);
    font-size: 0.9em;
}
.blog-list td span { /* For status spans like 'Published'/'Draft' */
    font-weight: 600;
}
.blog-list td button {
    margin-right: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-s);
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.blog-list td button:active { transform: translateY(1px); }

/* Specific button styles for actions in table */
.blog-list td button.edit { background-color: var(--brand-secondary-light); color: var(--text-primary); }
.blog-list td button.edit:hover { background-color: var(--brand-secondary); color: white; }
.blog-list td button.delete { background-color: var(--danger); color: white; }
.blog-list td button.delete:hover { background-color: #c82333; }
.blog-list td button.publish { background-color: var(--success); color: white; }
.blog-list td button.publish:hover { background-color: #218838; }
.blog-list td button.unpublish { background-color: var(--text-muted); color: white; }
.blog-list td button.unpublish:hover { background-color: #5a6268; }


/* ========== Post Form ========== */
.post-form {
    margin-top: 40px; /* Consistent block spacing */
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    background-color: var(--bg); /* Slightly distinct background */
    box-shadow: var(--shadow-s);
}
.post-form .form-group {
    margin-bottom: 20px; /* Increased spacing between form groups */
}
.post-form label {
    display: block;
    margin-bottom: 10px; /* More space below label */
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1em;
}
.post-form input[type="text"],
.post-form textarea {
    width: 100%; /* Full width within its container */
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    box-sizing: border-box; /* Include padding in width calculation */
    background-color: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.post-form input[type="text"]:focus,
.post-form textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: var(--focus);
}
.post-form textarea {
    min-height: 120px; /* Taller text area for summary */
}
.post-form input[type="file"] {
    margin-bottom: 15px;
    padding: 8px 0; /* Add some vertical padding */
}

/* Quill Editor Container (now consistent with overall theme) */
.post-form .quill-editor-container {
    height: 300px; /* Taller editor */
    margin-bottom: 20px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04); /* Subtle inner shadow */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.post-form .quill-editor-container:focus-within { /* Style when editor is focused */
    border-color: var(--brand-primary);
    box-shadow: var(--focus);
}
/* Basic Quill toolbar styles to fit theme */
.ql-toolbar.ql-snow {
    border-radius: var(--radius-s) var(--radius-s) 0 0;
    border-color: var(--border);
    background-color: var(--bg);
}
.ql-container.ql-snow {
    border-radius: 0 0 var(--radius-s) var(--radius-s);
    border-color: var(--border);
    border-top: none;
    font-family: inherit; /* Inherit font from body */
}


/* Post form buttons */
.post-form button {
    /* Use .button classes from styles.css for consistency */
    padding: 12px 20px;
    border-radius: var(--radius-s);
    font-size: 16px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    margin-right: 12px; /* Spacing between buttons */
}
.post-form button[type="submit"] {
    background-color: var(--brand-primary);
    color: white;
    border: none;
}
.post-form button[type="submit"]:hover {
    background-color: var(--brand-primary-dark);
    box-shadow: var(--shadow-glow);
}
.post-form button#cancelEditBtn {
    background-color: var(--text-muted);
    color: white;
    border: none;
}
.post-form button#cancelEditBtn:hover {
    background-color: #5a6268;
}

/* Image Preview */
#imagePreview {
    max-width: 250px; /* Slightly larger preview */
    max-height: 250px;
    margin-top: 15px;
    border: 1px solid var(--border);
    padding: 5px;
    border-radius: var(--radius-s);
    box-shadow: var(--shadow-s);
}

/* Status Messages (Success/Error) */
.status-message {
    margin-top: 20px; /* Consistent spacing */
    padding: 15px;
    border-radius: var(--radius-s);
    font-weight: bold;
    display: none; /* Hidden by default */
    font-size: 0.95em;
}
.status-message.success {
    background-color: rgba(34, 197, 94, 0.10); /* var(--success) with transparency */
    color: #155724; /* Darker green for text */
    border: 1px solid rgba(34, 197, 94, 0.40);
    display: block;
}
.status-message.error {
    background-color: rgba(239, 68, 68, 0.10); /* var(--danger) with transparency */
    color: #721c24; /* Darker red for text */
    border: 1px solid rgba(239, 68, 68, 0.40);
    display: block;
}

/* Responsive adjustments for admin panel */
@media (max-width: 640px) {
    .admin-container {
        padding: 15px;
    }
    .admin-login-card {
        padding: 15px;
        margin: 20px 16px;
    }
    .admin-login-card h1 {
        font-size: 1.5em;
    }
    .blog-list th, .blog-list td {
        padding: 10px;
        font-size: 0.8em;
    }
    .blog-list td button {
        padding: 6px 10px;
        margin-right: 5px;
        font-size: 0.75em;
    }
    .post-form {
        padding: 20px;
    }
    .post-form button {
        margin-right: 10px;
        margin-bottom: 10px;
        width: 100%; /* Make form buttons full width on small screens */
    }
    .post-form .form-group label {
        margin-bottom: 5px;
    }
    .post-form .quill-editor-container {
        height: 200px; /* Adjust editor height on small screens */
    }
}

/* Hide some columns on very small screens for readability */
@media (max-width: 480px) {
    .blog-list th:nth-child(2), /* Hide Author */
    .blog-list td:nth-child(2) {
        display: none;
    }
    .blog-list th:nth-child(4), /* Hide Published At */
    .blog-list td:nth-child(4) {
        display: none;
    }
}

/* ==========================
   Public Blog Page Styles
   Reuses theme variables from styles.css for a professional blog design
   ========================== */

.blog-hero {
    margin: 18px 0 28px 0;
    overflow: hidden;
}
.blog-hero .auth-card-header {
    background: linear-gradient(135deg, rgba(10,116,255,0.95), rgba(255,122,0,0.85));
    padding: 22px;
}
.blog-hero h1 { font-size: 28px; margin: 0; }
.blog-hero p { margin: 6px 0 0 0; }

.blog-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.blog-post-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    overflow: hidden;
    box-shadow: var(--shadow-s);
    transition: transform 160ms ease, box-shadow 160ms ease;
    text-decoration: none;
    color: inherit;
}
.blog-post-card img { width:100%; height:180px; object-fit:cover; display:block; }
.blog-post-card-content { padding: 14px 16px; }
.blog-post-card h2 { margin: 0 0 8px 0; font-size: 18px; }
.blog-post-card p { margin: 0 0 12px 0; color: var(--text-secondary); }
.blog-post-card .blog-post-card-meta { font-size: 13px; color: var(--text-muted); }
.blog-post-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-m); }

.post-article { background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow-m); border: 1px solid var(--border); overflow: hidden; }
.post-hero-image { width:100%; height:260px; background-size:cover; background-position:center; }
.post-article-header h1 { font-size: 28px; margin: 0; }
.post-content { line-height:1.7; color: var(--text-primary); max-width: 760px; }
.post-content img { border-radius: 8px; margin: 14px 0; }
.post-content h2 { margin-top: 22px; font-size: 20px; }
.post-content blockquote { border-left: 4px solid rgba(10,116,255,0.12); padding: 12px 16px; background: rgba(10,116,255,0.03); color: var(--text-secondary); border-radius:8px; }

.post-article footer .button { padding: 8px 12px; font-size: 14px; }

.content-wrapper { grid-template-columns: 1fr 320px; gap: 28px; }
.sidebar { padding-bottom: 18px; }

@media (max-width: 980px) {
    .blog-grid { grid-template-columns: 1fr; }
    .content-wrapper { grid-template-columns: 1fr; }
    .post-hero-image { height: 180px; }
}

/* Small helper for metadata chips */
.meta-chip { display:inline-flex; gap:8px; align-items:center; padding:6px 10px; border-radius:999px; border:1px solid var(--border); background:#fff; font-size:13px; color:var(--text-secondary); }

.post-tags { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.post-tags .meta-chip { background: rgba(0,0,0,0.03); }

/* Accessible focus styles for cards */
.blog-post-card:focus { outline: none; box-shadow: var(--focus); transform: translateY(-4px); }

