/* Modern Variables */
:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --accent: #FB8C00;
    --accent-dark: #EF6C00;
    --bg-color: #F5F7FA;
    --card-bg: #FFFFFF;
    --footer-bg: #1E2A38;
    --text-main: #1e293b;
    --text-muted: #6C757D;
    --border-color: #E0E0E0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
}

header {
    background-color: var(--primary);
    color: #FFFFFF;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 0rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px; /* Slightly shorter for modern look */
    z-index: 1000;
    box-sizing: border-box;
    box-shadow: var(--shadow-md);
}

.layout-wrapper {
    max-width: 100%;
    margin: 80px auto 20px;
    height: calc(100vh - 170px);
    overflow: hidden;
    padding: 0 0rem;
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

.sidebar-widget {
    margin-bottom: 20px;
}

.sidebar-widget h3 {
    margin-top: 0;
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.search-widget {
    display: flex;
    align-items: center;
    gap: 10px;
}

#filter-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #2c3e50;
    padding: 5px;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #f8fafc;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent);
    outline: none;
    background: white;
}

.category-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 10px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.category-btn:hover, .category-btn.active {
    background-color: #e0f2fe;
    color: var(--primary);
    padding-left: 15px;
}

.category-count {
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 8px;
    border-radius: 10px;
}

#blog-container {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Responsive grid */
    gap: 25px;
    height: 100%;
    overflow-y: auto;
    padding-bottom: 10px;
    box-sizing: border-box;
}

.blog-post {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0; /* Removed padding to allow full-width image */
    overflow: hidden; /* Ensures image stays within border radius */
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 450px;
    content-visibility: auto;
    contain-intrinsic-size: 450px;
    cursor: pointer;
}

.blog-post:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.post-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background-color: var(--border-color); /* Placeholder while loading */
}

.post-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-category {
    align-self: flex-start;
    background-color: #e0f2fe;
    color: var(--primary); /* Darker blue for accessible contrast (>4.5:1) */
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.blog-post h2 {
    margin: 12px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-content p {
    flex-grow: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.post-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.like-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s;
}

.like-btn.liked {
    color: #e74c3c;
}

.like-btn:hover {
    transform: scale(1.1);
}

/* Skeleton Loading Animation */
.skeleton { pointer-events: none; }
.skeleton-img { width: 100%; height: 200px; background: #e2e8f0; animation: pulse 1.5s infinite; }
.skeleton-text { background: #e2e8f0; border-radius: 4px; margin-bottom: 10px; animation: pulse 1.5s infinite; }
.skeleton-text.category { width: 30%; height: 20px; }
.skeleton-text.title { width: 80%; height: 28px; margin: 15px 0; }
.skeleton-text.meta { width: 50%; height: 16px; }

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.loading, .error {
    text-align: center;
    font-style: italic;
}

.hidden {
    display: none !important;
}

#single-post-view {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 30px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

#back-btn {
    margin-bottom: 20px;
    padding: 10px 20px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

#back-btn:hover {
    background-color: var(--primary-light);
}

#post-details-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 20px 0;
    box-shadow: var(--shadow-sm);
}

#post-details-content h1 {
    color: var(--primary);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

/* Related Posts */
.related-posts h3 {
    color: var(--primary);
}

.related-post-card h4 {
    color: var(--text-main);
    transition: color 0.2s;
}

.related-post-card:hover h4 {
    color: var(--primary);
}

.share-buttons {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.share-btn {
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

.share-btn:hover {
    opacity: 0.9;
}

.share-btn.facebook { background-color: #3b5998; }
.share-btn.twitter { background-color: #1da1f2; }
.share-btn.linkedin { background-color: #0077b5; }
.share-btn.whatsapp { background-color: #25d366; }

.comments-section {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.comments-section h3 {
    color: var(--primary);
    margin-bottom: 20px;
}

#comment-form, #comment-login-prompt {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#comment-form textarea, #comment-login-prompt textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    background: #f8fafc;
}

#comment-login-prompt textarea:disabled {
    background-color: #e2e8f0;
    cursor: not-allowed;
    color: var(--text-muted);
}

#comment-form button, #comment-login-prompt button {
    align-self: flex-start;
    padding: 8px 20px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#comment-form button:hover, #comment-login-prompt button:hover {
    background-color: var(--primary-light);
}

.char-count-wrapper {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: -5px;
    margin-bottom: 10px;
}

.comment-item {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.comment-author {
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
    display: block;
}

.comment-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 10px;
    font-weight: normal;
}

.reply-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 5px 0;
    margin-top: 5px;
}

.reply-btn:hover {
    color: var(--primary);
    text-decoration: underline;
}

.replies-list {
    margin-left: 20px;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
    margin-top: 10px;
}

.reply-form {
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.reply-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    font-size: 0.9rem;
}

.reply-form-actions {
    display: flex;
    gap: 10px;
}

.reply-form button {
    padding: 5px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
}

.reply-submit-btn {
    background-color: var(--primary);
    color: white;
    border: none;
}

.reply-cancel-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.load-more-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    background-color: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background-color: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}

/* Header & Nav */
.logo {
    margin: 0;
    padding-top: 10px;
    font-size: 1.8rem;
    margin-right: auto;
}

.logo img {
    /* filter: drop-shadow(0 0 4px #7bcee1); */
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: #FFFFFF;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.nav-btn span {
    display: inline-block;
}

.nav-btn:hover {
    background: var(--accent);
}

#user-info {
    display: flex;
    align-items: center;
}

#user-name {
    font-weight: bold;
    color: #FFFFFF;
}

.mobile-menu-btn {
    display: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
}

.modal button[type="submit"] {
    width: 100%;
    padding: 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.password-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}

.password-wrapper input {
    margin-bottom: 0;
    padding-right: 40px; /* Space for the icon */
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

/* Form Views (Create Post, Support) */
.form-view {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 15px;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group textarea {
    min-height: 200px;
    resize: vertical;
}

#thumbnail-preview {
    max-width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    display: block;
}

/* Rich Text Editor */
.editor-toolbar {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 8px;
    border-radius: 6px 6px 0 0;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: white;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 3px;
}

.editor-toolbar button:hover {
    background: #e1ecf4;
}

.rich-editor {
    border: 1px solid var(--border-color);
    border-radius: 0 0 6px 6px;
    padding: 15px;
    min-height: 250px;
    max-height: 500px;
    overflow-y: auto;
    background: white;
    outline: none;
}

.rich-editor:focus {
    border-color: var(--primary);
}

.submit-btn {
    background-color: var(--accent);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
}

.submit-btn:hover {
    background-color: var(--accent-dark);
}

/* My Posts List */
#my-posts-view {
    flex-grow: 1;
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-y: auto;
}

.my-post-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.my-post-actions button {
    margin-left: 10px;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    border: none;
    color: white;
}

.edit-btn { background-color: #f39c12; }
.delete-btn { background-color: #e74c3c; }

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: #FFFFFF;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    box-sizing: border-box;
    width: 100%;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: white;
}

@media (max-width: 1024px) {
    .layout-wrapper {
        flex-direction: column;
        height: auto;
        overflow: visible;
        margin-top: 60px;
    }
    .sidebar {
        width: 100%;
        box-sizing: border-box;
        height: auto;
        overflow: visible;
    }
    .form-view {
        width: 100%;
    }
    #filter-toggle-btn {
        display: block;
    }
    #category-filters {
        display: none;
    }
    #category-filters.active {
        display: block;
    }
    #blog-container {
        grid-template-columns: repeat(3, 1fr);
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 600px) {
    #blog-container {
        grid-template-columns: 1fr;
    }

    .mobile-menu-btn {
        display: block;
        width: auto;
        border: none;
        font-size: 1.5rem;
    }

    .mobile-menu-btn i {
        transition: transform 0.3s ease;
    }

    .mobile-menu-btn.open i {
        transform: rotate(180deg);
    }

    header {
        padding: 0 10px;
        height: 60px;
    }

    .logo {
        font-size: 1.4rem;
    }

    .header-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: var(--primary);
        flex-direction: column;
        padding: 10px 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    .header-nav.active {
        display: flex;
    }

    .header-nav .nav-btn {
        width: 100%;
        text-align: left;
        padding: 12px 20px;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 1rem;
    }

    .header-nav .nav-btn span {
        display: inline-block;
        margin-left: 10px;
    }

    #auth-buttons, #user-info {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .layout-wrapper {
        margin-top: 70px;
    }

    .form-view {
        padding: 15px;
    }

    footer {
        height: auto;
        padding: 20px;
        text-align: center;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
    }

    .footer-links a {
        margin: 0 10px;
    }
}