/*
 * Blog CMS Styles
 * Primary: #4a5e79
 * Secondary: #4f7f9e, #4ea2be, #52c7d7
 */

:root {
  --primary: #4a5e79;
  --secondary-1: #4f7f9e;
  --secondary-2: #4ea2be;
  --secondary-3: #52c7d7;
  --text: #333;
  --text-light: #666;
  --background: #fff;
  --background-alt: #f5f7fa;
  --border: #ddd;
  --error: #d32f2f;
  --success: #388e3c;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--background);
}

/* Header */
.site-header {
  background: var(--primary);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.nav-brand a {
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

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

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
}

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

.nav-user {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.nav-user-link {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.nav-user-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white !important;
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: calc(100vh - 200px);
}

/* Footer */
.site-footer {
  background: var(--background-alt);
  padding: 2rem;
  text-align: center;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--secondary-1);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 1rem;
}

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

.btn-small {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

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

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

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

.btn-success {
  background: var(--success);
}

/* Flash Messages */
.flash {
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.flash-notice {
  background: #e8f5e9;
  color: var(--success);
  border: 1px solid var(--success);
}

.flash-alert {
  background: #ffebee;
  color: var(--error);
  border: 1px solid var(--error);
}

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

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--secondary-1);
  box-shadow: 0 0 0 2px rgba(79, 127, 158, 0.2);
}

.form-group textarea {
  min-height: 200px;
  resize: vertical;
}

.form-actions {
  margin-top: 1.5rem;
}

.field-hint {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.field_with_errors input,
.field_with_errors textarea {
  border-color: var(--error);
}

.error-messages {
  background: #ffebee;
  border: 1px solid var(--error);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.error-messages h3 {
  color: var(--error);
  margin-bottom: 0.5rem;
}

.error-messages ul {
  margin-left: 1.5rem;
  color: var(--error);
}

/* Cards */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.card-title a {
  color: var(--primary);
  text-decoration: none;
}

.card-title a:hover {
  color: var(--secondary-1);
}

.card-meta {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.card-excerpt {
  color: var(--text);
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary-1) 100%);
  color: white;
  padding: 4rem 2rem;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.25rem;
  opacity: 0.9;
}

/* Post */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.post-meta {
  color: var(--text-light);
}

.post-content {
  line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

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

.post-content code {
  background: var(--background-alt);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--background-alt);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.post-content pre code {
  padding: 0;
  background: none;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
}

.post-content th {
  background: var(--background-alt);
}

/* Comments */
.comments-section {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.comments-section h2 {
  margin-bottom: 1.5rem;
}

.comment {
  border-left: 3px solid var(--secondary-2);
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}

.comment-meta {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.comment-body {
  color: var(--text);
}

.comment-form {
  background: var(--background-alt);
  padding: 1.5rem;
  border-radius: 8px;
  margin-top: 2rem;
}

.comment-form h3 {
  margin-bottom: 1rem;
}

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

.pagination a,
.pagination span {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
}

.pagination a:hover {
  background: var(--background-alt);
}

.pagination .current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--background-alt);
  font-weight: 600;
}

.data-table tr:hover {
  background: var(--background-alt);
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-draft {
  background: #fff3cd;
  color: #856404;
}

.badge-published {
  background: #d4edda;
  color: #155724;
}

.badge-pending {
  background: #fff3cd;
  color: #856404;
}

.badge-approved {
  background: #d4edda;
  color: #155724;
}

.badge-rejected {
  background: #f8d7da;
  color: #721c24;
}

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

.admin-header h1 {
  color: var(--primary);
}

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

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary);
}

.stat-card .stat-label {
  color: var(--text-light);
}

/* Media Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.media-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.media-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.media-item-info {
  padding: 0.75rem;
}

.media-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.filter-tab {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--text-light);
  border-radius: 4px 4px 0 0;
}

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

.filter-tab.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  margin-bottom: -0.5rem;
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.action-buttons .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Markdown preview */
.markdown-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.markdown-editor textarea {
  min-height: 400px;
}

.markdown-preview {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  background: var(--background-alt);
  overflow-y: auto;
  max-height: 500px;
}

/* Media Picker */
.media-picker {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.media-picker h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--primary);
}

.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.25rem;
}

.media-picker-item {
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
  text-align: center;
}

.media-picker-item:hover {
  border-color: var(--secondary-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.media-picker-item img,
.media-picker-item .media-thumb {
  max-width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
}

/* Media thumbnails (when variants not available) */
.media-thumb {
  max-width: 100%;
  max-height: 150px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.media-picker-doc {
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
}

.media-picker-doc .doc-icon {
  font-size: 1.5rem;
}

.media-picker-doc .doc-ext {
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--primary);
  margin-top: 0.25rem;
}

.media-picker-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .markdown-editor {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}
