/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    padding: 1rem 0;
}

.nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2563eb;
}

.logo a {
    text-decoration: none;
    color: inherit;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #2563eb;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero-content h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-description {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-btn {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: background 0.3s ease;
    backdrop-filter: blur(10px);
}

.hero-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Featured Section */
.featured {
    padding: 2rem 0;
    background: #fafbfc;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #1f2937;
}

.featured .section-title {
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.featured-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.featured-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.featured-card .card-content {
    padding: 1.25rem;
}

.featured-card .card-title a {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: #111827;
}

.featured-card .card-excerpt {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    color: #4b5563;
}

.featured-card .card-meta {
    margin-bottom: 1rem;
}

.featured-card .card-author {
    font-size: 0.95rem;
    font-weight: 500;
    color: #6b7280;
}

/* Blog List */
.blog-list {
    padding: 4rem 0;
    background: #f8fafc;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.blog-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.card-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.category {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.category:hover {
    background: #c7d2fe;
    color: #312e81;
}

.date {
    color: #6b7280;
}

.card-title {
    margin-bottom: 1rem;
}

.card-title a {
    text-decoration: none;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.card-title a:hover {
    color: #2563eb;
}

.card-excerpt {
    color: #6b7280;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.card-author {
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-btn {
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #6b7280;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.page-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.page-btn.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* Post Page */
.post {
    padding: 4rem 0;
    background: white;
}

.post-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem;
}

.post-meta {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.post-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #1f2937;
    line-height: 1.2;
}

.post-author {
    color: #6b7280;
    font-size: 1.1rem;
}

.post-content {
    max-width: 800px;
    margin: 0 auto 3rem;
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content h1, .post-content h2, .post-content h3 {
    margin: 2rem 0 1rem;
    color: #1f2937;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

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

.back-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: #e5e7eb;
}

/* Admin Panel */
.admin-header {
    background: #1f2937;
}

.admin-header .logo {
    color: white;
}

.admin-header .nav-links a {
    color: #d1d5db;
}

.admin-header .nav-links a:hover {
    color: white;
}

.admin-container {
    background: #f8fafc;
    min-height: calc(100vh - 80px);
    padding: 2rem 0;
}

.editor-section {
    background: white;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.editor-section .container {
    padding: 2rem;
}

.blog-form {
    max-width: 800px;
    margin: 0 auto;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Posts Management */
.posts-management {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.posts-management .container {
    padding: 2rem;
}

.posts-table {
    overflow-x: auto;
}

.posts-table table {
    width: 100%;
    border-collapse: collapse;
}

.posts-table th,
.posts-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.posts-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status.draft {
    background: #fef3c7;
    color: #92400e;
}

.status.published {
    background: #d1fae5;
    color: #065f46;
}

.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Alert */
.alert {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 6px;
    text-align: center;
}

.alert.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Footer */
.footer {
    background: #1f2937;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

/* Main Content Layout */
.main-content {
    padding: 2rem 0;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
    align-items: start;
}

/* Sidebar Styles */
.sidebar {
    position: sticky;
    top: 100px;
}

.sidebar-widget {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.sidebar-widget h3 {
    margin-bottom: 1rem;
    color: #1f2937;
    font-size: 1.2rem;
}

.sidebar-widget p {
    color: #6b7280;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Newsletter Widget */
.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.newsletter-form input {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.newsletter-form input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.newsletter-form button {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.newsletter-form button:hover {
    background: #1d4ed8;
}

/* Ad Widget */
.ad-placeholder {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

.ad-placeholder p {
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.ad-placeholder small {
    color: #9ca3af;
}

/* Featured Images */
.card-image {
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1rem;
    aspect-ratio: 16/9;
    width: 100%;
    background: #f3f4f6;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    max-width: 100%;
    display: block;
}

.blog-card:hover .card-image img {
    transform: scale(1.05);
}

/* Featured post images - prominent display */
.featured-image {
    aspect-ratio: 16/9;
    max-width: 100%;
    display: block;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
}

/* All image containers will now always display with either image or placeholder */

/* Image loading and error states */
.card-image img {
    transition: opacity 0.3s ease;
}

/* Hide broken images */
.card-image img[src=""],
.card-image img:not([src]) {
    display: none;
}

/* Handle image loading errors */
.card-image img {
    object-fit: cover;
    object-position: center;
    width: 100%;
    height: 100%;
}

/* Image Placeholder Styles */
.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f9fafb;
    border: 2px dashed #e5e7eb;
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.featured-card:hover .image-placeholder {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.blog-card:hover .image-placeholder {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.image-placeholder svg {
    opacity: 0.7;
}

.image-placeholder span {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

/* Latest post images - smaller */
.latest-image {
    aspect-ratio: 16/9;
    max-width: 100%;
}

/* Category page styles */
.category-header {
    margin-bottom: 2rem;
    text-align: center;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.category-description {
    color: #6b7280;
    font-size: 1.1rem;
}

/* Empty state styles */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #374151;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.empty-state .btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.empty-state .btn:hover {
    background: #1d4ed8;
}

.post-featured-image {
    margin-bottom: 2rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.post-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Create Form Styles */
.create-form-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.checkbox-group {
    margin: 1.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 0.75rem;
    transform: scale(1.2);
}

.editor-container {
    height: 400px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.image-preview {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
}

.image-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.remove-image {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.remove-image:hover {
    background: #b91c1c;
}

.current-image {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
}

.current-image img {
    border-radius: 4px;
}

/* Enhanced Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 1000px;
        padding: 0 30px;
    }
    
    .featured-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 2rem;
    }
    
    .featured-image {
        /* Height handled by aspect-ratio */
    }
}

@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr 250px;
        gap: 2rem;
    }
    
    .hero-content h2 {
        font-size: 2.5rem;
    }
    
    .featured-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 2rem;
    }
    
    .featured-image {
        /* Height handled by aspect-ratio */
    }
    
    .blog-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 20px;
    }
    
    .hero {
        padding: 3rem 0;
    }
    
    .hero-content h2 {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-description {
        font-size: 1.1rem;
    }
    
    .featured {
        padding: 1.5rem 0;
    }
    
    .featured-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        max-width: 600px;
    }
    
    .featured-card {
        padding: 1rem;
    }
    
    .featured-image {
        /* Height handled by aspect-ratio */
    }
    
    .image-placeholder {
        font-size: 0.8rem;
    }
    
    .image-placeholder span {
        font-size: 0.7rem;
    }
    
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sidebar {
        position: static;
        order: -1;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .nav .container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .nav-links {
        gap: 1.5rem;
        justify-content: center;
    }
    
    .post-title {
        font-size: 2rem;
    }
    
    .actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .post-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .page-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .hero {
        padding: 2rem 0;
    }
    
    .hero-content h2 {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .hero-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }
    
    .featured {
        padding: 1rem 0;
    }
    
    .featured-grid {
        max-width: 100%;
        gap: 1rem;
    }
    
    .featured-card {
        padding: 0.875rem;
    }
    
    .featured-image {
        /* Height handled by aspect-ratio */
    }
    
    .latest-image {
        /* height handled by aspect-ratio */
    }
    
    .image-placeholder {
        font-size: 0.75rem;
    }
    
    .image-placeholder span {
        font-size: 0.65rem;
    }
    
    .image-placeholder svg {
        width: 60px;
        height: 40px;
    }
    
    
    .card-title a {
        font-size: 1.05rem;
        line-height: 1.4;
    }
    
    .blog-card {
        padding: 1rem;
    }
    
    .create-form-container {
        padding: 1rem;
        margin: 0 10px;
    }
    
    .nav-links {
        gap: 1rem;
        font-size: 0.9rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .card-excerpt {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}
/* Mobile centering fix for latest post images */
@media (max-width: 768px) {
  .blog-card .card-image.latest-image {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    display: block;
  }
  .blog-card .card-image.latest-image img {
    object-fit: cover;
    object-position: center center;
    display: block;
    width: 100%;
    height: 100%;
  }
  .blog-card .card-image.latest-image .image-placeholder {
    width: 100%;
  }
}