/* Blog page layout */
.blog-main {
  padding: 30px 0 60px;
}

/* Controls bar */
.blog-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.blog-search-group {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.blog-search-group input[type="text"] {
  flex: 1;
  width: auto;
  max-width: none;
  padding: 9px 14px;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.blog-search-group select {
  width: auto;
  min-width: 160px;
  padding: 9px 10px;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.blog-actions {
  display: flex;
  gap: 10px;
}

.blog-write-btn {
  background-color: #bfa059;
  color: white;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.blog-write-btn:hover {
  background-color: #a08040;
}

/* Blog grid */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}

.blog-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  padding: 40px 0;
}

.blog-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  padding: 60px 0;
}

/* Pagination */
.blog-pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
}

.page-btn {
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.page-btn:hover:not([disabled]) {
  background: #fff8e1;
  border-color: #bfa059;
}

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

.page-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

/* Blog card */
.blog-card {
  background: #fff;
  border: 1px solid #e8d9a0;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 2px 12px rgba(191,160,89,0.10);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blog-card:hover {
  box-shadow: 0 6px 22px rgba(191,160,89,0.22);
  transform: translateY(-2px);
}

.blog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.blog-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #333;
  margin: 0;
  flex: 1;
}

.blog-category-badge {
  background: #fff3cd;
  color: #7a5c20;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  border: 1px solid #e8d9a0;
}

.blog-card-meta {
  font-size: 0.8rem;
  color: #888;
}

.blog-card-excerpt {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.6;
  flex: 1;
}

.blog-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f0e8cc;
  padding-top: 10px;
  font-size: 0.82rem;
  color: #888;
  gap: 8px;
}

.blog-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.blog-tag {
  background: #fffaf0;
  border: 1px solid #e8d9a0;
  color: #a07828;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Star rating */
.stars-display {
  display: inline-flex;
  gap: 2px;
  font-size: 1rem;
}

.star {
  color: #ccc;
  cursor: default;
}

.star.filled {
  color: #ffc107;
}

.star.interactive {
  cursor: pointer;
  transition: color 0.1s;
}

.star.interactive:hover,
.star.interactive.hovered {
  color: #ffd700;
}

.rating-count {
  font-size: 0.78rem;
  color: #888;
  margin-left: 4px;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  z-index: 1000;
  overflow-y: auto;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 560px;
  max-width: 95vw;
  min-width: 320px;
  max-height: 90vh;
  min-height: 220px;
  overflow: auto;
  resize: both;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.modal-box-lg {
  width: 760px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 26px 16px;
  border-bottom: 1px solid #e8d9a0;
  /* .modal-box scrolls internally when resized smaller than its content, so
     the header (with the close button) stays put instead of scrolling away. */
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-header h2 {
  margin: 0;
  border: none;
  padding: 0;
  font-size: 1.2rem;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 22px 26px 26px;
}

/* Forms inside modals */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 5px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: none;
  padding: 9px 12px;
  font-size: 0.93rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  resize: vertical;
}

.form-group textarea {
  min-height: 180px;
  text-align: left;
}

.required {
  color: #dc3545;
}

.hint {
  font-weight: 400;
  color: #888;
  font-size: 0.8rem;
}

.submit-note {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 14px;
}

.form-msg {
  font-size: 0.88rem;
  margin-bottom: 10px;
  min-height: 20px;
}

.form-msg.success {
  color: #28a745;
}

.form-msg.error {
  color: #dc3545;
}

.modal-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.my-blog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.my-blog-row:last-child {
  border-bottom: none;
}

.my-blog-info .my-blog-title {
  font-weight: 600;
}

.my-blog-info .my-blog-meta {
  font-size: 0.8rem;
  color: #777;
  margin-top: 2px;
}

.status-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  text-transform: uppercase;
  margin-left: 8px;
}

.status-badge.pending { background: #c99b2f; }
.status-badge.approved { background: #4a8f4a; }
.status-badge.rejected { background: #a33; }

.btn-primary {
  background-color: #bfa059;
  color: white;
  padding: 10px 22px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: #a08040;
}

.btn-primary:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #fff;
  color: #7a5c20;
  border: 1px solid #e8d9a0;
  padding: 7px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.btn-secondary:disabled {
  color: #aaa;
  cursor: not-allowed;
}

.video-insert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.video-insert-row .form-msg {
  margin-bottom: 0;
  min-height: auto;
}

.ck-editor__editable {
  min-height: 220px;
}

/* Blog detail inside modal */
.detail-meta {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.detail-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fffaf0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 22px;
}

.detail-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #7a5c20;
  margin: 22px 0 12px;
  border-bottom: 1px solid #e8d9a0;
  padding-bottom: 6px;
}

/* Rating widget in detail */
.rating-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.rating-widget .stars-interactive {
  display: inline-flex;
  gap: 4px;
  font-size: 1.4rem;
}

.rating-widget .stars-interactive .star {
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
}

.rating-widget .stars-interactive .star:hover {
  transform: scale(1.15);
  color: #ffd700;
}

.rating-already {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}

/* Comments */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.comment-item {
  background: #f9f5eb;
  border: 1px solid #e8d9a0;
  border-radius: 8px;
  padding: 12px 16px;
}

.comment-author {
  font-weight: 600;
  font-size: 0.88rem;
  color: #7a5c20;
}

.comment-date {
  font-size: 0.78rem;
  color: #aaa;
  margin-left: 8px;
}

.comment-text {
  font-size: 0.9rem;
  color: #444;
  margin-top: 6px;
  word-break: break-word;
}

.no-comments {
  font-size: 0.88rem;
  color: #aaa;
  font-style: italic;
}

/* Add comment form */
.add-comment-form {
  border: 1px solid #e8d9a0;
  border-radius: 8px;
  padding: 16px;
  background: #fffdf8;
}

.add-comment-form h4 {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: #555;
}

.add-comment-form input,
.add-comment-form textarea {
  width: 100%;
  max-width: none;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-family: inherit;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.add-comment-form textarea {
  min-height: 80px;
  resize: vertical;
  text-align: left;
}

/* Content type toggle in write modal */
.content-type-toggle {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  color: #555;
  font-weight: 500;
  cursor: pointer;
}

.radio-label input[type="radio"] {
  width: auto;
  min-width: auto;
  cursor: pointer;
  accent-color: #bfa059;
}

.html-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f8f0;
  border: 1px solid #c3e6cb;
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 0.88rem;
  color: #155724;
  font-weight: 500;
}

.clear-file-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  margin: 0;
  line-height: 1;
}

.clear-file-btn:hover {
  color: #dc3545;
}

/* HTML badge in admin */
.badge-html {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 8px;
  background: #e8f4fd;
  color: #0c5460;
  border: 1px solid #bee5eb;
  letter-spacing: 0.03em;
}

/* ── Blog post page ─────────────────────────────────────────────────── */

.blog-post-main {
  padding: 30px 0 60px;
  max-width: 860px;
}

.blog-post-back {
  margin-bottom: 24px;
}

.back-link {
  color: #bfa059;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.back-link:hover {
  text-decoration: underline;
}

.blog-post-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0e8cc;
}

.blog-post-title {
  font-size: 2rem;
  color: #222;
  margin-bottom: 14px;
  font-weight: 700;
  line-height: 1.3;
  border: none;
  padding: 0;
}

.blog-post-section {
  margin-top: 36px;
}

/* Uploaded HTML content area */
.blog-html-content {
  font-size: 1rem;
  line-height: 1.85;
  color: #333;
  word-break: break-word;
}

.blog-html-content h1,
.blog-html-content h2,
.blog-html-content h3,
.blog-html-content h4 {
  color: #222;
  border: none;
  margin-top: 1.4em;
  margin-bottom: 0.5em;
}

.blog-html-content p {
  margin-bottom: 1em;
}

.blog-html-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
}

.blog-html-content video {
  max-width: 100%;
  border-radius: 6px;
  margin: 12px 0;
  background: #000;
}

.blog-html-content iframe {
  max-width: 100%;
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  border: none;
  border-radius: 6px;
  margin: 12px 0;
}

.blog-html-content a {
  color: #bfa059;
}

.blog-html-content ul,
.blog-html-content ol {
  padding-left: 1.6em;
  margin-bottom: 1em;
}

.blog-html-content blockquote {
  border-left: 4px solid #bfa059;
  padding: 8px 16px;
  color: #666;
  font-style: italic;
  margin: 1.2em 0;
  background: #fffdf5;
  border-radius: 0 6px 6px 0;
}

.blog-html-content pre,
.blog-html-content code {
  background: #f4f4f4;
  border-radius: 4px;
  font-size: 0.88em;
  padding: 2px 6px;
}

.blog-html-content pre {
  padding: 14px 18px;
  overflow-x: auto;
  margin-bottom: 1em;
}

.blog-html-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

.blog-html-content th,
.blog-html-content td {
  border: 1px solid #e0d3ad;
  padding: 8px 10px;
  text-align: left;
}

.blog-html-content th {
  background: #fdf6e3;
}

@media (max-width: 600px) {
  .blog-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .blog-search-group {
    flex-direction: column;
  }

  .blog-actions {
    justify-content: flex-end;
  }

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

  .modal-overlay {
    padding: 16px 8px;
  }
}
