/* Global Styles */
:root {
    --primary-color: #ff0000;
    --secondary-color: #2c3e50;
    --background-color: #f8f9fa;
    --text-color: #333;
    --white: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Layout */
header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 600;
    margin-left: 1.5rem;
    transition: color 0.3s ease;
}

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

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
    flex: 1;
}

footer {
    background-color: var(--secondary-color);
    color: var(--white);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

/* Components */
.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}
.btn-secondary:hover { background-color: #7f8c8d; }

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.clickable-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.meta {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* Editor & Markdown Styles */
.editor-container {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.editor-pane, .preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.toolbar-btn {
    background: #e1e4e8;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: #333;
}
.toolbar-btn:hover { background: #d1d5da; }

.editor-textarea {
    width: 100%;
    height: 400px;
    font-family: monospace;
    padding: 1rem;
    resize: none;
}

.preview-content {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    height: 400px;
    overflow-y: auto;
}

/* Markdown Content Typography */
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1rem; margin-bottom: 0.5rem; }
.markdown-body p { margin-bottom: 1rem; }
.markdown-body ul, .markdown-body ol { margin-left: 1.5rem; margin-bottom: 1rem; }
.markdown-body blockquote { border-left: 4px solid #ddd; padding-left: 1rem; color: #666; margin: 1rem 0; }
.markdown-body code { background: #f6f8fa; padding: 0.2rem 0.4rem; border-radius: 3px; font-family: monospace; font-size: 90%; }
.markdown-body pre { background: #f6f8fa; padding: 1rem; overflow-x: auto; border-radius: 5px; }
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body img { max-width: 100%; border-radius: 4px; }

/* Responsive Editor */
@media (max-width: 768px) {
    .editor-container { flex-direction: column; }
    .editor-textarea, .preview-content { height: 300px; }
}

/* Flash Messages */
.flash-messages {
    list-style: none;
    margin-bottom: 1rem;
}

.flash-messages li {
    background: #d4edda;
    color: #155724;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

/* Hamburger Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 600;
    margin-left: 1.5rem;
    transition: color 0.3s ease;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
    padding: 0;
    display: inline-block;
}

.dropbtn:hover {
    color: var(--primary-color);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--white);
    min-width: 160px;
    box-shadow: var(--shadow);
    z-index: 2000;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    margin-left: 0;
    font-weight: normal;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: var(--primary-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Home Page Sidebar Layout */
.home-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.home-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #fff;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: 100px; /* sticky below header */
}

.home-sidebar h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.home-sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.home-sidebar li {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.5rem;
}
.home-sidebar li:last-child { border-bottom: none; }

.home-sidebar a {
    text-decoration: none;
    color: var(--secondary-color);
    font-size: 0.95rem;
    display: block;
    line-height: 1.4;
    transition: color 0.2s;
}

.home-sidebar a:hover {
    color: var(--primary-color);
    transform: translateX(3px);
}

.home-feed {
    flex: 1;
    min-width: 0; /* Fix flex overflow issues */
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .home-layout {
        flex-direction: column-reverse; /* Put sidebar below content on mobile? Or top? Usually top or bottom. */
    }
    .home-sidebar {
        width: 100%;
        position: static;
        margin-bottom: 2rem;
    }
}