﻿/* =============================================
   QA API Tester — Styles
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #111827;
  line-height: 1.55;
  padding-top: 56px;
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  z-index: 100;
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
}

.topbar__title { font-size: 1rem; }

.topbar__nav {
  display: flex;
  gap: 0.4rem;
}

.ctrl-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
  transition: filter 0.15s, opacity 0.15s;
}

.ctrl-btn:hover  { filter: brightness(1.1); }
.ctrl-btn:active { opacity: 0.85; }

.ctrl-btn--stop  { background: #dc2626; }
.ctrl-btn--reset { background: #6b7280; }
.ctrl-btn--pdf   { background: #16a34a; }
.ctrl-btn--todo  { background: #0ea5e9; }

/* ── Main layout ── */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.app-main.app-main--todo-open {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.app-main.app-main--todo-open > .todo-panel {
  grid-column: 2;
  grid-row: 1 / span 3;
  margin-bottom: 0;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}

.app-main.app-main--todo-open > :not(.todo-panel) {
  grid-column: 1;
}

/* ── Todo panel ── */
.todo-panel {
  background: #1f2937;
  border: 1px solid #374151;
  border-left: 4px solid #38bdf8;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.todo-panel__header {
  display: block;
  margin-bottom: 0.45rem;
  line-height: 1.25;
}

.todo-panel__header h3 {
  display: inline;
  margin-right: 0.3rem;
  font-size: 1.08rem;
  color: #ffffff;
}

.todo-panel__header span {
  display: inline;
  font-size: 0.88rem;
  color: #bfdbfe;
  font-weight: 600;
}

.todo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.28rem;
}

.todo-item {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.98rem;
  line-height: 1.28;
  color: #ffffff;
}

.todo-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #93c5fd;
  border-radius: 3px;
  background: #111827;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}

.todo-item input[type="checkbox"]:checked {
  background: #0ea5e9;
  border-color: #7dd3fc;
}

.todo-item input[type="checkbox"]:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: 2px solid #ffffff;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.todo-item--auto {
  color: #ffffff;
  font-weight: 400;
}

.todo-item--auto input[type="checkbox"] {
  border-color: #93c5fd;
}

/* ── Form card ── */
.form-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.input-group {
  margin-bottom: 1rem;
}

.input-group:last-child { margin-bottom: 0; }

.input-group > label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #374151;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fafbfc;
  color: #111827;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input[type="text"]:focus,
textarea:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="text"]::placeholder,
textarea::placeholder { color: #9ca3af; }

textarea {
  height: 140px;
  resize: vertical;
}

.form-footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f3f4f6;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ── Actions section ── */
.actions-section {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.btn-run-all {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
  transition: filter 0.15s, transform 0.1s, box-shadow 0.2s;
}

.btn-run-all:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.38);
}

.btn-run-all:active { transform: scale(0.99); }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.85rem 0.5rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.btn-action:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  transform: translateY(-1px);
}

.btn-action:active { transform: scale(0.97) translateY(0); }

.btn-action__icon  { font-size: 1.35rem; line-height: 1; margin-bottom: 0.1rem; }
.btn-action__label { font-size: 0.8rem;  font-weight: 700; }
.btn-action__sub   { font-size: 0.7rem;  opacity: 0.8; font-weight: 400; }

.btn-action--desktop { background: #2563eb; }
.btn-action--mobile  { background: #ea580c; }
.btn-action--links   { background: #7c3aed; }
.btn-action--anchors { background: #0891b2; }

/* ── Outputs grid ── */
#outputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* ── Section dividers inside grid ── */
.section-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  border-bottom: 1.5px solid #e5e7eb;
  margin-top: 0.4rem;
  border-radius: 4px 4px 0 0;
}

.section-header:first-child { margin-top: 0; }

/* Section color themes */
.section-header--h1      { color: #6d28d9; background: #f5f3ff; border-bottom-color: #c4b5fd; }
.section-header--desktop { color: #1d4ed8; background: #eff6ff; border-bottom-color: #93c5fd; }
.section-header--mobile  { color: #0f766e; background: #f0fdfa; border-bottom-color: #5eead4; }
.section-header--links   { color: #b45309; background: #fffbeb; border-bottom-color: #fcd34d; }
.section-header--anchors { color: #c2410c; background: #fff7ed; border-bottom-color: #fdba74; }

/* Panel accent borders */
.panel--h1      { border-left: 3px solid #7c3aed; }
.panel--desktop { border-left: 3px solid #2563eb; }
.panel--mobile  { border-left: 3px solid #0d9488; }
.panel--links   { border-left: 3px solid #d97706; }
.panel--anchors { border-left: 3px solid #ea580c; }

/* ── Panels ── */
.panel {
  background: #fff;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow 0.2s;
  min-width: 0;
}

.panel:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
}

.panel h3 {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: #374151;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.panel h3 small {
  font-size: 0.72rem;
  font-weight: 400;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel--full { grid-column: 1 / -1; }
.panel--half { grid-column: span 1; }

/* ── Text output ── */
.text-output {
  white-space: pre-wrap;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  color: #374151;
  max-height: 280px;
  overflow-y: auto;
}

.text-output + .text-output { margin-top: 0.5rem; }

/* ── Status badges ── */
.status-ok      { color: #16a34a; font-weight: 700; }
.status-fail    { color: #dc2626; font-weight: 700; }
.status-partial { color: #d97706; font-weight: 700; }

/* ── Word diff output (text reading) ── */
.diff-line {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  margin-bottom: 0.55rem;
  white-space: normal;
}

.diff-line--ok { opacity: 0.7; }
.diff-line--missing,
.diff-line--partial { opacity: 1; }

.diff-badge {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 4px;
  padding: 0.08rem 0.3rem;
  margin: 0 0.2rem;
  vertical-align: baseline;
}

.diff-badge--missing {
  color: #991b1b;
  background: #fee2e2;
}

.diff-badge--partial {
  color: #92400e;
  background: #fef3c7;
}

.diff-meta {
  color: #6b7280;
  font-size: 0.72rem;
}

.diff-row {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
  margin-top: 0.15rem;
  padding-left: 1.1rem;
}

.diff-label {
  min-width: 1.7rem;
  color: #6b7280;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.diff-row--co .diff-text { color: #7f1d1d; }
.diff-row--cp .diff-text { color: #14532d; }

mark.diff-del {
  background: #fecaca;
  color: #7f1d1d;
  border-radius: 2px;
  padding: 0 2px;
}

mark.diff-ins {
  background: #bbf7d0;
  color: #14532d;
  border-radius: 2px;
  padding: 0 2px;
}

/* ── H1 panel ── */
.h1-panel .h1-summary {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.h1-panel .h1-details {
  font-size: 0.82rem;
  color: #6b7280;
  line-height: 1.6;
}

/* ── Links table ── */
.anchors-panel { overflow-x: auto; }
#anchors-output { overflow-x: auto; }

.anchors-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.81rem;
}

.anchors-table th,
.anchors-table td {
  border: 1px solid #e5e7eb;
  padding: 0.4rem 0.55rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Compact variant for anchor validation results */
.anchors-table--sm th,
.anchors-table--sm td {
  padding: 0.2rem 0.4rem;
  font-size: 0.78rem;
}

.anchors-table thead {
  position: sticky;
  top: 0;
}

.anchors-table th {
  background: #f8f9fb;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.anchors-table tbody tr:nth-child(even) { background: #fafafa; }
.anchors-table tbody tr:hover { background: #eff6ff; }

.anchors-table th:nth-child(1),
.anchors-table td:nth-child(1) {
  width: 3rem;
  text-align: center;
  color: #9ca3af;
}

.anchors-table th:nth-child(4),
.anchors-table td:nth-child(4) {
  width: 3.5rem;
  text-align: center;
}

.anchors-table th:last-child,
.anchors-table td:last-child {
  width: 5rem;
  text-align: center;
}

.anchors-url a { color: #2563eb; text-decoration: none; }
.anchors-url a:hover { text-decoration: underline; }
.anchors-url, .anchors-url a { word-break: break-word; overflow-wrap: anywhere; }

.link-check-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 4px;
  padding: 0.12rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.link-check-btn:hover {
  background: #eef2ff;
  border-color: #a5b4fc;
  color: #312e81;
}

.link-find-hit {
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
  background: #fffbeb !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-main { padding: 1rem 1rem 2rem; }
  .app-main.app-main--todo-open {
    display: block;
  }
  .app-main.app-main--todo-open > .todo-panel {
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 1rem;
  }
  .btn-grid { grid-template-columns: repeat(2, 1fr); }
  #outputs { grid-template-columns: 1fr; }
  .panel--full, .panel--half { grid-column: 1; }
  .todo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .topbar__title { font-size: 0.9rem; }
  .ctrl-btn { padding: 0.25rem 0.5rem; font-size: 0.7rem; }
}