/* ══════════════════════════════════════════════════════
   QUANTRA — ARTICLES, DASHBOARD & FAQ COMPONENTS
   Loaded on top of style.css, reuses its CSS variables.
══════════════════════════════════════════════════════ */

/* ── Toolbar: search + categories ── */
.articles-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.articles-search {
  display: flex;
  gap: 10px;
  flex: 1 1 300px;
  max-width: 440px;
}

.articles-search input[type="search"] {
  flex: 1;
  padding: 13px 18px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--text-dark);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.articles-search input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 144, 254, 0.15);
}

.articles-search .btn {
  padding: 13px 26px;
  font-size: 0.9rem;
}

.articles-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.cat-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cat-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cat-chip span {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── Article cards ── */
.articles-grid {
  align-items: stretch;
}

.article-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
}

.article-card-media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  position: relative;
}

.article-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.article-card:hover .article-card-media img {
  transform: scale(1.05);
}

.article-card-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.article-card-body {
  padding: 26px 26px 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.article-card-meta {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.article-card-more {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.article-card-more:hover {
  text-decoration: underline;
}

/* ── Empty state ── */
.articles-empty {
  text-align: center;
  padding: 80px 20px;
  background: var(--surface);
  border: 1px dashed rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-card);
}

.articles-empty-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  opacity: 0.6;
}

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

.page-link {
  min-width: 44px;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
}

.page-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Single article ── */
.article-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--light-accent);
}

.article-breadcrumb a {
  color: var(--light-accent);
  text-decoration: none;
}

.article-breadcrumb a:hover {
  color: #fff;
  text-decoration: underline;
}

.article-meta-row {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--light-gray);
  font-size: 0.9rem;
}

.article-cover {
  width: 100%;
  height: auto;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  display: block;
  object-fit: cover;
}

.article-body {
  max-width: 780px;
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--text-dark);
}

.article-body h2 {
  font-size: 1.7rem;
  margin: 48px 0 18px;
  color: var(--primary);
  line-height: 1.4;
}

.article-body h3 {
  font-size: 1.32rem;
  margin: 36px 0 14px;
  color: var(--primary);
}

.article-body p {
  margin-bottom: 22px;
  color: var(--text-muted);
}

.article-body ul,
.article-body ol {
  margin: 0 0 24px;
  padding-inline-start: 26px;
  color: var(--text-muted);
}

.article-body li {
  margin-bottom: 10px;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 20px;
  margin: 28px 0;
  display: block;
}

.article-body blockquote {
  margin: 32px 0;
  padding: 22px 28px;
  border-inline-start: 4px solid var(--accent);
  background: rgba(32, 144, 254, 0.06);
  border-radius: 0 18px 18px 0;
  color: var(--text-dark);
  font-size: 1.05rem;
}

.article-body pre {
  background: #0b1220;
  color: #e2e8f0;
  padding: 20px;
  border-radius: 16px;
  overflow-x: auto;
  margin-bottom: 24px;
  direction: ltr;
  text-align: left;
}

.article-body code {
  background: rgba(32, 144, 254, 0.1);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
  direction: ltr;
  display: inline-block;
}

.article-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 26px;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}

.article-body th,
.article-body td {
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 12px 14px;
  text-align: start;
}

.article-body th {
  background: var(--surface-alt);
  font-weight: 600;
}

.article-tags {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── FAQ accordion ── */
.faq-item {
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.faq-item[open] {
  border-color: rgba(32, 144, 254, 0.35);
  box-shadow: var(--shadow-md);
}

.faq-item summary {
  padding: 20px 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.03rem;
  color: var(--text-dark);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  line-height: 1.6;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(32, 144, 254, 0.12);
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.25s ease;
}

.faq-item[open] summary::after {
  content: "\2212";
  transform: rotate(180deg);
}

.faq-item > p {
  padding: 0 24px 22px;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.85;
}

/* ══════════════════════════════════════
   DASHBOARD
══════════════════════════════════════ */
.dash-body {
  background: var(--bg-color);
  min-height: 100vh;
  font-family: var(--font-en);
}

[dir="rtl"] .dash-body {
  font-family: var(--font-ar);
}

.dash-header {
  background: var(--primary);
  color: #fff;
  padding: 18px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.dash-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.dash-brand img {
  height: 30px;
  width: auto;
}

.dash-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.dash-nav a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.dash-nav a:hover,
.dash-nav a.is-active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.dash-main {
  padding: 40px 0 80px;
}

.dash-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.dash-title-row h1 {
  font-size: 1.8rem;
  color: var(--text-dark);
  margin: 0;
}

/* Stat tiles */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.dash-stat {
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 18px;
  padding: 22px 24px;
}

.dash-stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.dash-stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

/* Table */
.dash-panel {
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 20px;
  overflow: hidden;
}

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

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 720px;
}

.dash-table th,
.dash-table td {
  padding: 14px 18px;
  text-align: start;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: middle;
}

.dash-table th {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  font-size: 0.85rem;
}

.dash-table tbody tr:hover {
  background: rgba(32, 144, 254, 0.04);
}

.dash-table td a.title-link {
  color: var(--text-dark);
  text-decoration: none;
  font-weight: 600;
}

.dash-table td a.title-link:hover {
  color: var(--accent);
}

.dash-thumb {
  width: 54px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.dash-thumb-empty {
  width: 54px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  opacity: 0.35;
}

.pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-published {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.pill-draft {
  background: rgba(234, 179, 8, 0.14);
  color: #a16207;
}

.pill-lang {
  background: rgba(32, 144, 254, 0.12);
  color: var(--accent);
}

.dash-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  border-color: rgba(220, 38, 38, 0.3);
  color: #dc2626;
}

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

/* Forms */
.dash-form {
  display: grid;
  gap: 22px;
}

.dash-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}

.field label {
  display: block;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.field .hint {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="url"],
.field input[type="datetime-local"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-dark);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.7;
}

.field textarea.editor {
  min-height: 420px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  direction: ltr;
  text-align: left;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 144, 254, 0.14);
}

.dash-card {
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 20px;
  padding: 28px;
}

.dash-card h2 {
  font-size: 1.15rem;
  margin: 0 0 20px;
  color: var(--primary);
}

.alert {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 22px;
  font-size: 0.92rem;
  font-weight: 500;
}

.alert-success {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.alert-error {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.25);
}

.alert-info {
  background: rgba(32, 144, 254, 0.08);
  color: var(--accent);
  border: 1px solid rgba(32, 144, 254, 0.25);
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #011b29, #023047);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 26px;
  padding: 40px 34px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.login-card img {
  height: 40px;
  margin: 0 auto 26px;
  display: block;
}

.login-card h1 {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 6px;
  color: #023047;
}

.login-card .sub {
  text-align: center;
  color: #71717a;
  font-size: 0.88rem;
  margin-bottom: 28px;
}

.dash-empty {
  padding: 70px 24px;
  text-align: center;
  color: var(--text-muted);
}

.cover-preview {
  max-width: 220px;
  border-radius: 12px;
  margin-top: 12px;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ── Dark mode ── */
[data-theme="dark"] .cat-chip,
[data-theme="dark"] .page-link,
[data-theme="dark"] .articles-search input[type="search"] {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
}

[data-theme="dark"] .cat-chip.is-active,
[data-theme="dark"] .page-link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
}

[data-theme="dark"] .article-card-meta,
[data-theme="dark"] .article-tags,
[data-theme="dark"] .article-body th,
[data-theme="dark"] .article-body td {
  border-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .faq-item {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(148, 163, 184, 0.18);
}

[data-theme="dark"] .articles-empty {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .article-body {
  color: #e2e8f0;
}

[data-theme="dark"] .article-body th {
  background: rgba(15, 23, 42, 0.9);
}

/* ── RTL ── */
[dir="rtl"] .article-body blockquote {
  border-radius: 18px 0 0 18px;
}

@media (max-width: 768px) {
  .articles-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .articles-search {
    max-width: none;
  }

  .article-body {
    font-size: 1rem;
  }

  .article-body h2 {
    font-size: 1.4rem;
  }

  .article-card-body {
    padding: 20px;
  }

  .dash-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-title-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ══════════════════════════════════════
   ZOHO CATEGORY ICON CLUSTERS
══════════════════════════════════════ */
.zoho-cat-icons {
  flex-shrink: 0;
}

.zoho-icon-cluster {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 6px;
  align-content: center;
}

.zoho-cluster-item {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-alt);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: grid;
  place-items: center;
  transition: transform 0.25s ease;
}

.zoho-cluster-item img {
  width: 22px;
  height: 22px;
  display: block;
}

.card:hover .zoho-cluster-item {
  transform: translateY(-2px);
}

.card:hover .zoho-cluster-item:nth-child(2) { transition-delay: 0.04s; }
.card:hover .zoho-cluster-item:nth-child(3) { transition-delay: 0.08s; }
.card:hover .zoho-cluster-item:nth-child(4) { transition-delay: 0.12s; }

/* Three icons look better in a single row */
.zoho-icon-cluster:has(> .zoho-cluster-item:nth-child(3):last-child) {
  grid-template-columns: repeat(3, 34px);
}

[data-theme="dark"] .zoho-cluster-item {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(148, 163, 184, 0.25);
}

@media (max-width: 480px) {
  .zoho-icon-cluster { grid-template-columns: repeat(2, 30px); gap: 5px; }
  .zoho-cluster-item { width: 30px; height: 30px; border-radius: 8px; }
  .zoho-cluster-item img { width: 19px; height: 19px; }
}
