/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');
/* Or a more "techy" font for headings like 'Montserrat' or 'Open Sans' */
/* @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&display=swap'); */


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

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.7;
    background-color: #f0f2f5; /* Slightly softer light gray */
    color: #343a40;
}

.container {
    max-width: 1080px; /* Slightly wider container */
    margin: 0 auto;
    padding: 0 25px; /* More padding on sides */
}

/* Header */
header {
    background: #ffffff; /* White header for a clean look */
    border-bottom: 1px solid #e9ecef; /* Subtle bottom border */
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); /* Lighter shadow */
}

header .container {
    display: flex; /* Use flexbox for logo and nav */
    justify-content: space-between; /* Space them out */
    align-items: center; /* Vertically align */
}

header h1 {
    margin: 0; /* Remove default margin */
    font-size: 1.8em; /* Adjusted size */
}

header h1 a {
    color: #343a40; /* Darker logo text */
    text-decoration: none;
    font-weight: 700;
}

header h1 a:hover {
    color: #007bff; /* Primary color on hover */
}

header nav ul {
    list-style: none;
    display: flex;
    margin: 0;
}

header nav ul li {
    margin-left: 30px; /* Space between nav items */
}

header nav a {
    color: #555; /* Muted link color */
    text-decoration: none;
    font-weight: 400;
    padding: 5px 0; /* Add padding for better hit area */
    position: relative;
    transition: color 0.3s ease;
}

/* Underline effect on hover for nav items */
header nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background: #007bff;
    left: 0;
    bottom: -5px;
    transition: width 0.3s ease;
}

header nav a:hover::after {
    width: 100%;
}

header nav a:hover {
    color: #007bff;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%); /* Blue gradient */
    color: #ffffff;
    padding: 80px 0; /* More vertical padding */
    text-align: center;
    margin-bottom: 40px; /* Space below hero */
    box-shadow: inset 0 -5px 10px rgba(0,0,0,0.1);
}

.hero-section h2 {
    font-size: 3em; /* Larger, more impactful heading */
    margin-bottom: 15px;
    font-weight: 700;
    /* font-family: 'Montserrat', sans-serif; */ /* If you want a different font for headings */
}

.hero-section p {
    font-size: 1.2em;
    margin-bottom: 30px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.9;
}

.button { /* General button style, used for hero CTA */
    display: inline-block;
    background: #ffffff; /* White button */
    color: #007bff; /* Blue text */
    padding: 12px 28px;
    text-decoration: none;
    border-radius: 50px; /* Pill-shaped button */
    font-weight: 600;
    font-size: 1.05em;
    transition: background 0.3s ease, color 0.3s ease, transform 0.2s ease;
    border: 2px solid #ffffff; /* Outline */
}

.button:hover {
    background: transparent; /* Transparent background on hover */
    color: #ffffff; /* White text on hover */
    transform: translateY(-2px); /* Slight lift */
}

/* Main Content */
main.container { /* Apply container to main */
    padding-top: 20px;
    padding-bottom: 50px;
}

#articles h2 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.5em;
    color: #343a40;
    /* font-family: 'Montserrat', sans-serif; */
    font-weight: 700;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); /* Slightly wider min width */
    gap: 30px;
}

.article-card {
    background: #ffffff;
    padding: 0; /* Remove padding from card itself, content inside will have it */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08); /* Stronger but softer shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* Important for image overflow if added */
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-8px); /* More pronounced lift */
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); /* Stronger shadow on hover */
}

/* Placeholder for article image */
.article-image {
    width: 100%;
    height: 200px; /* Fixed height for consistent card appearance */
    background-color: #e9ecef; /* Placeholder background */
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 20px;
    display: block; /* Ensure it takes up space */
}


.article-card h3 {
    margin-bottom: 10px;
    font-size: 1.5em; /* Slightly smaller for cards */
    padding: 0 25px; /* Inner padding for title */
}

.article-card h3 a {
    color: #343a40;
    text-decoration: none;
    transition: color 0.3s ease;
}

.article-card h3 a:hover {
    color: #007bff;
}

.article-card .meta {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 15px;
    font-style: normal; /* Remove italic */
    padding: 0 25px;
}

.article-card p {
    font-size: 0.95em;
    margin-bottom: 20px;
    padding: 0 25px;
}

.card-actions{
    display:flex;
    gap:10px;
    padding: 0 25px 20px 25px;
}

.btn-small{ 
    font-size: 0.85em;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    cursor: pointer;
}
.btn-small:hover{background:#f3f4f6}
.btn-small.danger{border-color:#fecaca;color:#b91c1c;background:#fff5f5}

.article-card .read-more {
    display: block; /* Make it a block element for full width */
    background: #e9ecef; /* Lighter background for card button */
    color: #007bff;
    padding: 12px 25px;
    text-align: center;
    border-radius: 0 0 8px 8px; /* Rounded only at bottom */
    margin-top: 0; /* Reset margin */
    font-weight: 600;
    transition: background 0.3s ease, color 0.3s ease;
}

.article-card .read-more:hover {
    background: #007bff; /* Blue background on hover */
    color: #ffffff; /* White text on hover */
}


/* Specific styling for detailed article page */
.article-detail {
    background: #ffffff;
    padding: 40px 50px; /* More padding for content */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    margin-bottom: 40px;
}

.article-detail h2 {
    font-size: 2.8em; /* Larger article title */
    margin-bottom: 20px;
    color: #343a40;
    line-height: 1.2;
}

.article-detail .meta {
    font-size: 0.9em;
    color: #777;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee; /* Subtle separator */
    padding-bottom: 15px;
    font-style: normal;
}

.article-detail h3 {
    margin-top: 35px;
    margin-bottom: 15px;
    font-size: 1.7em;
    color: #343a40;
    font-weight: 600;
}

.article-detail p {
    margin-bottom: 25px;
    font-size: 1.05em; /* Slightly larger text for readability */
    color: #495057;
    text-align: left; /* No justify for article content */
}

.article-detail ul {
    margin-left: 30px;
    margin-bottom: 25px;
    list-style-type: disc;
    color: #495057;
}

.article-detail ul li {
    margin-bottom: 10px;
    font-size: 1.05em;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px;
    background: #343a40; /* Darker footer */
    color: #e9ecef; /* Lighter text */
    margin-top: 50px;
    font-size: 0.85em;
}

/* Dialog (Create/Edit) */
dialog#post-form, dialog#admin-login-form{
    width: min(720px, 92vw);
    border: none;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
dialog::backdrop{background: rgba(0,0,0,0.4)}

#post-form form, #admin-login-form form{padding: 20px 22px}
#post-form h3, #admin-login-form h3{font-size:1.4em;margin-bottom:10px}
.form-row{display:flex;flex-direction:column;margin:10px 0}
.form-row input[type="text"], .form-row textarea, .form-row input[type="password"]{
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    background:#fff;
}
.form-row input[type="file"]{margin-top:6px}
.image-preview{max-height:180px;margin-top:10px;border-radius:8px;display:block}
.form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:8px}
.btn-secondary{background:#e5e7eb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px}
.button{display:inline-block;background:#007bff;color:#fff;border:none;border-radius:8px;padding:10px 14px;cursor:pointer}
.button:hover{background:#0056b3}

/* Empty state */
.empty-state{margin:20px 0;padding:18px;border:1px dashed #d1d5db;border-radius:8px;color:#6b7280;background:#f9fafb}

/* Post view styling */
.post-view {
  max-width: 800px;
  margin: 0 auto;
}

.post-navigation {
  margin-bottom: 30px;
}

.post-navigation .button {
  background: #e9ecef;
  color: #007bff;
  border: 1px solid #e9ecef;
}

.post-navigation .button:hover {
  background: #007bff;
  color: #ffffff;
}

/* Code block styling */
.article-detail pre {
  background: #2d3748;
  color: #e2e8f0;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid #4a5568;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.article-detail pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
}

.article-detail .inline-code {
  background: #f1f5f9;
  color: #e53e3e;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.9em;
  border: 1px solid #e2e8f0;
}

/* Copy button for code blocks */
.code-block-container {
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #4a5568;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.copy-code-btn:hover {
  opacity: 1;
}

.copy-code-btn.copied {
  background: #48bb78;
}

/* Post Type Toggle */
.post-type-toggle {
  display: flex;
  gap: 5px;
  margin-top: 5px;
}

.toggle-btn {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.toggle-btn:hover {
  border-color: #007bff;
  color: #007bff;
}

.toggle-btn.active {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

.content-section {
  transition: all 0.3s ease;
}

/* Code content specific styling */
#code-content {
  font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}

#code-language {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  font-size: 14px;
}

/* Code post specific styling */
.code-description {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid #007bff;
}

.code-description p {
  margin: 0;
  color: #495057;
  font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .container {
        padding: 0 20px;
    }
    header h1 {
        font-size: 1.6em;
    }
    header nav ul li {
        margin-left: 20px;
    }
    .hero-section h2 {
        font-size: 2.5em;
    }
    .hero-section p {
        font-size: 1.1em;
    }
    #articles h2 {
        font-size: 2em;
    }
    .article-detail {
        padding: 30px;
    }
    .article-detail h2 {
        font-size: 2.2em;
    }
    .article-card h3 {
        font-size: 1.3em;
    }
}

@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        text-align: center;
    }
    header h1 {
        margin-bottom: 15px;
    }
    header nav ul {
        flex-direction: column;
        gap: 10px;
    }
    header nav ul li {
        margin: 0;
    }
    .hero-section {
        padding: 60px 0;
    }
    .hero-section h2 {
        font-size: 2em;
    }
    .hero-section p {
        font-size: 1em;
    }
    main.container {
        padding: 20px 15px;
    }
    .article-grid {
        grid-template-columns: 1fr;
    }
    .article-card {
        margin-bottom: 20px; /* Add some space between stacked cards */
    }
    .article-detail {
        padding: 25px 20px;
    }
    .article-detail h2 {
        font-size: 1.8em;
    }
}