/* ==========================================================================
   Hafzen — demo.css
   Complementary styles for the interactive demo dashboard (demo.html).
   Only adds what styles.css doesn't already provide. Uses the same tokens.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Pages & tab transitions
   -------------------------------------------------------------------------- */
.page { display: none; }
.page.is-active { display: block; animation: page-fade 200ms var(--ease); }
.page > * + * { margin-top: var(--space-6); }

@keyframes page-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.page-head { margin-bottom: 0; }
.page-title { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.page-sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: 4px; }
.section-subhead { font-size: var(--text-lg); letter-spacing: -0.01em; margin-bottom: var(--space-4); }

/* Card header pattern (title + muted right-side note) */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  font-weight: 600;
  font-size: var(--text-base);
  flex-wrap: wrap;
}
.card-head > span:not(.badge) { font-weight: 500; color: var(--text-muted); font-size: var(--text-xs); }
.card-link { font-size: var(--text-sm); color: var(--accent-text); font-weight: 500; }
.card-link:hover { color: var(--accent-hover); }

/* --------------------------------------------------------------------------
   2. Sidebar drawer (mobile) & topbar additions
   -------------------------------------------------------------------------- */
.sidebar-overlay { display: none; }

.app-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.app-nav-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.app-nav-toggle svg { width: 18px; height: 18px; }

.topbar-left { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

/* Company selector (decorative dropdown) */
.company-select { position: relative; }
.company-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.company-btn:hover { background: rgba(255, 255, 255, 0.05); }
.company-btn > svg { width: 14px; height: 14px; color: var(--text-muted); }
.company-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
  flex-shrink: 0;
}
.company-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 60;
}
.company-menu.is-open { display: block; animation: page-fade 150ms var(--ease); }
.company-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.company-menu button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.company-menu button[aria-selected="true"] { color: var(--text); }
.company-menu button .check { margin-left: auto; width: 14px; height: 14px; color: var(--accent-text); }
.company-menu .menu-note {
  padding: 8px 10px 6px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  margin-inline: var(--space-2);
}

/* --------------------------------------------------------------------------
   3. Notice banners (partial / info states)
   -------------------------------------------------------------------------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 12px 16px;
  border: 1px solid rgba(217, 119, 6, 0.25);
  background: var(--warning-soft);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.notice > svg { width: 16px; height: 16px; color: var(--warning-text); flex-shrink: 0; margin-top: 2px; }
.notice strong { color: var(--text); font-weight: 600; }
.notice p { flex: 1; }
.notice button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-xs);
  display: flex;
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease);
}
.notice button:hover { color: var(--text); }
.notice--info { border-color: rgba(49, 87, 213, 0.3); background: var(--accent-soft); }
.notice--info > svg { color: var(--accent-text); }

/* --------------------------------------------------------------------------
   4. Overview extras
   -------------------------------------------------------------------------- */
.score-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.score-hero-side { display: flex; gap: var(--space-8); flex-wrap: wrap; }
.sh-stat .sh-num { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.sh-stat .sh-lab { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.score-strip { display: flex; flex-direction: column; gap: var(--space-5); }
.score-strip .score-display { align-items: center; }
.score-strip-engines { width: 100%; }

/* Change list (What changed / timeline) */
.change-list { display: flex; flex-direction: column; }
.change-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}
.change-item:first-child { border-top: none; padding-top: 0; }
.change-item:last-child { padding-bottom: 0; }
.change-item strong { color: var(--text); font-weight: 550; }
.change-icon {
  width: 22px; height: 22px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.change-icon svg { width: 13px; height: 13px; }
.change-icon--up   { background: var(--success-soft); color: var(--success-text); }
.change-icon--down { background: var(--error-soft);   color: var(--error-text); }
.change-icon--warn { background: var(--warning-soft); color: var(--warning-text); }
.change-icon--info { background: var(--accent-soft);  color: var(--accent-text); }
.change-date {
  width: 52px;
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: 3px;
  font-feature-settings: 'tnum';
}

/* Action preview rows (Overview) */
.action-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.action-row:hover { background: rgba(255, 255, 255, 0.02); }
.action-row:first-child { border-top: none; }
.action-row .badge { flex-shrink: 0; }
.action-row-body { flex: 1; min-width: 0; }
.action-row-title { font-size: var(--text-sm); font-weight: 550; color: var(--text); }
.action-row-impact { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.action-row > svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }

/* --------------------------------------------------------------------------
   5. Filters
   -------------------------------------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 550;
  margin-right: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-wrap svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrap .input { padding-left: 36px; }

.input--select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  width: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   6. Tables — demo extras
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { min-width: 700px; }
.table tbody tr[data-clickable] { cursor: pointer; }
.cell-check { color: var(--success-text); display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }
.cell-check svg { width: 13px; height: 13px; }
.cell-dash { color: var(--text-muted); }
.cell-url {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   7. Modal — wide variant & prompt detail
   -------------------------------------------------------------------------- */
.modal--wide { max-width: 680px; max-height: 85vh; overflow-y: auto; }
.modal-head { margin-bottom: var(--space-5); padding-right: 44px; }

.answer-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface-2);
}
.answer-block + .answer-block { margin-top: var(--space-3); }
.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
}
.answer-text { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.65; }
.brand-mark {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 550;
}
.answer-cites { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cite-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px 9px;
}
.cite-chip svg { width: 10px; height: 10px; }

.insight-box {
  margin-top: var(--space-5);
  border: 1px solid rgba(49, 87, 213, 0.3);
  background: var(--accent-softer);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}
.insight-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.insight-title svg { width: 13px; height: 13px; }

.modal-meta { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.modal-meta .meta-item { font-size: var(--text-xs); color: var(--text-muted); }
.modal-meta .meta-item strong { display: block; font-size: var(--text-md); color: var(--text); font-weight: 650; font-feature-settings: 'tnum'; }

/* --------------------------------------------------------------------------
   8. Competitors
   -------------------------------------------------------------------------- */
.comp-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.comp-logo {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: var(--text-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.comp-name { font-weight: 600; font-size: var(--text-base); }
.comp-domain { font-size: var(--text-xs); color: var(--text-muted); }
.comp-score-row { display: flex; align-items: baseline; gap: var(--space-3); }
.comp-score { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; font-feature-settings: 'tnum'; }
.comp-rates { display: flex; flex-direction: column; gap: 10px; margin-top: var(--space-5); }
.rate-row { display: flex; align-items: center; gap: 10px; font-size: var(--text-xs); color: var(--text-muted); }
.rate-row .rate-label { width: 108px; flex-shrink: 0; }
.rate-row .progress { flex: 1; }
.rate-row .rate-val { width: 36px; text-align: right; color: var(--text-secondary); font-weight: 600; font-feature-settings: 'tnum'; }

.chart-legend { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   9. Citations opportunities
   -------------------------------------------------------------------------- */
.opp-card { display: flex; flex-direction: column; gap: var(--space-3); }
.opp-domain { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.opp-domain svg { width: 14px; height: 14px; color: var(--text-muted); }
.opp-meta { font-size: var(--text-sm); color: var(--text-secondary); }
.opp-sub { font-size: var(--text-xs); color: var(--text-muted); }
.opp-card .btn { align-self: flex-start; margin-top: auto; }

/* --------------------------------------------------------------------------
   10. Actions page
   -------------------------------------------------------------------------- */
.actions-list { display: flex; flex-direction: column; gap: var(--space-5); }
.action-full { display: flex; flex-direction: column; gap: var(--space-4); transition: opacity var(--dur-med) var(--ease); }
.action-full.is-done { opacity: 0.6; }
.action-full h3 { font-size: var(--text-md); letter-spacing: -0.01em; line-height: 1.4; }
.action-why { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.65; }
.action-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.action-impact {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: var(--text-sm);
  color: var(--success-text);
  line-height: 1.5;
}
.action-impact svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }
.action-buttons {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}
.status-tag { font-size: var(--text-xs); font-weight: 600; }
.status-tag--planned { color: var(--accent-text); }
.status-tag--done { color: var(--success-text); }

/* --------------------------------------------------------------------------
   11. Settings & billing
   -------------------------------------------------------------------------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.check-grid { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); color: var(--text-secondary); cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
}

.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; z-index: 1; }
.switch .track {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  transition: background var(--dur-fast) var(--ease);
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur-fast) var(--ease);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-hover); outline-offset: 2px; }

.usage-block { margin-bottom: var(--space-6); }
.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* --------------------------------------------------------------------------
   12. Toasts
   -------------------------------------------------------------------------- */
.toast-wrap {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: var(--text-sm);
  color: var(--text);
  animation: toast-in 200ms var(--ease);
  transition: opacity 200ms var(--ease);
}
.toast svg { width: 15px; height: 15px; color: var(--success-text); flex-shrink: 0; }
.toast.is-leaving { opacity: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   13. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .app-nav-toggle { display: inline-flex; }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 65;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-med) var(--ease), visibility var(--dur-med);
  }
  .sidebar-overlay.is-open { opacity: 1; visibility: visible; }
  .score-strip-engines { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { padding-inline: var(--space-4); }
  .topbar .btn-label { display: none; }
  .topbar .btn--primary { padding: 8px 12px; }
  .score-hero { flex-direction: column; align-items: flex-start; }
  .settings-grid { grid-template-columns: 1fr; }
  .company-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filter-bar { gap: var(--space-3); }
  .page-title { font-size: var(--text-xl); }
  .action-row { align-items: flex-start; }
  .action-row .badge { margin-top: 2px; }
  .action-row > svg { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .page.is-active { animation: none; }
  .toast { animation: none; }
}
