/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Design tokens ===== */
:root {
  --bg-a:             #0b1f2e;
  --bg-b:             #0d2233;
  --bg-c:             #0a1c18;
  --surface:          rgba(255,255,255,0.04);
  --surface-hover:    rgba(255,255,255,0.07);
  --border:           rgba(61,184,122,0.18);
  --border-focus:     rgba(61,184,122,0.5);
  --green:            #3db87a;
  --green-dim:        #2a8c5a;
  --green-glow:       rgba(61,184,122,0.15);
  --text:             #e2ede8;
  --text-sub:         #8fa99a;
  --text-muted:       #546a5c;
  --red:              #ef5350;
  --amber:            #ffa726;
  --radius:           12px;
  --radius-sm:        8px;
  --t:                0.2s ease;
}

/* ===== Base ===== */
html { scroll-behavior: smooth; }

body {
  font-family: 'Heebo', 'Arial Hebrew', Arial, sans-serif;
  background: linear-gradient(145deg, var(--bg-a) 0%, var(--bg-b) 50%, var(--bg-c) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  direction: rtl;
}

/* ===== Layout ===== */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main { flex: 1; padding-bottom: 56px; }

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 52px 0 36px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.logo-img {
  display: block;
  height: 50px;
  width: auto;
  margin: 0 auto;
}

.header-title {
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.header-sub {
  font-size: 0.875rem;
  color: var(--text-sub);
}

/* ===== Input section ===== */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
}

/* ===== Toggle ===== */
.input-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t), box-shadow var(--t);
}

.toggle-btn.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 10px rgba(61,184,122,0.3);
}

.toggle-btn:not(.active):hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ===== Input panels ===== */
.input-panel { margin-bottom: 16px; }

.textarea {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 14px 16px;
  resize: vertical;
  min-height: 160px;
  transition: border-color var(--t), box-shadow var(--t);
  direction: rtl;
}

.textarea::placeholder { color: var(--text-muted); }

.textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--green-glow);
}

.char-count {
  text-align: left;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.url-input {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  padding: 14px 16px;
  direction: ltr;
  transition: border-color var(--t), box-shadow var(--t);
}

.url-input::placeholder { color: var(--text-muted); }

.url-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--green-glow);
}

.url-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 7px;
}

/* ===== Analyze button ===== */
.btn-analyze {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dim) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity var(--t), box-shadow var(--t), transform var(--t);
  box-shadow: 0 4px 18px rgba(61,184,122,0.25);
}

.btn-analyze:hover:not(:disabled) {
  box-shadow: 0 6px 26px rgba(61,184,122,0.4);
  transform: translateY(-1px);
}

.btn-analyze:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(61,184,122,0.3);
}

.btn-analyze:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-icon {
  font-size: 1.1rem;
  transition: transform var(--t);
  display: inline-block;
}

.btn-analyze:hover:not(:disabled) .btn-icon { transform: translateX(-4px); }

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 52px 24px;
  text-align: center;
}

.loading-intro {
  font-size: 1rem;
  color: var(--text-sub);
  line-height: 1.65;
  max-width: 520px;
}

.loading-stages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 280px;
  max-width: 360px;
  width: 100%;
}

.loading-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
  opacity: 0.4;
  transition: color 0.5s ease, opacity 0.5s ease;
  direction: rtl;
}

.loading-stage.active {
  color: var(--green);
  opacity: 1;
}

.loading-stage.done {
  color: var(--text-sub);
  opacity: 0.5;
}

.stage-check {
  color: var(--green);
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.4s ease;
  margin-right: auto;
}

.loading-stage.done .stage-check { opacity: 1; }

.loading-stage.active .stage-icon {
  animation: stagePulse 2.2s ease-in-out infinite;
}

@keyframes stagePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.loading-tip {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.65;
  min-height: 2.8em;
  transition: opacity 0.4s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Report ===== */
.report {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: msgIn 0.45s ease;
}

/* report header card */
.report-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.report-meta { flex: 1; min-width: 0; }

.report-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.page-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.page-type-chip {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--green-glow);
  border: 1px solid var(--border-focus);
  color: var(--green);
  font-weight: 500;
}

.report-summary {
  font-size: 0.88rem;
  color: var(--text-sub);
  line-height: 1.65;
}

/* findings card */
.findings-section,
.rewrite-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.section-title {
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.findings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.finding {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-right: 3px solid transparent;
  padding: 14px 16px;
}

.finding.priority-high   { border-right-color: var(--red); }
.finding.priority-medium { border-right-color: var(--amber); }
.finding.priority-low    { border-right-color: var(--green); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.priority-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.4px;
}

.finding.priority-high   .priority-badge { background: rgba(239,83,80,0.14);  color: var(--red); }
.finding.priority-medium .priority-badge { background: rgba(255,167,38,0.14); color: var(--amber); }
.finding.priority-low    .priority-badge { background: rgba(61,184,122,0.14); color: var(--green); }

.finding-title {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text);
}

.finding-body {
  font-size: 0.86rem;
  color: var(--text-sub);
  line-height: 1.65;
}

/* rewrite */
.rewrite-block { display: flex; flex-direction: column; gap: 12px; }

.rewrite-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}

.rewrite-original {
  background: rgba(239,83,80,0.07);
  border: 1px solid rgba(239,83,80,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.65;
}

.rewrite-suggested {
  background: rgba(61,184,122,0.07);
  border: 1px solid rgba(61,184,122,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.65;
}

/* ===== Login screen ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.footer-image {
  display: block;
  margin: 40px auto 0;
  max-width: 800px;
  width: 100%;
  height: auto;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 36px 40px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 22px 0 28px;
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-password {
  text-align: center;
  letter-spacing: 0.15em;
}

.login-error {
  font-size: 0.875rem;
  color: var(--red);
  margin: 0;
}

/* ===== Phase 4 report ===== */

/* Shared section card */
.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* Quick summary */
.qs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.qs-block {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.qs-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.qs-works    .qs-label { color: var(--green); }
.qs-weakness .qs-label { color: var(--red); }
.qs-start    .qs-label { color: var(--amber); }

.qs-text {
  font-size: 0.875rem;
  color: var(--text-sub);
  line-height: 1.65;
  margin: 0;
}

/* Findings header: title + filter bar on same row */
.findings-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.findings-hd .section-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 5px;
}

.filter-btn {
  padding: 4px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t);
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* Progress bar */
.progress-wrap { margin-bottom: 14px; }

.progress-lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-track {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.35s ease;
}

/* Accordion */
.accordion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accordion-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-right: 3px solid transparent;
  overflow: hidden;
}

.accordion-card[data-priority="high"]   { border-right-color: var(--red); }
.accordion-card[data-priority="medium"] { border-right-color: var(--amber); }
.accordion-card[data-priority="low"]    { border-right-color: var(--green); }

.accordion-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
  background: rgba(0,0,0,0.18);
  user-select: none;
  transition: background var(--t);
  gap: 12px;
}

.accordion-hd:hover { background: rgba(0,0,0,0.28); }

.accordion-hd-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.accordion-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform var(--t);
}

.accordion-card.open .chevron { transform: rotate(180deg); }

/* Priority badges inside accordion */
.priority-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.pb-high   { background: rgba(239,83,80,0.14);  color: var(--red); }
.pb-medium { background: rgba(255,167,38,0.14); color: var(--amber); }
.pb-low    { background: rgba(61,184,122,0.14); color: var(--green); }

/* Accordion body */
.accordion-bd {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
}

.accordion-card.open .accordion-bd { display: flex; }

/* Finding fields */
.finding-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.field-text {
  font-size: 0.875rem;
  color: var(--text-sub);
  line-height: 1.65;
  margin: 0;
}

.current-text {
  background: rgba(255,167,38,0.07);
  border: 1px solid rgba(255,167,38,0.2);
  border-right: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.875rem;
  color: var(--text-sub);
  font-style: italic;
  line-height: 1.65;
  margin: 0;
}

.rewrite-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.suggested-rewrite {
  flex: 1;
  background: rgba(61,184,122,0.07);
  border: 1px solid rgba(61,184,122,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
  margin: 0;
}

.copy-btn {
  flex-shrink: 0;
  padding: 6px 13px;
  background: rgba(61,184,122,0.1);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  color: var(--green);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t);
}

.copy-btn:hover { background: rgba(61,184,122,0.2); }

/* Done checkbox */
.done-row {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.done-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-sub);
}

.done-cb { accent-color: var(--green); width: 14px; height: 14px; }

.finding-done { opacity: 0.38; }
.finding-done .accordion-title { text-decoration: line-through; }

/* Freshness */
.freshness-ok {
  font-size: 0.875rem;
  color: var(--green);
}

.freshness-issue {
  background: rgba(255,167,38,0.06);
  border: 1px solid rgba(255,167,38,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.freshness-issue-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.freshness-correction {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin: 0;
}

/* Check items (fact-check sections) */
.check-category { margin-top: 16px; }

.check-category-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.check-item {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.check-item-hd {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.confidence-label {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
}

.conf-high   { color: rgba(61,184,122,0.75); }
.conf-medium { color: rgba(255,167,38,0.8); }
.conf-low    { color: rgba(143,169,154,0.7); }

.check-issue {
  font-size: 0.875rem;
  color: var(--text-sub);
  line-height: 1.65;
  margin: 0;
}

.check-separator {
  height: 1px;
  margin: 12px 0;
}

.check-correction-box {
  background: rgba(61,184,122,0.07);
  border: 1px solid rgba(61,184,122,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}

.check-correction-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check-correction {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
  margin: 0;
}

/* Markdown export */
.export-row { text-align: center; }

.export-btn {
  padding: 9px 22px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}

.export-btn:hover {
  border-color: var(--border-focus);
  color: var(--text);
}

/* Error card */
.error-card {
  background: rgba(239,83,80,0.07);
  border: 1px solid rgba(239,83,80,0.25);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.error-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 8px;
}

.error-body {
  font-size: 0.875rem;
  color: var(--text-sub);
  line-height: 1.65;
  margin: 0;
}

/* ===== Footer ===== */
.footer {
  margin-top: auto;
  padding-bottom: 20px;
}

/* ===== Responsive ===== */
@media (max-width: 580px) {
  .header { padding: 36px 0 28px; }
  .header-title { font-size: 1.3rem; }
  .logo-img { height: 40px; }
  .input-section { padding: 16px; }
  .report-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .page-types { justify-content: center; }
  .qs-grid { grid-template-columns: 1fr; }
}
