/* Global application styles */

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f9;
  color: #111;
}

.page-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header,
.site-footer {
  background: #000;
  border-bottom: 1px solid #111;
  padding: 1rem 0;
}

.site-header .brand h1,
.site-header .brand p {
  margin: 0;
}

.site-header .brand h1,
.site-header .brand p {
  color: #fff;
}

.site-header .brand p {
  font-size: 0.95rem;
}

.site-header .container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.main-nav {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 1rem;
}

.main-nav-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex: 1;
}

.main-nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
}

.main-nav .nav-link,
.main-nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  background: none;
  border: none;
  padding: 0;
}

.main-nav .nav-link:hover,
.main-nav a:hover {
  text-decoration: none;
  color: #fff;
}

.main-nav .nav-user {
  color: #ddd;
  font-weight: 400;
}

.page-heading {
  margin: 2rem 0 1rem;
}

.page-heading h2 {
  margin-bottom: 0.25rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}

.search-field,
.category-field {
  min-width: 220px;
  flex: 1;
}

.category-select,
input[type="search"] {
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0;
}

.article-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.article-card,
.article-detail,
.comments-section,
.admin-summary,
.admin-table,
form {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.article-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.article-card h3,
.article-detail h2 {
  margin-top: 0;
}

.article-card-title {
  min-height: 3.3rem;
  margin: 0;
  line-height: 1.35;
}

.article-card-meta {
  min-height: 1.5rem;
  margin: 0.55rem 0 0.45rem;
}

.article-card-image {
  height: 185px;
  overflow: hidden;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}

.article-card-image--placeholder {
  background: linear-gradient(135deg, #eef2ff, #e2e8f0);
}

.article-card-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.article-detail-image {
  width: min(480px, 100%);
  height: 300px;
  margin: 1rem auto;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 0;
  box-sizing: border-box;
}

.article-detail-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

@media (max-width: 640px) {
  .article-detail-image {
    width: min(420px, 100%);
    height: 250px;
  }
}

.article-card .article-categories {
  min-height: 2rem;
  margin: 0.25rem 0 0.55rem;
}

.article-card-excerpt {
  margin: 0;
  min-height: 4.9rem;
}

.article-card .article-stats {
  margin-top: auto;
  padding-top: 0.8rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-article {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1.8fr 1fr;
  align-items: center;
  padding: 1.5rem;
  background: #111827;
  color: #f8fafc;
  margin-bottom: 2rem;
}

.hero-article .hero-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-article .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.8rem;
  color: #93c5fd;
  margin: 0;
}

.hero-article h2 {
  margin: 0;
  font-size: clamp(2rem, 2.5vw, 3rem);
}

.hero-article h2 a,
.hero-article h2 a:visited,
.hero-article h2 a:hover {
  color: #fff;
  text-decoration: none;
}

.hero-meta,
.hero-excerpt {
  color: #d1d5db;
}

.hero-excerpt {
  line-height: 1.8;
}

.hero-image {
  border-radius: 1rem;
  overflow: hidden;
  min-height: 320px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.category-section {
  margin-top: 2rem;
}

.articles-index-page {
  padding-bottom: 2.5rem;
}

.category-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.latest-section {
  margin-bottom: 2rem;
}

.article-detail .article-body {
  margin-top: 1.5rem;
}

.article-share {
  margin-bottom: 1rem;
}

.article-share h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: #374151;
}

.article-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.32rem 0.58rem;
  min-width: 5.25rem;
  min-height: 1.72rem;
  font-size: 0.77rem;
  line-height: 1;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
}

.share-button:hover {
  opacity: 0.92;
}

.share-button--x {
  background: #111827;
}

.share-button--facebook {
  background: #1877f2;
}

.share-button--pinterest {
  background: #e60023;
}

.share-button--bluesky {
  background: #0285ff;
}

.share-button--reddit {
  background: #ff4500;
}

.share-button--copy {
  background: #f3f4f6;
  color: #111827;
  border-color: #d1d5db;
}

.share-button--native {
  background: #0f766e;
}

.article-share-status {
  min-height: 1.2rem;
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  color: #4b5563;
}


/* No results message */
.no-results-message {
  text-align: center;
  padding: 2rem 1rem;
  background: #f9f9fb;
  border-radius: 0.75rem;
  margin: 2rem 0;
}

.no-results-message p {
  margin: 0.5rem 0;
  color: #6b7280;
}

.no-results-message p:first-child {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
}

.no-results-message .button {
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .hero-article {
    grid-template-columns: 1fr;
  }

  .article-share-actions {
    gap: 0.45rem;
  }

  .share-button {
    font-size: 0.74rem;
    padding: 0.27rem 0.5rem;
    min-width: 4.95rem;
    min-height: 1.55rem;
  }
}

.article-card p,
.comment p {
  line-height: 1.65;
}

.article-stats,
.comment-meta {
  color: #666;
  font-size: 0.95rem;
}

.button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  font-weight: 600;
  background: #0366d6;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary,
button.secondary,
input[type="submit"].secondary {
  background: #f1f3f5;
  color: #111;
  border-color: #d1d5db;
}

.button.small,
button.small {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.field {
  margin-bottom: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.85rem;
  font: inherit;
}

textarea {
  resize: vertical;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #111;
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
  max-width: 100%;
  width: 100%;
}

.form-group small {
  display: block;
  margin-top: 0.4rem;
  color: #6b7280;
  font-size: 0.85rem;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  color: #111;
  margin-bottom: 0;
}

.form-group input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #0366d6;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.form-errors {
  background: #fff1f0;
  border: 1px solid #f2c1bd;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.form-errors h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.hint {
  margin: 0.4rem 0 0;
  color: #6b7280;
  font-size: 0.95rem;
}

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

.signup-human-check input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #0366d6;
  cursor: pointer;
  margin: 0;
}

.signup-human-check {
  padding: 0.65rem 0.8rem;
  border: 1px solid #cfe0ff;
  background: #f5f9ff;
  border-radius: 0.65rem;
}

.signup-human-check label {
  font-weight: 600;
  cursor: pointer;
}

.actions {
  margin-top: 1.25rem;
}

.flash-messages {
  margin-bottom: 1rem;
}

.flash {
  padding: 0.9rem 1rem;
  border-radius: 0.65rem;
  margin-bottom: 0.75rem;
}

.flash.notice {
  background: #e6fffa;
  color: #0f766e;
}

.flash.alert {
  background: #fef3c7;
  color: #92400e;
}

.site-footer {
  margin-top: auto;
  padding: 1rem 0;
  background: #000;
  color: #fff;
}

/* Admin Navigation */
/* Removed dropdown admin menu styling because admin items are now top-level links */

/* Dashboard Stats */
.dashboard-stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 2rem 0;
}

.stat-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}

.stat-card h3 {
  margin: 0 0 0.5rem;
  font-size: 2.5rem;
  color: #0366d6;
}

.stat-card p {
  margin: 0;
  color: #6b7280;
  font-size: 0.95rem;
}

.account-shell {
  display: grid;
  gap: 1.5rem;
  margin: 2rem 0;
}

.account-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.account-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.account-card h3,
.account-card h4 {
  margin-top: 0;
}

.account-avatar {
  width: 120px;
  height: 120px;
  margin-bottom: 1rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #e5e7eb;
}

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

.account-meta {
  display: grid;
  gap: 0.75rem;
}

.account-meta p {
  margin: 0;
}

.account-links {
  display: grid;
  gap: 0.4rem;
}

.account-links p {
  margin: 0;
}

.account-links a {
  color: #0366d6;
  text-decoration: none;
}

.account-links a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .page-heading {
    margin: 1.5rem 0 0.75rem;
  }

  .account-shell,
  .admin-panels,
  .dashboard-stats {
    gap: 1rem;
  }

  .account-card,
  .article-card,
  .article-detail,
  .comments-section,
  .admin-summary,
  .admin-table,
  form,
  .stat-card {
    padding: 1rem;
  }

  .account-avatar {
    width: 88px;
    height: 88px;
  }

  .account-form .actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.account-form {
  max-width: 760px;
}

.account-form textarea,
.account-form input[type="text"],
.account-form input[type="email"],
.account-form input[type="password"] {
  width: 100%;
}

/* Admin Panels */
.admin-panels {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin: 2rem 0;
}

.admin-panel {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-header h3 {
  margin: 0;
}

.panel-header p {
  margin: 0;
}

.panel-header .link {
  color: #0366d6;
  text-decoration: none;
  font-size: 0.95rem;
}

.panel-header .link:hover {
  text-decoration: underline;
}

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

.admin-table thead {
  background: #f7f7f9;
  border-bottom: 2px solid #e6e6e6;
}

.admin-table thead th {
  padding: 0.85rem;
  text-align: left;
  font-weight: 600;
  color: #111;
  font-size: 0.95rem;
}

.admin-table tbody tr {
  border-bottom: 1px solid #e6e6e6;
}

.admin-table tbody tr:hover {
  background: #f9f9fb;
}

.admin-table td {
  padding: 0.85rem;
  font-size: 0.95rem;
}

.admin-table a {
  color: #0366d6;
  text-decoration: none;
}

.admin-table a:hover {
  text-decoration: underline;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #4338ca;
}

.badge.published {
  background: #dcfce7;
  color: #166534;
}

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

.badge.admin-pin {
  background: #111827;
  color: #f9fafb;
  margin-right: 0.4rem;
}

.admin-users-panel--admins {
  border: 2px solid #0f766e;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.12);
  position: relative;
}

.admin-users-panel--admins::before {
  content: "Admins pinned";
  position: absolute;
  top: -0.8rem;
  left: 1rem;
  background: #0f766e;
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.admin-users-panel--members {
  border-left: 4px solid #cbd5e1;
}

.user-actions {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.admin-table .user-actions form.button_to {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
}

.comment-admin-actions {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.admin-table .comment-admin-actions form.button_to {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
}

/* Comments List */
.comment-item {
  padding: 1rem 0;
  border-bottom: 1px solid #e6e6e6;
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-meta {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.comment-meta .timestamp {
  color: #999;
  margin-left: 0.5rem;
}

.comment-item p {
  margin: 0.5rem 0 0;
  line-height: 1.5;
}

.comment-reactions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
  color: #4b5563;
}

.comment-reaction-form {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
}

.comment-reaction-button,
.comment-reaction-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  text-decoration: none;
  font-size: 1.15rem;
}

.comment-reaction-button {
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 0.35rem;
  border: 1px solid transparent;
}

.comment-reaction-button:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.comment-reaction-button.is-active {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

.comment-reaction-count {
  min-width: 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1f2937;
  margin-right: 0.35rem;
}

.reply-form-wrap {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.9rem;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 0.6rem;
}

.comment-replies {
  margin-top: 0.75rem;
  padding-left: 1rem;
  border-left: 2px solid #e5e7eb;
  display: grid;
  gap: 0.75rem;
}

.comment-reply {
  background: #fbfdff;
  border: 1px solid #e5edf9;
  border-radius: 0.65rem;
  padding: 0.8rem;
}

.signup-honeypot {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* Categories */
.article-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.category-tag {
  display: inline-block;
  background: #e0e7ff;
  color: #4338ca;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0;
}

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

.category-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Quill Editor */
.ql-toolbar {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #f9f9fb;
}

.ql-container {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  border: 1px solid #d1d5db;
  border-top: none;
  font-size: 1rem;
}

.ql-editor {
  min-height: 300px;
  padding: 1rem;
}

.ql-editor.ql-blank::before {
  color: #9ca3af;
  font-style: italic;
}

/* Quill Editor Extended */
#article_body_editor {
  margin-top: 0.35rem;
}

#article_body_editor .ql-toolbar {
  position: sticky;
  top: 0.5rem;
  z-index: 5;
}

#article_body_editor .ql-editor {
  min-height: 720px;
}

.pagination-nav {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pagination-label {
  font-size: 0.95rem;
  color: #4b5563;
}

.weekly-share-count {
  margin: 0.5rem 0 0;
  color: #0f766e;
  font-weight: 600;
}

.category-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.admin-table .category-actions form.button_to {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
}

.category-action-button {
  min-width: 4.25rem;
  color: #111;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.analytics-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem;
  background: #f8fafc;
}

.analytics-card h4 {
  margin: 0 0 0.65rem;
}

.analytics-card p {
  margin: 0.35rem 0;
  color: #374151;
}

.trend-up {
  color: #047857;
}

.trend-down {
  color: #b91c1c;
}

.trend-flat {
  color: #6b7280;
}

.trend-table-wrap {
  overflow-x: auto;
}

.trend-table td {
  vertical-align: middle;
}

.trend-date {
  color: #6b7280;
  font-size: 0.85rem;
}

.spark-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 160px;
}

.spark-value {
  width: 2.2rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #111827;
}

.spark-track {
  display: inline-block;
  width: 100%;
  height: 0.5rem;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.spark-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.spark-fill--views {
  background: #2563eb;
}

.spark-fill--likes {
  background: #0d9488;
}

.spark-fill--comments {
  background: #f97316;
}

.spark-fill--shares {
  background: #7c3aed;
}
