/*
 * Modern Blog Application Styles
 */

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 0.5rem;
  --spacing: 1rem;
}

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

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

/* Navigation */
.navbar {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  box-shadow: var(--shadow);
}

.navbar .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing);
  width: 100%;
}

/* Flash Messages */
.flash {
  padding: 1rem;
  margin: 1rem auto;
  max-width: 1200px;
  border-radius: var(--radius);
  text-align: center;
}

.flash-notice {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.flash-alert {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

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

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
  color: white;
  padding: 4rem 0;
  text-align: center;
  margin-bottom: 3rem;
}

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

.hero-subtitle {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background-color: #475569;
}

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

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

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

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

.post-card {
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.post-cover {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-content {
  padding: 1.5rem;
}

.post-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.post-link {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
}

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

.post-excerpt {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.post-likes {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Posts List */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.post-item {
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  transition: transform 0.2s, box-shadow 0.2s;
}

.post-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.post-item-cover {
  width: 300px;
  min-width: 300px;
  height: 200px;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.post-item-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-item-content {
  padding: 1.5rem;
  flex: 1;
}

.post-item-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.post-item-excerpt {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.post-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Post Detail */
.post-detail {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 800px;
  margin: 0 auto;
}

.post-detail-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.post-detail-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.post-detail-meta {
  display: flex;
  gap: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.post-detail-cover {
  width: 100%;
  margin-bottom: 2rem;
  border-radius: var(--radius);
  overflow: hidden;
}

.post-detail-cover img {
  width: 100%;
  height: auto;
  display: block;
}

.post-detail-body {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 2rem;
}

.post-keywords {
  padding: 1rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  color: var(--text-secondary);
}

.post-detail-footer {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* Section Title */
.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.featured-posts {
  margin-top: 3rem;
}

/* No Posts */
.no-posts {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

/* Admin Styles */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.admin-header h1 {
  font-size: 2rem;
  font-weight: 700;
}

.admin-actions {
  display: flex;
  gap: 1rem;
}

.admin-table {
  width: 100%;
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border-collapse: collapse;
}

.admin-table thead {
  background-color: var(--bg-secondary);
}

.admin-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
}

.admin-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.admin-table tbody tr:hover {
  background-color: var(--bg-secondary);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* Forms */
.post-form {
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 800px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

.error-messages {
  background-color: #fee2e2;
  border: 1px solid var(--danger-color);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.error-messages h2 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: #991b1b;
}

.error-messages ul {
  list-style-position: inside;
  color: #991b1b;
}

.current-cover {
  margin-top: 1rem;
}

.cover-thumbnail {
  max-width: 200px;
  height: auto;
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

.cover-preview {
  margin-top: 0.5rem;
}

.cover-preview img {
  max-width: 400px;
  height: auto;
  border-radius: var(--radius);
}

.admin-post-detail {
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field-group {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.field-group:last-child {
  border-bottom: none;
}

.field-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.field-group p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.post-body-preview {
  color: var(--text-primary);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Footer */
.footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  color: var(--text-secondary);
}

/* Rich Text Editor (Trix) Styling */
trix-editor {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 300px;
  background-color: var(--bg-primary);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
}

trix-editor:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

trix-toolbar {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--bg-secondary);
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

trix-toolbar .trix-button-group {
  border: none;
  margin-bottom: 0;
}

trix-toolbar .trix-button {
  border: none;
  border-radius: 4px;
  margin: 0 2px;
}

trix-toolbar .trix-button:hover {
  background-color: var(--bg-primary);
}

trix-toolbar .trix-button.trix-active {
  background-color: #dbeafe;
  color: var(--primary-color);
}

.trix-content {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.trix-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 1.5rem 0 1rem;
  color: var(--text-primary);
}

.trix-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  color: var(--text-primary);
}

.trix-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: var(--text-primary);
}

.trix-content p {
  margin-bottom: 1rem;
}

.trix-content ul,
.trix-content ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.trix-content li {
  margin-bottom: 0.5rem;
}

.trix-content blockquote {
  border-left: 4px solid var(--primary-color);
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius);
  font-style: italic;
}

.trix-content pre {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.trix-content code {
  background-color: var(--bg-secondary);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.trix-content a {
  color: var(--primary-color);
  text-decoration: underline;
}

.trix-content a:hover {
  color: var(--primary-hover);
}

.trix-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .post-item {
    flex-direction: column;
  }

  .post-item-cover {
    width: 100%;
    min-width: 100%;
  }

  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .admin-table {
    font-size: 0.875rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.75rem;
  }

  .actions {
    flex-direction: column;
  }

  .nav-links {
    gap: 1rem;
  }

  trix-toolbar .trix-button-group:not(:first-child) {
    margin-left: 0;
  }
}
