/* ============================================================
   Keyword Spyglass — Tool-specific styles
   3-color system: green (good) / amber (warning) / red (critical)
   ============================================================ */

.ks-theme {
    /* Text scale */
    --t1: #f0f0f5;
    --t2: #a0a0b5;
    --t3: #6b6b80;
    /* Radii + transitions */
    --r: 16px;
    --rs: 10px;
    --rx: 6px;
    --tr: 0.25s ease;
    /* Status colors (the only 3 allowed) */
    --ks-good: #4ade80;     /* green  — good  */
    --ks-warn: #facc15;     /* amber  — warning */
    --ks-bad:  #f87171;     /* red    — critical */
    --ks-good-bg: rgba(74, 222, 128, 0.10);
    --ks-warn-bg: rgba(250, 204, 21, 0.10);
    --ks-bad-bg:  rgba(248, 113, 113, 0.10);
    --ks-good-bd: rgba(74, 222, 128, 0.30);
    --ks-warn-bd: rgba(250, 204, 21, 0.30);
    --ks-bad-bd:  rgba(248, 113, 113, 0.30);
}

.ks-theme .bg-grad {
    background: radial-gradient(circle at 50% 0%, rgba(29, 124, 110, 0.18) 0%, transparent 70%);
}

/* Hero */
.ks-theme .ks-hero {
    text-align: center;
    max-width: 900px;
    margin: 0 auto 40px;
}
.ks-theme .ks-hero h1 {
    font-size: clamp(2.2rem, 6vw, 4rem);
    font-weight: 800;
    line-height: 1.05;
    margin: 16px 0 12px;
    letter-spacing: -0.02em;
}
.ks-theme .ks-hero h1 .gt {
    background: linear-gradient(135deg, var(--accent, #1D7C6E), var(--accent-gold, #E8C87A));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Input row inherits .url-row from tools-layout.css */
.ks-theme .url-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 28px;
}
.ks-theme .url-input {
    flex: 1 1 320px;
    max-width: 540px;
    padding: 16px 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: #fff;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: var(--tr);
}
.ks-theme .url-input:focus {
    border-color: var(--accent, #1D7C6E);
    background: rgba(255, 255, 255, 0.08);
}
.ks-theme .analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--accent, #1D7C6E);
    color: #fff;
    border: none;
    padding: 16px 30px;
    border-radius: 40px;
    font-weight: 700;
    font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 12px 26px rgba(29, 124, 110, 0.30);
    transition: transform 0.25s, box-shadow 0.25s, background 0.25s;
}
.ks-theme .analyze-btn:hover {
    background: var(--accent-hover, #145F55);
    transform: translateY(-2px);
    box-shadow: 0 18px 32px rgba(29, 124, 110, 0.40);
}

/* Loading + error: inherit .lo / .err-box from tools-layout.css */
.ks-theme .progress-bar {
    width: 280px;
    height: 4px;
    background: rgba(255, 255, 255, 0.10);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}
.ks-theme .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent, #1D7C6E), var(--accent-gold, #E8C87A));
    transition: width 0.4s ease;
}

/* Results layout */
.ks-theme .results {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}
.ks-theme .ks-pdf-container {
    text-align: left;
}

/* Top toolbar */
.ks-theme .top-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.ks-theme .bbtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--rs);
    background: transparent;
    color: var(--t2);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--tr);
    font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ks-theme .bbtn:hover { border-color: var(--accent, #1D7C6E); color: var(--t1); }
.ks-theme .export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--rs);
    background: rgba(255, 255, 255, 0.03);
    color: var(--t2);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--tr);
    font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ks-theme .export-btn:hover { border-color: var(--accent, #1D7C6E); color: var(--t1); }

/* Report header */
.ks-theme .report-header {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--r);
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.ks-theme .report-header .rh-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.ks-theme .report-header .gb {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent, #1D7C6E), var(--accent-gold, #E8C87A));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ks-theme .report-header .gb svg { stroke: #fff; }
.ks-theme .report-header .ut {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--t1);
    word-break: break-all;
}
.ks-theme .report-header .us {
    font-size: 0.78rem;
    color: var(--t3);
    margin-top: 2px;
}
.ks-theme .report-header .rh-right { text-align: right; }
.ks-theme .report-header .opp-score .os-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--t3);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.ks-theme .report-header .opp-score .os-val {
    font-size: 1.4rem;
    font-weight: 800;
}

/* Meta bar — Last Updated + Live data sources badge (sits above report-header) */
.ks-theme .ks-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 18px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--rs);
    font-size: 0.82rem;
}
.ks-theme .ks-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.ks-theme .ks-source-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--ks-good-bg);
    border: 1px solid var(--ks-good-bd);
    border-radius: 20px;
}
.ks-theme .ks-meta-label {
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    font-size: 0.72rem;
}
.ks-theme .ks-meta-val {
    color: var(--t1);
    font-weight: 700;
}
.ks-theme .ks-source-badge .ks-meta-val { color: var(--ks-good); }
.ks-theme .ks-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ks-good);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
    animation: ksLivePulse 1.8s ease-out infinite;
    flex-shrink: 0;
}
@keyframes ksLivePulse {
    0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* Cards */
.ks-theme .r-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--r);
    padding: 22px 24px;
    margin-bottom: 24px;
}
.ks-theme .r-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 10px;
    flex-wrap: wrap;
}
.ks-theme .r-hdr h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--t1);
    margin: 0;
}
.ks-theme .badge-sm {
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    color: var(--t2);
}

/* Summary chart — horizontal bars, vanilla CSS */
.ks-theme .ks-chart-card { padding-bottom: 16px; }
.ks-theme .ks-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 6px;
}
.ks-theme .ks-bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 56px;
    align-items: center;
    gap: 12px;
}
.ks-theme .ks-bar-label {
    font-size: 0.85rem;
    color: var(--t2);
    font-weight: 600;
}
.ks-theme .ks-bar-track {
    height: 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 7px;
    overflow: hidden;
}
.ks-theme .ks-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 7px;
    transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.ks-theme .ks-bar-fill.good { background: var(--ks-good); }
.ks-theme .ks-bar-fill.warn { background: var(--ks-warn); }
.ks-theme .ks-bar-fill.bad  { background: var(--ks-bad); }
.ks-theme .ks-bar-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--t1);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.ks-theme .ks-chart-note {
    margin: 14px 0 0;
    font-size: 0.78rem;
    color: var(--t3);
    line-height: 1.5;
}

/* Score cards */
.ks-theme .scards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}
.ks-theme .sc {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--r);
    padding: 20px 22px;
    text-align: left;
}
.ks-theme .sc .lb {
    font-size: 0.74rem;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 10px;
}
.ks-theme .sc .vl {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}
.ks-theme .sc .sb {
    font-size: 0.78rem;
    color: var(--t3);
    margin-top: 8px;
}
/* Status text colors — only 3 allowed */
.ks-theme .is-good  { color: var(--ks-good); }
.ks-theme .is-warn  { color: var(--ks-warn); }
.ks-theme .is-bad   { color: var(--ks-bad); }

/* Element grid */
.ks-theme .ks-elem-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}
.ks-theme .ks-elem {
    background: rgba(0, 0, 0, 0.20);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 16px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ks-theme .ks-el-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--t1);
    font-variant-numeric: tabular-nums;
}
.ks-theme .ks-el-lb {
    font-size: 0.72rem;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Problems table */
.ks-theme .ks-problems-table { width: 100%; border-collapse: collapse; }
.ks-theme .ks-problems-table th {
    font-size: 0.74rem;
    text-transform: uppercase;
    color: var(--t3);
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.20);
    text-align: left;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.ks-theme .ks-problems-table td {
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    vertical-align: top;
    line-height: 1.5;
}
.ks-theme .ks-problems-table tr:last-child td { border-bottom: none; }
.ks-theme .ks-problems-table td.ks-issue-cell { color: var(--t1); }
.ks-theme .ks-problems-table td.ks-fix-cell  { color: var(--t2); }
.ks-theme .ks-issue-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 8px;
    vertical-align: middle;
}
.ks-theme .ks-issue-tag.bad  { background: var(--ks-bad-bg);  color: var(--ks-bad);  border: 1px solid var(--ks-bad-bd); }
.ks-theme .ks-issue-tag.warn { background: var(--ks-warn-bg); color: var(--ks-warn); border: 1px solid var(--ks-warn-bd); }
.ks-theme .ks-issue-tag.good { background: var(--ks-good-bg); color: var(--ks-good); border: 1px solid var(--ks-good-bd); }
.ks-theme .ks-empty-note {
    margin: 12px 0 0;
    padding: 14px;
    background: var(--ks-good-bg);
    border: 1px solid var(--ks-good-bd);
    border-radius: 10px;
    color: var(--ks-good);
    font-size: 0.9rem;
    text-align: center;
}

/* Insights list */
.ks-theme .ks-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ks-theme .ks-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.92rem;
    color: var(--t1);
    line-height: 1.5;
}
.ks-theme .ks-list-good li::before {
    content: "✓";
    color: var(--ks-good);
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Expectations tags */
.ks-theme .ks-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ks-theme .ks-tags .ks-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--t2);
}

/* Loading + error helpers (in case tools-layout.css not loaded) */
.ks-theme .lo {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: 24px auto 0;
}
.ks-theme .lo.on { display: flex; }
.ks-theme .lo .spinner {
    width: 38px; height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.10);
    border-top-color: var(--accent, #1D7C6E);
    border-radius: 50%;
    animation: ksSpin 0.8s linear infinite;
}
@keyframes ksSpin { to { transform: rotate(360deg); } }
.ks-theme .lo .ltx { font-size: 0.9rem; color: var(--t2); }
.ks-theme .err-box {
    display: none;
    max-width: 620px;
    margin: 20px auto 0;
    padding: 22px 24px;
    background: var(--ks-bad-bg);
    border: 1px solid var(--ks-bad-bd);
    border-radius: 14px;
    text-align: center;
}
.ks-theme .err-box.on { display: block; }
.ks-theme .err-box h4 { color: var(--ks-bad); margin: 0 0 8px; font-size: 1.05rem; }
.ks-theme .err-box p { color: var(--t2); font-size: 0.88rem; line-height: 1.5; margin: 0; }
.ks-theme .err-box .retry-btn {
    margin-top: 14px;
    padding: 10px 22px;
    border: 1px solid var(--ks-bad-bd);
    border-radius: 8px;
    background: var(--ks-bad-bg);
    color: var(--ks-bad);
    cursor: pointer;
    font-size: 0.88rem;
    font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: var(--tr);
}
.ks-theme .err-box .retry-btn:hover { background: rgba(248, 113, 113, 0.18); }

/* Responsive */
@media (max-width: 768px) {
    .ks-theme .scards { grid-template-columns: 1fr; }
    .ks-theme .ks-elem-grid { grid-template-columns: repeat(3, 1fr); }
    .ks-theme .ks-bar-row { grid-template-columns: 100px 1fr 44px; gap: 8px; }
    .ks-theme .url-row { flex-direction: column; align-items: stretch; }
    .ks-theme .url-input { max-width: 100%; }
    .ks-theme .analyze-btn { width: 100%; justify-content: center; }
    .ks-theme .report-header { flex-direction: column; align-items: flex-start; }
    .ks-theme .report-header .rh-right { text-align: left; }
    .ks-theme .top-toolbar { flex-direction: column; align-items: stretch; }
    .ks-theme .top-toolbar .bbtn,
    .ks-theme .top-toolbar .export-btn { width: 100%; justify-content: center; }
    .ks-theme .ks-meta-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .ks-theme .ks-source-badge { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .ks-theme .ks-elem-grid { grid-template-columns: repeat(2, 1fr); }
    .ks-theme .sc .vl { font-size: 1.6rem; }
}
