/* Keyword Gap Analysis - tool-specific overrides on top of the shared
 * primitives in code/assets/css/tools.css.
 *
 * What lives here:
 *   1. Page-chrome (tightening header padding for this tool's hero).
 *   2. Form-field labels we add above the user input and competitor
 *      textarea.
 *   3. Wide results table: 2-row header treatment (competitor name
 *      spans Traffic + Position subheaders), per-column widths, and
 *      the centered+bold numeric cell styling shared with TPF.
 *   4. Results subhead chip (resolution + per-input keyword counts).
 *   5. Modal-backdrop reuse + invalid/unknown list styling. Same shape
 *      WTC and TPF use; the `.modal-backdrop[hidden]` override is
 *      mandatory because display:flex would otherwise beat [hidden].
 */

/* ========================================================================
   Form labels for the user's site + competitor textarea
   ======================================================================== */
.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;
}
.field-hint {
    margin-left: 6px;
    color: var(--ink-500);
    font-weight: 400;
    font-size: 12px;
}

/* Competitor-count chip turns red once the user has more lines in the
 * textarea than their plan allows. The .is-over class is toggled by
 * tool.js's updateCompetitorCount(). */
.bulk-count.is-over {
    color: var(--brand-red);
    font-weight: 600;
}

/* ========================================================================
   Results table - wide layout with two-row header
   ========================================================================
   Keyword column: left aligned, takes the headline space.
   Per-competitor pair: 2 columns (Traffic, Position).
   Optional metrics tail: 4 columns (Volume, CPC, Competition, Trend).

   The whole table can run wider than the viewport; the page scrolls
   horizontally because the shared .results-table-wrap has no
   horizontal overflow set (which would break the sticky thead).
*/
.results-table th[data-col="keyword"] {
    text-align: left;
    min-width: 240px;
    width: 28%;
}

.results-table th.th-num,
.results-table td.td-num {
    text-align: center;
    font-feature-settings: var(--tnum);
    min-width: 90px;
}
.results-table td.td-num {
    font-size: 15px;
    font-weight: 600;
}
.results-table td.td-num.is-muted {
    color: var(--ink-400);
    font-weight: 400;
}

/* Two-row header treatment. Row 1 has spanning competitor labels.
 * Row 2 has Traffic | Position subheaders + (when enrichment ran)
 * Volume / CPC / Competition / Trend.
 */
.results-table thead .competitor-group {
    text-align: center;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1px solid var(--ink-100);
    padding: 6px 8px;
    background: var(--ink-50);
    /* Truncate over-long competitor labels rather than letting them
     * blow out the column width. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.results-table thead .competitor-group.th-metrics {
    background: linear-gradient(0deg, var(--brand-50, #f4f9ff), var(--ink-50));
    color: var(--brand-700, var(--ink));
}
.results-table thead tr.subhead th {
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 4px;
    padding-bottom: 8px;
    /* The shared sticky rule pins every <th> at top:58 (just below the
     * .results-header strip). With our two-row thead that collapses
     * the group row (competitor labels, ~29px tall) under the subhead
     * row at the same offset, hiding the labels entirely. Push the
     * subhead row down by the group row's height so the two rows
     * stack cleanly. */
    top: 87px;
}

/* Trend chart cell. */
.results-table td.td-trend {
    text-align: center;
    padding: 4px 8px;
}
.trend-svg {
    display: inline-block;
    vertical-align: middle;
}

/* ========================================================================
   Results subhead - resolution + summary chip
   ======================================================================== */
.results-subhead {
    padding: 10px 16px 4px 16px;
    font-size: 12.5px;
    color: var(--ink-600);
    background: var(--ink-50);
    border-bottom: 1px solid var(--ink-100);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: baseline;
}
.results-subhead strong {
    color: var(--ink);
    font-weight: 600;
}
.results-subhead .subhead-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 2px 8px;
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: 999px;
    font-size: 12px;
    color: var(--ink-700);
}
.results-subhead .subhead-pill .subhead-num {
    font-weight: 700;
    color: var(--ink);
    font-feature-settings: var(--tnum);
}

/* ========================================================================
   Invalid / Unknown / Enrich modals
   ======================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: modal-backdrop-in 0.12s ease-out;
}
.modal-backdrop[hidden] {
    display: none;
}
@keyframes modal-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.modal-card {
    background: #fff;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: 100%;
    padding: 24px 28px;
    animation: modal-card-in 0.18s ease-out;
}
@keyframes modal-card-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}
.modal-body {
    margin: 0 0 12px;
    color: var(--ink-700);
    font-size: 14px;
    line-height: 1.5;
}
.modal-body strong {
    color: var(--ink);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.invalid-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 8px 12px;
    background: var(--ink-50);
    border: 1px solid var(--ink-100);
    border-radius: var(--r-sm);
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}
.invalid-list li {
    color: var(--ink-700);
    padding: 4px 0;
    border-bottom: 1px solid var(--ink-100);
    display: flex;
    gap: 10px;
    align-items: baseline;
    word-break: break-all;
}
.invalid-list li:last-child {
    border-bottom: 0;
}
.invalid-list .invalid-line {
    color: var(--ink);
    font-weight: 500;
    flex: 1 1 auto;
    min-width: 0;
}
.invalid-list .invalid-reason {
    color: var(--brand-red);
    font-size: 12px;
    flex: 0 0 auto;
    white-space: nowrap;
}
.invalid-list .invalid-role {
    color: var(--ink-400);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 auto;
    white-space: nowrap;
    margin-right: 6px;
}

/* Disabled primary button */
.primary-btn:disabled,
.primary-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================================================
   12-month trend tooltip (re-uses ORC's pattern; the tooltip element
   itself is created by tool.js on demand and absolutely positioned
   under the cursor).
   ======================================================================== */
.trend-tooltip {
    position: fixed;
    z-index: 99999;
    background: var(--ink);
    color: #fff;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    white-space: pre-line;
    max-width: 220px;
}
