/* frontend/css/blog-modern.css */

:root {
  --primary-color: #5D5FEF;
  --primary-hover: #4B4EE6;
  --secondary-color: #2ecc71;
  --accent-color: #45B7D1;
  --dark-bg: #1e293b;
  --light-bg: #f8fafc;
  --white: #ffffff;
  --text-dark: #1e293b;
  --text-gray: #64748b;
  --border-color: #e2e8f0;
  --border-radius: 12px;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font-family);
  background-color: var(--light-bg);
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

.blog-page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px 20px 40px; /* Top padding for fixed header */
}

/* Header Section */
.blog-hero {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, rgba(93, 95, 239, 0.1) 0%, rgba(69, 183, 209, 0.1) 100%);
  border-radius: 20px;
  margin-bottom: 50px;
}

.blog-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 15px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.blog-hero p {
  font-size: 1.1rem;
  color: var(--text-gray);
  max-width: 600px;
  margin: 0 auto;
}

/* Main Grid Layout */
.blog-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 40px;
}

@media (max-width: 992px) {
  .blog-layout {
    grid-template-columns: 1fr;
  }
}

/* Blog Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 30px;
}

.blog-card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.blog-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--hover-shadow);
}

.blog-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background-color: #eee;
}

.blog-card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.blog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-gray);
}

.blog-category {
  background-color: rgba(93, 95, 239, 0.1);
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.75rem;
}

.blog-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  line-height: 1.4;
}

.blog-title a {
  color: var(--text-dark);
  text-decoration: none;
  transition: color 0.2s;
}

.blog-title a:hover {
  color: var(--primary-color);
}

.blog-excerpt {
  font-size: 0.95rem;
  color: var(--text-gray);
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

.blog-footer {
  margin-top: auto;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.read-more-link {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.read-more-link:hover {
  text-decoration: underline;
}

/* Sidebar Styles */
.blog-sidebar {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.sidebar-widget {
  background: var(--white);
  padding: 25px;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
}

.widget-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--light-bg);
  position: relative;
}

.widget-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50px;
  height: 2px;
  background-color: var(--primary-color);
}

/* Categories List */
.categories-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.categories-list li {
  margin-bottom: 10px;
}

.categories-list a {
  display: flex;
  justify-content: space-between;
  color: var(--text-gray);
  text-decoration: none;
  transition: color 0.2s;
  padding: 5px 0;
}

.categories-list a:hover, .categories-list a.active {
  color: var(--primary-color);
  font-weight: 500;
}

/* Affirmation Widget */
.affirmation-widget {
  background: linear-gradient(135deg, rgba(93, 95, 239, 0.05), rgba(69, 183, 209, 0.05));
  border: 1px solid rgba(93, 95, 239, 0.1);
}

.affirmation-content {
  font-style: italic;
  color: var(--text-dark);
  margin-bottom: 10px;
  font-size: 1.05rem;
  line-height: 1.5;
}

.affirmation-theme {
  font-size: 0.8rem;
  color: var(--primary-color);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Featured Posts Widget */
.featured-item {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.featured-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.featured-thumb {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.featured-info h4 {
  font-size: 0.95rem;
  margin: 0 0 5px 0;
  line-height: 1.3;
}

.featured-info a {
  color: var(--text-dark);
  text-decoration: none;
  transition: color 0.2s;
}

.featured-info a:hover {
  color: var(--primary-color);
}

.featured-date {
  font-size: 0.8rem;
  color: var(--text-gray);
}

/* Modal Styles */
.blog-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none; /* Toggled via JS */
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.blog-modal-container {
  background: var(--white);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 25px;
  border-bottom: 1px solid var(--border-color);
  background: var(--white);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-gray);
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-dark);
}

.modal-scroll-content {
  overflow-y: auto;
  padding: 30px;
  line-height: 1.8;
}

.modal-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain; /* changed from cover to contain per request */
  background-color: #f1f5f9;
  border-radius: 12px;
  margin-bottom: 30px;
}

.post-full-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 15px;
  color: var(--text-dark);
  line-height: 1.2;
}

.post-full-meta {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  font-size: 0.9rem;
  color: var(--text-gray);
}

.post-full-content {
  font-size: 1.1rem;
  color: #334155;
}

.post-full-content h2 {
  margin-top: 30px;
  margin-bottom: 15px;
  font-size: 1.5rem;
  color: var(--text-dark);
}

.post-full-content p {
  margin-bottom: 20px;
}

.post-full-content ul, .post-full-content ol {
  margin-bottom: 20px;
  padding-left: 20px;
}

.post-full-content li {
  margin-bottom: 8px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 50px;
}

.page-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 600;
}

.page-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.page-btn.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Loading State */
.loading-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-gray);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(93, 95, 239, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Dark Mode Support */
[data-theme="dark"] {
  --light-bg: #0f172a;
  --white: #1e293b;
  --text-dark: #f1f5f9;
  --text-gray: #94a3b8;
  --border-color: #334155;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .blog-hero {
  background: linear-gradient(135deg, rgba(93, 95, 239, 0.2) 0%, rgba(69, 183, 209, 0.2) 100%);
}

[data-theme="dark"] .blog-card-image,
[data-theme="dark"] .modal-image {
  background-color: #334155;
}

/* References Section in Blog Content */
.references-list {
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.references-list li {
  margin-bottom: 5px;
  word-break: break-word;
}
