/*
 * SERP Checker - tool-specific styles.
 *
 * Composes the shared primitives from code/assets/css/tools.css
 * (.tool-form-card, .mode-toggle, .input-form, .text-input,
 * .primary-btn, .results-region, .results-table, etc.). Only
 * tool-specific overrides + new bits live here.
 */

/* ----- form labels (every tool defines its own .field-label) ------ */

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin: 14px 0 6px 0;
}
.field-label:first-child {
    margin-top: 0;
}

.form-hint {
    margin: 14px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-sm);
    background: var(--ink-50);
    color: var(--ink-700);
    font-size: 13px;
}
.form-hint a {
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}
.form-hint a:hover {
    text-decoration: underline;
}

/* ----- form rows: stack label above input, full-width input ------ */

.sc-keyword-row,
.sc-bulk-row,
.sc-location-row,
.sc-device-row,
.sc-submit-row {
    display: block;
}

.sc-keyword-row[hidden],
.sc-bulk-row[hidden],
.sc-location-row[hidden],
.sc-device-row[hidden],
.sc-submit-row[hidden] {
    display: none;
}

/* Override the shared .text-input flex-basis (only valid inside an
 * .input-row flex parent) so single keyword + location inputs span
 * the full row width. */
.sc-keyword-row .text-input,
.sc-location-row .text-input,
.sc-bulk-row .text-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.sc-bulk-textarea {
    resize: vertical;
    min-height: 140px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.55;
}

.sc-submit-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 18px;
}

.sc-submit-row .primary-btn {
    align-self: flex-start;
}

.sc-submit-row .form-hint {
    margin: 0;
}

/* ----- location autocomplete ------------------------------------- */

.sc-location-control {
    position: relative;
}

.sc-location-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid var(--ink-200, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.sc-location-dropdown[hidden] { display: none; }

.sc-location-option {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--ink-100, #f3f4f6);
    transition: background 0.1s ease;
}

.sc-location-option:last-child { border-bottom: none; }

.sc-location-option:hover,
.sc-location-option.is-focused {
    background: var(--ink-50, #f9fafb);
}

.sc-location-option .sc-loc-name {
    color: var(--ink-900, #111827);
    font-weight: 500;
    font-size: 13px;
}

.sc-location-option .sc-loc-meta {
    color: var(--ink-500, #6b7280);
    font-size: 11px;
    margin-top: 2px;
}

.sc-location-option .sc-loc-type-pill {
    display: inline-block;
    background: var(--ink-100, #f3f4f6);
    color: var(--ink-700, #374151);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 6px;
}

.sc-location-no-results {
    padding: 16px;
    text-align: center;
    color: var(--ink-500, #6b7280);
    font-size: 13px;
}

/* ----- device pill ----------------------------------------------- */

.sc-device-pill {
    display: inline-flex;
    background: var(--ink-100, #f3f4f6);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
}

.sc-device-btn {
    background: transparent;
    border: 0;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--ink-700, #374151);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}

.sc-device-btn:hover {
    color: var(--ink-900, #111827);
}

.sc-device-btn.is-active {
    background: #fff;
    color: var(--brand-700, #1d4ed8);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ----- focus-keyword stats card --------------------------------- */

.sc-keyword-stats-card {
    background: var(--brand-50, #eef2ff);
    border: 1px solid var(--brand-100, #e0e7ff);
    border-radius: 10px;
    padding: 14px 16px;
    margin-top: 16px;
}

.sc-keyword-stats-card[hidden] { display: none; }

.sc-keyword-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.sc-keyword-stats-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sc-keyword-stats-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-500, #6b7280);
    font-weight: 600;
}

.sc-keyword-stats-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink-900, #111827);
    font-variant-numeric: tabular-nums;
}

.sc-keyword-stats-value .muted { color: var(--ink-400, #9ca3af); font-weight: 400; }

.sc-keyword-stats-trend .sc-keyword-stats-value {
    min-height: 24px;
}

.sc-keyword-stats-trend svg {
    width: 100%;
    height: 24px;
    overflow: visible;
}

/* ----- SERP features region ------------------------------------- */

.features-region {
    background: var(--ink-50, #f9fafb);
    border: 1px solid var(--ink-200, #e5e7eb);
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 16px;
}

.features-region[hidden] { display: none; }

.feature-block {
    background: #fff;
    border: 1px solid var(--ink-200, #e5e7eb);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.feature-block:last-child { margin-bottom: 0; }

.feature-block-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-700, #374151);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 8px;
}

.feature-block-title .feature-icon {
    color: var(--brand-600, #4f46e5);
}

.feature-block-body {
    color: var(--ink-800, #1f2937);
    font-size: 14px;
    line-height: 1.5;
}

.feature-block-body a {
    color: var(--brand-700, #1d4ed8);
    text-decoration: none;
}

.feature-block-body a:hover { text-decoration: underline; }

.feature-fs-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.feature-paa-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.feature-paa-list li {
    padding: 6px 0;
    border-top: 1px dashed var(--ink-200, #e5e7eb);
}

.feature-paa-list li:first-child { border-top: 0; }

.feature-localpack-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.feature-localpack-list li {
    padding: 6px 0;
    border-top: 1px dashed var(--ink-200, #e5e7eb);
    font-size: 13px;
}

.feature-localpack-list li:first-child { border-top: 0; }

.feature-localpack-list strong { color: var(--ink-900, #111827); }

.feature-related-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.feature-related-list li a {
    display: inline-block;
    background: var(--ink-100, #f3f4f6);
    border-radius: 999px;
    padding: 4px 10px;
    color: var(--ink-700, #374151);
    text-decoration: none;
    font-size: 13px;
}

.feature-related-list li a:hover {
    background: var(--ink-200, #e5e7eb);
    color: var(--ink-900, #111827);
}

/* AI Overview flag (when DataForSEO confirms an AI Overview is shown
 * but doesn't include the content inline). The pill makes it clear
 * this is a binary signal, not a truncated answer. */
.feature-flag-pill {
    display: inline-block;
    background: linear-gradient(90deg, #eef2ff 0%, #fef3c7 100%);
    color: var(--ink-800, #1f2937);
    border: 1px solid var(--ink-200, #e5e7eb);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
}

/* ----- collapsible feature details ------------------------------ */

.feature-teaser {
    margin: 0 0 8px;
    color: var(--ink-800, #1f2937);
    line-height: 1.55;
}

.feature-details {
    margin-top: 8px;
}

.feature-details[open] .feature-details-label::after {
    content: '\2191';  /* up arrow when open */
}
.feature-details-label::after {
    content: '\2193';  /* down arrow when closed */
    margin-left: 6px;
    font-weight: 500;
}

.feature-details-summary {
    cursor: pointer;
    list-style: none;
    color: var(--brand, #4f46e5);
    font-weight: 500;
    font-size: 13px;
    padding: 4px 0;
    user-select: none;
}
.feature-details-summary::-webkit-details-marker { display: none; }
.feature-details-summary:hover { text-decoration: underline; }

.feature-details-content {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--ink-100, #f3f4f6);
}

.feature-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-900, #111827);
    margin: 12px 0 4px;
}
.feature-section-title:first-child { margin-top: 0; }

.feature-details-content p {
    margin: 0 0 8px;
    line-height: 1.55;
    color: var(--ink-800, #1f2937);
}

.feature-references {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--ink-200, #e5e7eb);
}
.feature-references-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-500, #6b7280);
    font-weight: 600;
    margin-bottom: 6px;
}
.feature-references-list {
    margin: 0;
    padding-left: 22px;
    font-size: 13px;
}
.feature-references-list li {
    margin-bottom: 4px;
}

/* ----- generic feature list (discussions, perspectives) --------- */

.feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
}
.feature-list li {
    padding: 6px 0;
    border-top: 1px dashed var(--ink-200, #e5e7eb);
}
.feature-list li:first-child { border-top: 0; }
.feature-list a {
    color: var(--brand-700, #1d4ed8);
    text-decoration: none;
}
.feature-list a:hover { text-decoration: underline; }
.feature-list-meta {
    color: var(--ink-500, #6b7280);
    font-size: 12px;
    margin-left: 6px;
}

/* ----- SERP feature rows (interleaved into the results table) -- */

/* The whole row sits inside <tbody>; the single <td colspan=N> hosts
 * one (or more) feature blocks. Visually distinct from organic rows so
 * users see "this is a SERP feature, not a ranking result". The shared
 * table rule sets overflow:hidden + ellipsis on every cell; we
 * override that for feature cells (long-form content lives here). */
.results-table .serp-feature-row {
    background: #fbfaff;
    border-left: 3px solid var(--brand-100, #e0e7ff);
}
.results-table .serp-feature-row td.serp-feature-cell {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    padding: 14px 18px;
    vertical-align: top;
}

/* Inside a feature row, the .feature-block doesn't need its own
 * border/background , the row already provides them. Strip the
 * double chrome so it sits flush. */
.results-table .serp-feature-row .feature-block {
    border: 0;
    background: transparent;
    padding: 0;
    margin-bottom: 12px;
}
.results-table .serp-feature-row .feature-block:last-child {
    margin-bottom: 0;
}

/* ----- paid ads (Google Ads) ------------------------------------ */

.feature-ad {
    padding: 10px 12px;
    border-left: 3px solid var(--brand-100, #e0e7ff);
    background: var(--ink-25, #fcfcfd);
    margin-bottom: 8px;
    border-radius: 4px;
}
.feature-ad:last-child { margin-bottom: 0; }
.feature-ad-title {
    font-weight: 500;
    color: var(--brand-700, #1d4ed8);
}
.feature-ad-title a {
    color: inherit;
    text-decoration: none;
}
.feature-ad-title a:hover { text-decoration: underline; }
.feature-ad-breadcrumb {
    font-size: 12px;
    color: var(--ink-500, #6b7280);
    margin: 2px 0;
}
.feature-ad-desc {
    font-size: 13px;
    color: var(--ink-700, #374151);
    line-height: 1.5;
}

/* ----- images grid --------------------------------------------- */

.feature-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.feature-image {
    aspect-ratio: 1 / 1;
    background: var(--ink-100, #f3f4f6);
    border-radius: 6px;
    overflow: hidden;
    display: block;
}
.feature-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ----- product / shopping grid --------------------------------- */

.feature-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.feature-product {
    background: #fff;
    border: 1px solid var(--ink-200, #e5e7eb);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.feature-product-img {
    aspect-ratio: 1 / 1;
    background: var(--ink-50, #f9fafb);
    border-radius: 6px;
    overflow: hidden;
}
.feature-product-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.feature-product-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.feature-product-title {
    font-size: 13px;
    color: var(--ink-900, #111827);
    line-height: 1.35;
    /* clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.feature-product-title a {
    color: var(--brand-700, #1d4ed8);
    text-decoration: none;
}
.feature-product-title a:hover { text-decoration: underline; }
.feature-product-meta {
    font-size: 12px;
    color: var(--ink-700, #374151);
}

/* ----- generic / unknown feature block ------------------------- */

.feature-block-generic {
    background: var(--ink-25, #fcfcfd);
    border-color: var(--ink-100, #f3f4f6);
}

/* ----- expanded PAA list ---------------------------------------- */

.feature-paa-list-full li {
    padding: 8px 0;
    border-top: 1px dashed var(--ink-200, #e5e7eb);
}
.feature-paa-list-full li:first-child { border-top: 0; }
.feature-paa-q {
    font-weight: 500;
    color: var(--ink-900, #111827);
}
.feature-paa-a {
    margin-top: 4px;
    color: var(--ink-700, #374151);
    font-size: 13px;
    line-height: 1.5;
}
.feature-paa-source {
    margin-top: 4px;
    font-size: 12px;
}
.feature-paa-source a {
    color: var(--ink-500, #6b7280);
    text-decoration: none;
}
.feature-paa-source a:hover {
    text-decoration: underline;
    color: var(--brand-700, #1d4ed8);
}

/* ----- per-keyword feature header (bulk mode) ------------------- */

.features-keyword-block {
    margin-bottom: 16px;
}

.features-keyword-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-700, #374151);
    background: var(--ink-200, #e5e7eb);
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 10px;
}

/* ----- keyword filter (bulk mode) -------------------------------- */

/* Chip strip above the results table that lets the user narrow the
 * union-of-keywords view down to one keyword. Hidden in single
 * mode and on single-keyword bulks (nothing to filter). */
.sc-keyword-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--ink-100, #f3f4f6);
}

.sc-keyword-filter[hidden] { display: none; }

.sc-kw-chip {
    background: var(--ink-100, #f3f4f6);
    color: var(--ink-700, #374151);
    border: 0;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    font: inherit;
    font-size: 13px;
}

.sc-kw-chip:hover {
    background: var(--ink-200, #e5e7eb);
    color: var(--ink-900, #111827);
}

.sc-kw-chip.is-active {
    background: var(--brand, #4f46e5);
    color: #fff;
}

.sc-kw-chip-count {
    font-weight: 600;
    opacity: 0.65;
    margin-left: 4px;
    font-size: 12px;
}

.sc-kw-chip.is-active .sc-kw-chip-count {
    opacity: 0.85;
}

/* ----- results subhead (Location / Device / Depth chips) -------- */

.results-subhead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--ink-50, #f9fafb);
    border-bottom: 1px solid var(--ink-100, #f3f4f6);
    color: var(--ink-700, #374151);
    font-size: 13px;
}

.results-subhead[hidden] { display: none; }

.sc-subhead-label {
    color: var(--ink-500, #6b7280);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-right: 4px;
}

.sc-subhead-value {
    color: var(--ink-900, #111827);
    font-weight: 500;
}

.sc-subhead-sep {
    color: var(--ink-300, #d1d5db);
    margin: 0 4px;
    font-weight: 400;
}

/* ----- table cell variants -------------------------------------- */

/* The shared .results-table cell rule sets overflow:hidden +
 * text-overflow:ellipsis + white-space:nowrap on every cell. Combined
 * with `table-layout: fixed`, short content gets ellipsised whenever
 * the column shrinks. We override that for every short-content column
 * so "1" and "DA" render as themselves, not "1...".  URL + Title are
 * the only columns that NEED truncation (long content), and they get
 * to wrap onto multiple lines via the rule further down. */
.results-table .position-cell,
.results-table .da-cell,
.results-table .pr-cell,
.results-table .spam-cell,
.results-table .traffic-cell,
.results-table .kw-cell,
.results-table .keyword-cell {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

.results-table .position-cell {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    width: 70px;
    padding-left: 10px;
    padding-right: 10px;
}

/* Tight numeric columns with reduced horizontal padding so the column
 * stays narrow but the header label still fits. */
.results-table .da-cell,
.results-table .pr-cell,
.results-table .spam-cell,
.results-table .traffic-cell,
.results-table .kw-cell {
    padding-left: 10px;
    padding-right: 10px;
}
.results-table .da-cell      { width: 64px; }
.results-table .pr-cell      { width: 60px; }
.results-table .spam-cell    { width: 72px; }
.results-table .traffic-cell { width: 92px; }
.results-table .kw-cell      { width: 100px; }
.results-table .keyword-cell { width: 180px; }

/* URL + Title wrap onto multiple lines so long URLs / long titles
 * never get hidden. The shared one-line ellipsis rule is overridden. */
.results-table .url-cell,
.results-table .title-cell {
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    vertical-align: top;
    word-break: break-word;
}
.results-table .url-cell   { min-width: 220px; }
.results-table .title-cell { min-width: 280px; }
.results-table .title-cell .title-line {
    /* Cap the title line at 2 visual rows so the row height stays
     * reasonable. The full text lives in the cell's `title=` attribute
     * for a hover tooltip. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.position-badge {
    display: inline-block;
    min-width: 28px;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 13px;
    text-align: center;
}

.position-badge.is-top3   { background: #dcfce7; color: #166534; }
.position-badge.is-top10  { background: #ecfdf5; color: #047857; }
.position-badge.is-page2  { background: #fef3c7; color: #92400e; }
.position-badge.is-deep   { background: #fee2e2; color: #b91c1c; }

.results-table .keyword-cell {
    font-weight: 500;
    color: var(--ink-800, #1f2937);
}

.results-table .url-cell a {
    color: var(--brand-700, #1d4ed8);
    text-decoration: none;
    word-break: break-all;
}
/* No `a:hover { text-decoration: underline }` here: the shared
 * `.cell-link:hover` already provides a border-bottom underline
 * affordance. Adding text-decoration on top would draw two lines
 * under wrapped URLs (one per text-line, plus the border-bottom). */

.results-table .title-cell {
    color: var(--ink-900, #111827);
    font-weight: 500;
}

.results-table .description-cell {
    color: var(--ink-700, #374151);
    font-size: 13px;
}

.results-table .description-cell.truncated {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.results-table .numeric-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.results-table .badge-cell {
    text-align: center;
}

/* ----- DA / Spam tiered badges ---------------------------------- */

.tier-badge {
    display: inline-block;
    min-width: 28px;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.tier-badge.is-high   { background: #dcfce7; color: #166534; }
.tier-badge.is-medium { background: #fef3c7; color: #92400e; }
.tier-badge.is-low    { background: #fee2e2; color: #b91c1c; }
.tier-badge.is-muted  { background: transparent; color: var(--ink-400, #9ca3af); }

/* ----- responsive tweaks ---------------------------------------- */

@media (max-width: 720px) {
    .sc-keyword-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .results-table .url-cell { min-width: 160px; max-width: 220px; }
    .results-table .title-cell { min-width: 180px; max-width: 240px; }
    .results-subhead {
        gap: 8px;
        padding: 8px 12px;
    }
}
