/* Redirect Checker - tool-specific overrides.
   Shared primitives live in code/assets/css/tools.css. */

/* ---------- Form additions ---------------------------------------- */

.expand-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--ink-700);
    cursor: pointer;
    user-select: none;
}
.expand-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-500, #4a59e2);
    cursor: pointer;
}

.ua-picker {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--ink-100);
}
.ua-picker-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.ua-picker-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-800);
}
.ua-picker-cap {
    font-size: 12.5px;
    color: var(--ink-500);
}
.ua-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
@media (max-width: 640px) {
    .ua-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 420px) {
    .ua-grid {
        grid-template-columns: 1fr;
    }
}
.ua-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--ink-200);
    border-radius: 8px;
    background: var(--ink-50);
    font-size: 14px;
    color: var(--ink-800);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.ua-option:hover {
    border-color: var(--ink-300);
    background: #fff;
}
.ua-option.is-checked {
    border-color: var(--brand-500, #4a59e2);
    background: rgba(74, 89, 226, 0.05);
}
.ua-option.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ua-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-500, #4a59e2);
    margin: 0;
    flex-shrink: 0;
}
.ua-option-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.ua-option-label {
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ua-option-kind {
    display: inline-block;
    align-self: flex-start;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 9px;
    line-height: 1.5;
}
.ua-option-kind.is-bot {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
}
.ua-option-kind.is-browser {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
}

/* Quota chip styles live in shared code/assets/css/tools.css. */

/* ---------- Single-mode per-UA card grid -------------------------- */

.ua-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 16px;
    padding: 16px;
}
.ua-card-grid[hidden] {
    display: none;
}
@media (max-width: 720px) {
    .ua-card-grid {
        grid-template-columns: 1fr;
    }
}
.ua-card {
    background: #fff;
    border: 1px solid var(--ink-100);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ua-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.ua-card-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ua-card-name strong {
    font-size: 14px;
    color: var(--ink-800);
}
.ua-card-name small {
    font-size: 11.5px;
    color: var(--ink-500);
}
.ua-card-grade {
    flex-shrink: 0;
}
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}
.grade-badge.grade-A { background: #16a34a; }
.grade-badge.grade-B { background: #22c55e; }
.grade-badge.grade-C { background: #eab308; }
.grade-badge.grade-D { background: #f97316; }
.grade-badge.grade-E { background: #dc2626; }
.grade-badge-sm {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.ua-card-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-600);
}
.ua-card-summary > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--ink-50);
    border-radius: 6px;
}
.ua-card-summary strong {
    color: var(--ink-800);
}

.chain-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chain-hop {
    display: grid;
    grid-template-columns: 28px 60px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--ink-50);
    border-radius: 6px;
    font-size: 12.5px;
}
.chain-hop-num {
    color: var(--ink-500);
    font-weight: 600;
    text-align: center;
}
.chain-hop-status {
    font-weight: 700;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11.5px;
}
.chain-hop-status.s-2xx { background: rgba(34, 197, 94, 0.15); color: #166534; }
.chain-hop-status.s-3xx { background: rgba(245, 158, 11, 0.15); color: #92400e; }
.chain-hop-status.s-4xx { background: rgba(239, 68, 68, 0.15); color: #991b1b; }
.chain-hop-status.s-5xx { background: rgba(239, 68, 68, 0.2); color: #7f1d1d; }
.chain-hop-status.s-0  { background: rgba(107, 114, 128, 0.15); color: #374151; }
.chain-hop-url {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-700);
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 11.5px;
}
.chain-hop-url a {
    color: inherit;
    text-decoration: none;
}
.chain-hop-url a:hover {
    text-decoration: underline;
}
.chain-hop-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--ink-500);
    white-space: nowrap;
}
.chain-hop-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--ink-100);
    color: var(--ink-700);
}
.chain-hop-type.t-meta_refresh { background: rgba(245, 158, 11, 0.2); color: #92400e; }
.chain-hop-type.t-js           { background: rgba(239, 68, 68, 0.15); color: #991b1b; }

.findings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--ink-100);
    padding-top: 12px;
}
.finding-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--ink-50);
    font-size: 12.5px;
}
.finding-item.sev-high   { background: rgba(239, 68, 68, 0.08); }
.finding-item.sev-medium { background: rgba(245, 158, 11, 0.08); }
.finding-item.sev-low    { background: var(--ink-50); }
.finding-sev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--ink-200);
    color: var(--ink-800);
    height: fit-content;
    margin-top: 1px;
}
.finding-sev.sev-high   { background: #dc2626; color: #fff; }
.finding-sev.sev-medium { background: #f59e0b; color: #fff; }
.finding-sev.sev-low    { background: #6b7280; color: #fff; }
.finding-text strong {
    color: var(--ink-800);
    display: block;
    margin-bottom: 2px;
}
.finding-text span {
    color: var(--ink-600);
    line-height: 1.4;
}

.ua-card-final {
    border-top: 1px solid var(--ink-100);
    padding-top: 12px;
    font-size: 12.5px;
    color: var(--ink-600);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ua-card-final-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ua-card-final-row strong {
    flex-shrink: 0;
    color: var(--ink-700);
    font-weight: 600;
    min-width: 80px;
}
.ua-card-final-row .final-url {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 11.5px;
    word-break: break-all;
}
.ua-card-final-row .final-url a {
    color: var(--brand-500, #4a59e2);
    text-decoration: none;
}
.ua-card-final-row .final-url a:hover {
    text-decoration: underline;
}

.cloaking-flag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(220, 38, 38, 0.12);
    color: #991b1b;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* ---------- Results subhead --------------------------------------- */

.results-subhead {
    padding: 12px 20px;
    background: var(--ink-50);
    border-bottom: 1px solid var(--ink-100);
    font-size: 13px;
    color: var(--ink-600);
    line-height: 1.5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}
.results-subhead strong {
    color: var(--ink-800);
    font-weight: 600;
}
.results-subhead-sep {
    color: var(--ink-300);
    user-select: none;
}
.results-subhead-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.results-subhead-item-icon {
    width: 14px;
    height: 14px;
    color: var(--ink-400);
    flex-shrink: 0;
}
.results-subhead-item.is-warn {
    color: #b45309;
}
.results-subhead-item.is-warn strong {
    color: #92400e;
}
.results-subhead-item.is-warn .results-subhead-item-icon {
    color: #f59e0b;
}
.results-subhead-item.is-danger {
    color: #991b1b;
}
.results-subhead-item.is-danger strong {
    color: #7f1d1d;
}
.results-subhead-item.is-danger .results-subhead-item-icon {
    color: #dc2626;
}
.results-subhead-item.is-info strong {
    color: var(--brand-500, #4a59e2);
}

/* ---------- Bulk-mode table --------------------------------------- */

#bulk-table-wrap[hidden] {
    display: none;
}
#results-footer[hidden] {
    display: none;
}
#results-table thead th,
#results-table tbody td {
    text-align: center;
    vertical-align: middle;
}
/* The two URL columns are long strings; left-align them, but keep
   the header center-aligned for visual consistency. */
#results-table tbody td.col-input,
#results-table tbody td.col-final {
    text-align: left;
}
/* Shared `.results-table { table-layout: fixed }` means column
   widths are determined by the FIRST ROW (thead). The TBody widths
   would be ignored, so we apply widths to BOTH thead th AND tbody
   td via the col-* class on each. Small columns get explicit pixel
   widths; URL columns get fluid percentages so they claim every
   pixel left over. */
#results-table .col-num {
    font-variant-numeric: tabular-nums;
    width: 60px;
    white-space: nowrap;
    padding-left: 4px;
    padding-right: 4px;
}
#results-table .col-grade {
    width: 72px;
    padding-left: 4px;
    padding-right: 4px;
}
#results-table .col-issues {
    width: 80px;
    white-space: nowrap;
    padding-left: 4px;
    padding-right: 4px;
}
/* Merged action column: holds the View chain button (always) plus
   an optional Cloak badge (rare, when UAs disagree). Wide enough
   to fit the button (~100px) plus a few pixels of breathing room. */
#results-table .col-action {
    width: 116px;
    white-space: nowrap;
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
}
/* Inside the merged action TD: when both Cloak badge AND View
   chain button are present, force the badge onto its own line so
   they stack vertically. `display: table` is block-level (claims
   a row) but shrinks to content width, and `margin: 0 auto`
   centers it horizontally. Browsers reject `display: flex` on
   raw <td> in `table-layout: fixed`; this is the safe equivalent. */
#results-table tbody td.col-action .cloaking-flag {
    display: table;
    margin: 0 auto 4px;
    padding: 2px 8px;
    font-size: 10.5px;
}
/* Input URL takes 55% of leftover horizontal space; Final URL takes
   45%. Percentages in fixed-layout tables are honored as preferences
   for the leftover space after explicit-pixel columns are placed.
   word-break + the JS truncate cap together prevent runaway widths
   from absurdly long URLs. */
#results-table .col-input {
    width: 55%;
    word-break: break-all;
}
#results-table .col-final {
    width: 45%;
    word-break: break-all;
}
/* URL cells are clickable triggers (open the same View Chain modal
   the action button does). Dotted underline + cursor:pointer
   signals interactivity; hover shifts to a solid brand-colored
   underline. */
#results-table .url-cell {
    cursor: pointer;
    color: var(--ink-700);
    text-decoration: underline dotted var(--ink-300);
    text-underline-offset: 3px;
}
#results-table .url-cell:hover,
#results-table .url-cell:focus-visible {
    color: var(--brand-red, #b03a39);
    text-decoration: underline solid currentColor;
    outline: none;
}
.bulk-status {
    display: inline-block;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11.5px;
}
.bulk-status.s-2xx { background: rgba(34, 197, 94, 0.15); color: #166534; }
.bulk-status.s-3xx { background: rgba(245, 158, 11, 0.15); color: #92400e; }
.bulk-status.s-4xx { background: rgba(239, 68, 68, 0.15); color: #991b1b; }
.bulk-status.s-5xx { background: rgba(239, 68, 68, 0.2); color: #7f1d1d; }
.bulk-status.s-0   { background: rgba(107, 114, 128, 0.15); color: #374151; }

.issue-counts {
    display: inline-flex;
    gap: 4px;
}
.issue-count {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
}
.issue-count.sev-high   { background: rgba(239, 68, 68, 0.15); color: #991b1b; }
.issue-count.sev-medium { background: rgba(245, 158, 11, 0.15); color: #92400e; }
.issue-count.sev-low    { background: rgba(107, 114, 128, 0.15); color: #374151; }

.view-btn {
    padding: 5px 12px;
    background: var(--ink-50);
    border: 1px solid var(--ink-200);
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ink-700);
}
.view-btn:hover {
    background: #fff;
    border-color: var(--brand-500, #4a59e2);
    color: var(--brand-500, #4a59e2);
}

.ua-count-pill {
    display: inline-block;
    padding: 2px 8px;
    background: var(--ink-50);
    border: 1px solid var(--ink-200);
    border-radius: 10px;
    font-size: 11px;
    color: var(--ink-700);
}

/* ---------- Row modal --------------------------------------------- */

#row-modal .modal-card {
    width: min(96vw, 920px);
    max-width: 96vw;
}
#row-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}
.modal-card--wide {
    width: min(96vw, 920px);
    max-width: 96vw;
}

/* ---------- Recent searches additions ----------------------------- */

.history-item-meta-uas {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}
.history-item-ua-pill {
    display: inline-block;
    padding: 1px 6px;
    background: var(--ink-100);
    border-radius: 8px;
    font-size: 10.5px;
    color: var(--ink-700);
}
