/*
 * GPL Broken Link Checker — tool-only UI (2.0: site crawl, views, progress).
 * Shared chrome (.gpl-tool, .mt-stat-card, .mt-results-card, .mt-dt-top, .mt-result-table,
 * .gpl-tag, form controls, buttons) comes from the GPL theme and is not duplicated here.
 * Type scale matches the other GuestPostLinks checkers: 1rem titles, 0.875rem help text,
 * 14px results, 13px filters, 12px badges.
 */

.gplblc-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1em;
    margin: 0 0 1em !important;
    padding: 0;
    border: 0;
}

.gplblc-mode-switch label {
    display: block;
    margin: 0;
    cursor: pointer;
}

.gplblc-mode-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.gplblc-mode-switch span {
    position: relative;
    display: flex;
    min-height: 64px;
    padding: 1em 1em 1em 3.25em;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border: 1px solid var(--gpl-tool-card-line, #e5e7eb);
    border-radius: var(--gpl-tool-radius, 8px);
    background: var(--gpl-tool-surface, #fff);
    text-align: left;
    transition: border-color .15s ease, background .15s ease;
}

.gplblc-mode-switch span:hover {
    border-color: var(--gpl-tool-line-hover, #c5cad3);
}

.gplblc-mode-switch span::before {
    content: "";
    position: absolute;
    left: 1em;
    top: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #1d2128;
    border-radius: 50%;
    background: #fff;
    transform: translateY(-50%);
    transition: border-color .15s ease, background .15s ease;
}

.gplblc-mode-switch span:hover::before {
    border-color: #8c95a5;
}

.gplblc-mode-switch input:checked + span {
    border-color: var(--gpl-tool-blue, #3e63dd);
    background: var(--gpl-tool-blue-bg, #f4f7ff);
}

.gplblc-mode-switch input:checked + span::before {
    border-color: #1d2128;
    background: #1d2128;
}

.gplblc-mode-switch input:checked + span::after {
    content: "";
    position: absolute;
    left: calc(1em + 2px);
    top: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #1d2128;
    transform: translateY(-50%);
}

.gplblc-mode-switch input:focus-visible + span {
    outline: 3px solid var(--gpl-tool-focus-ring, #93c5fd);
    outline-offset: 2px;
}

.gplblc-mode-switch strong {
    color: var(--gpl-tool-ink, #1f2937);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
}

.gplblc-mode-switch small {
    color: var(--gpl-tool-text-soft, #6b7280);
    font-size: 0.875rem;
    line-height: 1.35;
}

.gplblc-fields {
    display: grid;
    gap: 1em;
}

.gplblc-field.form-control {
    align-items: stretch;
    gap: 0.75em;
}

.gplblc-field > label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 0;
}

.gplblc-input-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    color: var(--gpl-tool-text-soft, #6b7280);
    font-size: 0.875rem;
}

.gplblc-tool .gplblc-text-button {
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--gpl-tool-blue, #3e63dd) !important;
    font: inherit;
    font-weight: 600;
    line-height: inherit;
    text-decoration: underline;
    text-transform: none;
    cursor: pointer;
}

.gplblc-tool .gplblc-text-button:hover {
    text-decoration: none;
}

.gplblc-options {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5em;
    flex-wrap: wrap;
    min-height: 50px;
    padding: 1em 0;
    font-size: 14px;
}

.gplblc-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    margin: 0;
    font-size: 14px;
    cursor: pointer;
}

.gplblc-tool .motta-alert {
    margin-bottom: 10px;
    text-align: start;
}

/* Submit loading spinner is the shared .gpl-tool__submit-btn.button--loading style. */

.gplblc-progress {
    margin-top: 1em;
}

.gplblc-progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 4px;
    background: #e6e9f1;
}

.gplblc-progress-track span {
    display: block;
    width: 0;
    min-width: 2%;
    height: 100%;
    border-radius: 4px;
    background: var(--gpl-tool-blue, #3e63dd);
    transition: width .2s ease;
}

.gplblc-results {
    padding: 10px 0;
    color: var(--gpl-tool-ink, #1f2937);
    font-size: 14px;
    scroll-margin-top: 20px;
}

.gplblc-filterbar {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    margin: 6px 0 16px;
    padding: 14px 16px;
    border: 1px solid var(--gpl-tool-line, #eaedf2);
    border-radius: var(--mt-border__radius, 8px);
    background: var(--gpl-tool-surface, #fff);
}

.gplblc-filter-title {
    color: var(--gpl-tool-label, #374151);
    font-weight: 700;
}

.gplblc-frange {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gpl-tool-label, #374151);
    font-size: 13px;
}

.gplblc-frange label {
    margin: 0;
    font-weight: 600;
}

.gplblc-tool .gplblc-frange select {
    width: auto;
    min-width: 160px;
    height: 34px;
    margin: 0;
    padding: 7px 28px 7px 12px;
    border: 1px solid var(--gpl-tool-line, #eaedf2);
    border-radius: 8px;
    background: #fff url("data:image/svg+xml;charset=UTF-8,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat calc(100% - 10px) center / 12px 8px;
    box-shadow: none;
    color: var(--gpl-tool-label, #374151);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.gplblc-tool .gplblc-frange select:hover {
    border-color: var(--gpl-tool-line-hover, #c5cad3);
    background-color: var(--gpl-tool-surface-hover, #f8fafc);
}

.gplblc-tool .gplblc-frange select:focus {
    border-color: var(--gpl-tool-line-hover, #c5cad3);
    background-color: var(--gpl-tool-surface, #fff);
    outline: none;
}

.gplblc-restore {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em 1em;
    margin-top: 16px;
    padding: 10px 16px;
    border: 1px solid var(--gpl-tool-line, #e5e7eb);
    border-radius: 8px;
    background: var(--gpl-tool-surface-hover, #f8fafc);
    color: var(--gpl-tool-text-soft, #4b5563);
    font-size: 0.875rem;
    line-height: 1.45;
}

.gplblc-restore.hide {
    display: none;
}

.gplblc-note {
    margin: 0 0 16px;
    padding: 10px 16px;
    border: 1px solid #f5c78a;
    border-radius: 8px;
    background: #fff4e5;
    color: #92400e;
    font-size: 13px;
    line-height: 1.45;
}

.gplblc-tool .mt-dt-top input,
.gplblc-tool .mt-dt-top select {
    min-height: 0;
    box-shadow: none;
}

.gplblc-tool .mt-dt-top .dt-button {
    white-space: nowrap;
}

.gplblc-tool .mt-dt-top .gplblc-dt-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    order: 0;
    margin-right: auto;
}

.gplblc-tool .mt-dt-top .dt-buttons {
    order: 1;
}

.gplblc-tool .mt-dt-top .mt-dt-top-right {
    order: 2;
}

.gplblc-tool .dt-button i.success {
    color: green !important;
}

/* --- Progress card --- */

.gplblc-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    margin-bottom: 0.75em;
}

.gplblc-progress-text {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25em 0.75em;
    color: var(--gpl-tool-ink, #1f2937);
    font-size: 0.875rem;
}

.gplblc-progress-text strong {
    font-weight: 600;
}

.gplblc-progress-text span,
.gplblc-progress-time {
    color: var(--gpl-tool-text-soft, #666);
    font-size: 0.875rem;
}

.gplblc-progress-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.gplblc-progress.is-done .gplblc-progress-track span {
    background: var(--gpl-tool-green, #0f9a7b);
}

.gplblc-progress.is-failed .gplblc-progress-track span {
    background: var(--gpl-tool-red, #dc2626);
}

/* --- Option row: crawl size select --- */

.gplblc-select-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    margin: 0;
    font-size: 14px;
}

.gplblc-tool .gplblc-select-option select {
    width: auto;
    min-width: 130px;
    height: 34px;
    margin: 0;
    padding: 4px 28px 4px 10px;
    font-size: 14px;
}

.gplblc-select-option.is-disabled,
.gplblc-check.is-disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* --- Summary: clickable stat cards + extra counts --- */

.gplblc-tool .gplblc-stat-filter {
    width: 100%;
    min-height: 0;
    margin: 0;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.gplblc-tool .gplblc-stat-filter:hover,
.gplblc-tool .gplblc-stat-filter:focus {
    border-color: var(--gpl-tool-line-hover, #cbd5e1) !important;
    background: #fff !important;
    color: inherit !important;
    box-shadow: none !important;
}

.gplblc-tool .gplblc-stat-filter.is-selected:hover,
.gplblc-tool .gplblc-stat-filter.is-selected:focus {
    border-color: var(--gpl-tool-blue, #4166e1) !important;
    box-shadow: 0 0 0 1px var(--gpl-tool-blue, #4166e1) !important;
}

.gplblc-tool .gplblc-stat-filter.is-selected {
    border-color: var(--gpl-tool-blue, #4166e1);
    box-shadow: 0 0 0 1px var(--gpl-tool-blue, #4166e1);
}

.gplblc-tool .gplblc-stat-filter:focus-visible {
    outline: 3px solid var(--gpl-tool-focus-ring, rgba(65, 102, 225, .28));
    outline-offset: 2px;
}

.gplblc-extra {
    margin: -6px 0 16px;
}

.gplblc-extra:empty {
    display: none;
}

.gplblc-tool .gplblc-extra .gpl-tag {
    display: inline-flex;
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    box-shadow: none;
    font-family: inherit;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.gplblc-tool .gplblc-extra .gpl-tag strong {
    font-weight: 600;
}

/* Same tones as .gpl-tag--success / --warning / --muted, with a border so they read as buttons. */
.gplblc-tool .gplblc-extra .gpl-tag--success {
    border-color: rgba(19, 188, 150, .25);
    background: rgba(19, 188, 150, .08);
    color: #0f9a7b;
}

.gplblc-tool .gplblc-extra .gpl-tag--warning {
    border-color: rgba(228, 167, 5, .35);
    background: rgba(237, 178, 0, .08);
    color: #b7860a;
}

.gplblc-tool .gplblc-extra .gpl-tag--muted {
    border-color: #e5e7eb;
    background: #f3f4f6;
    color: #6b7280;
}

/* Theme button:hover would paint these orange; darken the pill's own tone instead. */
.gplblc-tool .gplblc-extra .gpl-tag--success:hover,
.gplblc-tool .gplblc-extra .gpl-tag--success:focus {
    border-color: rgba(19, 188, 150, .55) !important;
    background: rgba(19, 188, 150, .16) !important;
    color: #0b7d63 !important;
}

.gplblc-tool .gplblc-extra .gpl-tag--warning:hover,
.gplblc-tool .gplblc-extra .gpl-tag--warning:focus {
    border-color: rgba(228, 167, 5, .7) !important;
    background: rgba(237, 178, 0, .16) !important;
    color: #96700a !important;
}

.gplblc-tool .gplblc-extra .gpl-tag--muted:hover,
.gplblc-tool .gplblc-extra .gpl-tag--muted:focus {
    border-color: #cbd5e1 !important;
    background: #e5e7eb !important;
    color: #374151 !important;
}

.gplblc-tool .gplblc-extra .gpl-tag:hover,
.gplblc-tool .gplblc-extra .gpl-tag:focus {
    box-shadow: none !important;
}

.gplblc-tool .gplblc-extra .gpl-tag.is-selected {
    border-color: currentColor !important;
}

.gplblc-tool .gplblc-extra .gpl-tag:focus-visible {
    outline: 3px solid var(--gpl-tool-focus-ring, rgba(65, 102, 225, .28));
    outline-offset: 2px;
}

.gplblc-note.is-error {
    border-color: var(--gpl-tool-red-line, #fca5a5);
    background: var(--gpl-tool-red-soft, #fff5f5);
    color: var(--gpl-tool-red, #dc2626);
}

.gplblc-tool .gplblc-frange select:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* --- Result views: same tab design as the Domain Age Checker (.dac-view-tabs) --- */

.gplblc-views {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 28px 36px;
    padding: 16px 16px 0;
    border-bottom: 1px solid #ecf0f4;
    background: #fff;
}

.gplblc-tool .gplblc-view {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0 0 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #7c818b;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.gplblc-tool .gplblc-view i {
    color: inherit;
    font-size: 14px;
    line-height: 1;
}

.gplblc-view-label {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.gplblc-view-count {
    color: inherit;
    font-size: 12.8px;
    font-weight: 400;
    line-height: 1;
}

.gplblc-tool .gplblc-view::after {
    content: "";
    position: absolute;
    z-index: 1;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 2px;
    background: #1d2128;
    transition: width .3s;
}

/* !important: the theme paints every button:hover with the primary fill. */
.gplblc-tool .gplblc-view:hover,
.gplblc-tool .gplblc-view:focus,
.gplblc-tool .gplblc-view:active,
.gplblc-tool .gplblc-view.is-active {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #f97248 !important;
}

.gplblc-tool .gplblc-view:hover::after,
.gplblc-tool .gplblc-view:focus-visible::after,
.gplblc-tool .gplblc-view.is-active::after {
    width: 100%;
    background: #f97248;
}

.gplblc-tool .gplblc-view:focus-visible {
    outline: 2px solid #f97248;
    outline-offset: 2px;
}

.gplblc-source-chip {
    padding: 12px 16px 0;
}

.gplblc-source-chip .gpl-tag {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gplblc-tool .gplblc-chip-clear {
    min-width: 0;
    min-height: 0;
    margin: 0 0 0 4px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

/* --- Table cells --- */

.gplblc-table td.url a {
    word-break: break-all;
}

.gplblc-sub {
    display: block;
    margin-top: 4px;
    color: var(--gpl-tool-muted, #6b7280);
    font-size: 12px;
    line-height: 1.4;
    word-break: break-all;
}

.gplblc-sub.is-note {
    color: var(--gpl-tool-amber-text, #92400e);
    word-break: normal;
}

.gplblc-sub a {
    color: inherit;
    text-decoration: underline;
}

.gplblc-muted {
    color: var(--gpl-tool-muted, #6b7280);
}

.gplblc-table .gpl-tag--sm {
    vertical-align: middle;
}

.gplblc-tool .gplblc-more,
.gplblc-tool .gplblc-issues {
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 2px 8px;
    border: 1px solid var(--gpl-tool-line, #eaedf2);
    border-radius: 3px;
    background: var(--gpl-tool-surface, #fff);
    box-shadow: none;
    color: var(--gpl-tool-blue, #4166e1);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    cursor: pointer;
}

.gplblc-tool .gplblc-issues {
    border-color: rgba(242, 24, 80, .25);
    background: rgba(242, 24, 80, .08);
    color: #f21951;
}

.gplblc-tool .gplblc-more:hover,
.gplblc-tool .gplblc-more:focus {
    border-color: #4166e140 !important;
    background: #4166e114 !important;
    color: #4166e1 !important;
    box-shadow: none !important;
}

.gplblc-tool .gplblc-issues:hover,
.gplblc-tool .gplblc-issues:focus {
    border-color: rgba(242, 24, 80, .5) !important;
    background: rgba(242, 24, 80, .14) !important;
    color: #d0103f !important;
    box-shadow: none !important;
}

.gplblc-tool .gplblc-chip-clear:hover,
.gplblc-tool .gplblc-chip-clear:focus {
    background: transparent !important;
    color: #1f3fae !important;
    box-shadow: none !important;
}

.gplblc-zero {
    color: var(--gpl-tool-muted, #6b7280);
}

.gplblc-sources-row td {
    background: var(--gpl-tool-blue-bg, #f4f7fa);
    text-align: left !important;
}

.gplblc-sources .gplblc-repeat {
    display: inline;
    margin: 0 0 0 4px;
}

.gplblc-sources {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.gplblc-sources li {
    margin: 0;
    word-break: break-all;
}

.gplblc-empty-ok {
    color: var(--gpl-tool-green, #0f9a7b);
    font-weight: 600;
}

.gplblc-http {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.gplblc-http.is-ok {
    background: rgba(19, 188, 150, 0.08);
    color: #0f9f7a;
}

.gplblc-http.is-redirect,
.gplblc-http.is-blocked,
.gplblc-http.is-limited {
    background: #fdf0da;
    color: #d98a13;
}

.gplblc-http.is-broken,
.gplblc-http.is-soft,
.gplblc-http.is-timeout,
.gplblc-http.is-ssl,
.gplblc-http.is-dns,
.gplblc-http.is-error {
    background: rgba(242, 24, 80, 0.08);
    color: #f21951;
}

.gplblc-http.is-pending,
.gplblc-http.is-skipped {
    background: #f3f4f6;
    color: #6b7280;
}

.gplblc-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.gplblc-badge.is-ok {
    background: rgba(19, 188, 150, 0.08);
    color: #0f9f7a;
}

.gplblc-badge.is-redirect {
    background: #fdf0da;
    color: #d98a13;
}

.gplblc-badge.is-broken,
.gplblc-badge.is-dns,
.gplblc-badge.is-ssl,
.gplblc-badge.is-error {
    background: rgba(242, 24, 80, 0.08);
    color: #f21951;
}

.gplblc-badge.is-soft,
.gplblc-badge.is-timeout,
.gplblc-badge.is-blocked,
.gplblc-badge.is-limited {
    background: #fff4e5;
    color: #c45a26;
}

.gplblc-badge.is-pending,
.gplblc-badge.is-skipped {
    background: #f3f4f6;
    color: #6b7280;
}

.gplblc-repeat {
    display: block;
    margin-top: 4px;
    color: var(--gpl-tool-muted, #6b7280);
    font-size: 12px;
}

.gplblc-no-row td {
    padding: 24px;
    color: var(--gpl-tool-muted, #6b7280);
    text-align: center !important;
}

@media (max-width: 820px) {
    .gplblc-progress-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .gplblc-views {
        gap: 18px 24px;
        padding: 12px 12px 0;
    }

    .gplblc-tool .gplblc-view {
        font-size: 15px;
    }
}

@media (max-width: 640px) {
    .gplblc-mode-switch,
    .gplblc-options {
        grid-template-columns: 1fr;
    }

    .gplblc-options {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75em;
    }

    .gplblc-filterbar {
        gap: 12px;
    }

    .gplblc-frange {
        width: 100%;
    }

    .gplblc-tool .gplblc-frange select {
        flex: 1;
        min-width: 0;
    }

}

@media (max-width: 430px) {
    .gplblc-input-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gplblc-progress-track span {
        transition: none;
    }
}
