/* Top Navbar */
:root {
    --avatar-size: 32px;
    --bg-color: #1a365d;
    --text-color: #ffffff;
    --primary: #2d74da;
    --primary-hover: #1a5bb8;
    --muted: #cbd5e0;
    --muted-2: #a0aec0;
    --topnav-bg: #1a365d;
    --topnav-height: 70px;
    --search-bg: #ffffff;
    --search-input-text: #333;
    --footer-bg: #3343c1;
    --footer-text: #cbd5e0;
    --card-bg: #1a2332;
    --card-border: #2d3748;
    --accent: #6352dd;
    --accent-hover: #4c3db7;
    --danger: #ef2929;
    --danger-hover: #cc2323;
    --input-bg: #ffffff;
    --input-text: #111827;
    --input-border: #e5e7eb;
    --publish-grad-start: #6352dd;
    --publish-grad-end: #8b5cf6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    color: white;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    max-width: 100vw;
}

.test-cont {
    margin: auto;
}

main {
    max-width: 100%;
    overflow-x: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.topnav-root {
    background-color: var(--topnav-bg);
    color: var(--muted);
    width: 100%;
}

.topnav-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    padding: 0 20px;
    height: var(--topnav-height);
    gap: 30px;
}

.topnav-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 40px;
}

/* Main Navigation Bar */
nav {
    background-color: var(--card-bg);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

nav a:hover {
    background-color: var(--primary);
    color: var(--text-color);
}

nav a.active {
    background-color: var(--primary);
    color: var(--text-color);
}

.content-wrapper {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* Responsive: stack links vertically on smaller screens */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem;
    }

    nav a {
        width: 100%;
        text-align: center;
    }
}

.search-bar {
    display: flex;
    align-items: center;
    margin-right: 40px;
    position: relative;
}

.search-bar form {
    display: flex;
    align-items: center;
    background-color: var(--search-bg);
    border-radius: 25px;
    overflow: hidden;
}

.search-bar input {
    border: none;
    padding: 10px 15px;
    font-size: 14px;
    color: var(--search-input-text);
    outline: none;
    min-width: 200px;
}

@media (max-width: 480px) {
    hr {
        display: block !important;
        border: 1px solid #ccc !important;
        width: 90vw !important;
        max-width: 500px !important;
        margin: 20px auto !important;
        height: 0 !important;
        background: none !important;
        border-radius: 0 !important;
    }
    .search-bar input {
        min-width: 0;
        width: 100%;
    }
}

.search-bar button {
    background-color: var(--primary);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 0 20px 20px 0;
    transition: background-color 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.search-bar button:hover {
    background-color: var(--primary-hover);
}

.topnav-buttons a {
    color: var(--muted);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    background-color: var(--primary);
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.topnav-buttons a:hover {
    background-color: var(--primary-hover);
}

.topnav-buttons span {
    color: var(--muted-2);
}

/* User Preview and Dropdown */
.user-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.avatar {
    height: var(--avatar-size);
    width: var(--avatar-size);
    border-radius: 50%;
    object-fit: cover;
}

.display-name {
    margin: 0.5em;
}

.dropdown-arrow {
    cursor: pointer;
    margin-left: 5px;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.dropdown-arrow:hover {
    transform: scale(1.1);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--search-bg);
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: none;
    min-width: 120px;
    z-index: 1000;
}

.user-dropdown a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 1px solid #eee;
}

.user-dropdown a:last-child {
    border-bottom: none;
}

.user-dropdown a:hover {
    background: #f0f0f0;
}

/* Footer Styles */
footer {
    flex-shrink: 0;
    background-color: var(--footer-bg) !important;
    color: var(--footer-text);
    padding: 40px 20px 20px;
    font-family: Arial, sans-serif;
    border-radius: 50% 50% 0 0 / 50px 50px 0 0;
    margin-top: 50px;
    position: relative;
    z-index: 1;
}

.footer-subroot {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 30px;
}

.footer-links h3,
.footer-subscribe h3,
.footer-social h3 {
    color: var(--text-color);
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

.footer-links h3 {
    text-align: left;
    margin-bottom: 50px !important;
}

.footer-links {
    margin: 0 40px;
}

.footer-links div {
    display: flex;
    gap: 80px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-links div div {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
}

.footer-links a {
    color: var(--muted-2);
    text-decoration: none;
    font-size: 14px;
}

.footer-links a:hover {
    color: var(--text-color);
}

.footer-subscribe {
    text-align: center;
}

.subscribe-form {
    display: flex;
    align-items: center;
    background: var(--search-bg);
    border-radius: 25px;
    overflow: hidden;
    padding: 5px;
    max-width: 400px;
    margin: 0 auto;
}

.subscribe-form input {
    flex: 1;
    border: none;
    padding: 10px 15px;
    font-size: 14px;
    color: #333;
    outline: none;
}

.subscribe-form button {
    background: var(--primary);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 0 40px 40px 0;
    transition: background-color 0.3s ease;
}

.subscribe-form button:hover {
    background: var(--primary-hover);
}

.footer-social {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.social-icons {
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    justify-content: center;
}

.social-icons a {
    color: var(--muted);
    font-size: 20px;
    text-decoration: none;
}

.social-icons a:hover {
    color: var(--text-color);
}

.footer-copyright {
    text-align: center;
    margin-top: 20px;
}

.footer-copyright p {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --avatar-size: 28px;
        --topnav-height: auto;
    }

    .topnav-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
        height: auto;
        align-items: stretch; /* ensures children take full width */
    }

    .search-bar {
        width: 100%;
        margin-right: 0;
    }

    .search-bar form {
        width: 100%;
    }

    .search-bar input {
        min-width: unset;
        flex: 1;
        font-size: 16px; /* prevent zoom on iOS */
    }

    .topnav-buttons {
        gap: 10px;
        width: 100%;
        justify-content: center;
        margin-left: 0;
        flex-wrap: wrap;
    }

    .topnav-buttons a {
        padding: 8px 16px;
        font-size: 14px;
        text-align: center;
        flex: 0 1 auto;
    }

    .user-preview {
        font-size: 14px;
        justify-content: center;
        width: 100%;
    }

    .footer-subroot {
        gap: 20px;
    }

    .footer-links div {
        gap: 30px;
        flex-direction: column;
        align-items: center;
    }

    .footer-links div div {
        align-items: center;
    }

    .footer-links a {
        font-size: 13px;
    }

    .subscribe-form {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .subscribe-form input {
        width: 100%;
        max-width: 300px;
    }

    .subscribe-form button {
        width: 100%;
        max-width: 300px;
        border-radius: 25px;
    }

    .footer-social {
        text-align: center;
    }

    .social-icons {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .topnav-container {
        padding: 10px 15px;
    }

    .search-bar input {
        min-width: 0;
        width: 100%;
        font-size: 16px;
    }

    .topnav-buttons a {
        padding: 6px 12px;
        font-size: 13px;
    }

    .footer-links div {
        gap: 20px;
    }

    .footer-links a {
        font-size: 12px;
    }

    .subscribe-form input,
    .subscribe-form button {
        font-size: 14px;
        padding: 8px;
    }

    .toast-notification {
        left: 10px;
        right: 10px;
        transform: translateX(0) translateY(100px);
        min-width: auto;
        max-width: calc(100% - 20px);
        visibility: hidden;
        pointer-events: none;
    }

    .toast-notification.show {
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0) translateY(0);
    }
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%) translateY(40px);
    min-width: 120px;
    max-width: 90vw;
    background: #10b981;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 10px 28px 10px 38px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 9999;
    transition: opacity 0.3s, transform 0.3s;
    text-align: center;
    display: inline-block;
}
.toast-notification::before {
    content: '\2714';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #fff;
    font-weight: bold;
}
.toast-notification.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Latest Blogs Section */
.latest-blogs {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.latest-blogs h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.blog-item {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.blog-item:last-child {
    border-bottom: none;
}

/* Blog Item Wrapper with Actions */
.blog-item-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #ccc;
    padding-bottom: 15px;
    margin-bottom: 15px;
    gap: 20px;
}

.blog-item-wrapper:last-child {
    border-bottom: none;
}

.blog-item-wrapper a {
    flex: 1;
    min-width: 0;
}

/* Blog Actions (Edit/Delete Buttons) */
.blog-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    white-space: nowrap;
    align-items: center;
    margin-top: 5px;
}

.btn-edit,
.btn-delete {
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.btn-edit {
    background-color: var(--accent);
    color: var(--text-color);
}

.btn-edit:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(99, 82, 221, 0.3);
}

.btn-edit:active {
    transform: translateY(0);
}

.btn-delete {
    background-color: var(--danger);
    color: var(--text-color);
}

.btn-delete:hover {
    background-color: var(--danger-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(239, 41, 41, 0.3);
}

.btn-delete:active {
    transform: translateY(0);
}

/* Responsive Design - Blog Items */
@media (max-width: 768px) {
    .blog-item-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .blog-actions {
        justify-content: flex-end;
        margin-top: 10px;
        flex-wrap: wrap;
    }

    .btn-edit,
    .btn-delete {
        flex: 1;
        min-width: auto;
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .blog-actions {
        justify-content: stretch;
        gap: 8px;
    }

    .btn-edit,
    .btn-delete {
        flex: 1;
        max-width: none;
    }
}

/* Facebook-style Blog Posts */
.blog-posts-container {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.blog-post-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--card-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.blog-post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Post header layout */
.post-header {
    display: flex;
    gap: 12px;
    position: relative;
    margin-bottom: 15px;
}

/* Avatar styling with link */
.author-avatar-link {
    display: block;
    flex-shrink: 0;
}

.author-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    display: block;
}

.default-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-weight: bold;
    font-size: 18px;
    border: 2px solid var(--primary);
    text-decoration: none;
}

/* Content section */
.post-content-section {
    flex: 1;
    min-width: 0; /* Prevent overflow */
}

.post-link {
    text-decoration: none;
    color: inherit;
    display: block;
    margin-bottom: 10px;
}

.post-title {
    color: var(--text-color);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.post-snippet {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Author and date section */
.post-meta {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
}

.author-name {
    color: #90cdf4;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.author-name:hover {
    text-decoration: underline;
}

.post-date {
    color: #a0aec0;
    font-size: 13px;
}

/* Blog Actions for the card */
.blog-actions-card {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .blog-post-card {
        padding: 12px;
    }

    .post-header {
        gap: 8px;
    }

    .author-avatar,
    .default-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .post-title {
        font-size: 16px;
    }

    .post-snippet {
        font-size: 13px;
    }

    .blog-actions-card {
        position: relative;
        top: auto;
        right: auto;
        justify-content: flex-end;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .blog-post-card {
        padding: 10px;
    }

    .author-avatar,
    .default-avatar {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .post-title {
        font-size: 15px;
    }

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

    .post-date {
        margin-left: 0;
    }
}
