/* css/insights.css — AI Insights Digest. Layered on shared.css +
   account.css. Delivery preferences genuinely are settings (they reuse
   .settings-group), but "Generate now" and "History" are the working
   part of this page and get their own, less list-like, treatment. */

.insights-intro {
  font-size: var(--text-sm);
  color: var(--text-3);
  margin: 0 0 var(--space-5);
  max-width: 46ch;
}

.insights-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.insights-field:last-child { border-bottom: none; }

.insights-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-1);
}
.insights-field-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: var(--leading-body);
}

.insights-input {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease);
}
.insights-input:focus { outline: none; border-color: var(--accent); }

select.insights-input {
  max-width: 220px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238c8c86' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.insights-page-checks {
  display: flex;
  flex-direction: column;
}

.insights-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px 0;
}
.insights-page-checks .insights-toggle-row {
  padding: 8px 0;
  font-size: var(--text-sm);
  color: var(--text-1);
}

/* ── Switch — used in place of a bare checkbox for the two on/off
     delivery settings; a page's Pages-to-include list stays as plain
     checkboxes since those are a multi-select, not a toggle. ── */
.insights-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
}
.insights-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.insights-switch-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast) var(--ease);
}
.insights-switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease);
}
.insights-switch input:checked + .insights-switch-track { background: var(--accent); }
.insights-switch input:checked + .insights-switch-track::before { transform: translateX(16px); }
.insights-switch input:focus-visible + .insights-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.page-check {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.insights-field-actions {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3) var(--space-4);
}

.insights-submit {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.insights-submit:hover { background: var(--bg-subtle); }
.insights-submit:disabled { opacity: 0.6; cursor: default; }

/* ── Generate now — the page's real primary action, so it gets more
     visual weight than the settings form above it ── */
.insights-generate-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.insights-generate-copy { display: flex; flex-direction: column; gap: 2px; }
.insights-generate-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-1); }
.insights-generate-hint { font-size: var(--text-xs); color: var(--text-3); }

.insights-generate-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.insights-generate-btn:hover { background: var(--accent-hover); }
.insights-generate-btn:disabled { opacity: 0.6; cursor: default; }

.insights-generate-status {
  flex-basis: 100%;
  font-size: var(--text-xs);
  color: var(--text-3);
}
.insights-generate-status[data-tone="error"] { color: var(--danger); }
.insights-generate-status[data-tone="success"] { color: var(--success); }

/* ── History ── */
#digestHistory {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.insights-digest-card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insights-digest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.insights-digest-period {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-1);
}

.insights-digest-highlight {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: var(--leading-body);
}

.insights-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.insights-status--ready      { background: color-mix(in srgb, var(--success) 16%, var(--bg-elevated)); color: var(--success); }
.insights-status--generating { background: var(--accent-subtle); color: var(--accent); }
.insights-status--failed     { background: var(--danger-subtle); color: var(--danger); }
.insights-status i { font-size: 0.85em; }
.insights-status--generating i { animation: insights-spin 1s linear infinite; }
@keyframes insights-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .insights-status--generating i { animation: none; }
}

.insights-digest-delivered {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.insights-digest-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}

.insights-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  color: var(--text-1);
  transition: background var(--duration-fast) var(--ease);
}
.insights-link-btn:hover { background: var(--bg-subtle); }

.insights-link-btn--whatsapp { border-color: #25D366; color: #128C4A; }
@media (prefers-color-scheme: dark) { .insights-link-btn--whatsapp { color: #3ee08a; } }

/* ── States: skeleton, blocked, empty (shared visual language with
     inbox.css's .inbox-state) ── */
/* ── Skeleton — mirrors the actual preferences group, generate panel
     and a history card below it, so nothing reflows once real content
     arrives. Same primitives as inbox.css's .sk classes. ── */
.sk {
  display: inline-block;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--text-1) 6%, transparent), transparent),
    var(--bg-subtle);
  background-size: 200% 100%;
  animation: insights-shimmer 1.5s ease-in-out infinite;
}
.sk-pill { border-radius: var(--radius-full); }
.sk-text { border-radius: 4px; }
.sk-rect { border-radius: var(--radius-sm); }

@keyframes insights-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

.inbox-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.inbox-state i { font-size: 1.75rem; color: var(--text-4); margin-bottom: var(--space-1); }
.inbox-state-title { font-size: var(--text-base); font-weight: 600; color: var(--text-1); }
.inbox-state-desc { font-size: var(--text-sm); color: var(--text-3); max-width: 40ch; }

.insights-empty { padding: var(--space-6) var(--space-4); }

@media (max-width: 480px) {
  .insights-generate-panel { flex-direction: column; align-items: stretch; }
  .insights-generate-btn { justify-content: center; }
}
