/*
 * GPL Link Analyzer — tool-only UI.
 * 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.
 * The form and table follow GPL Keyword Density Checker; the filter bar and clickable stat
 * cards follow GPL Broken Link Checker.
 */

/* --- Form --- */

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

.gplla-field > label {
    margin: 0;
}

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

.gplla-tool .gplla-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, #4166e1) !important;
    font: inherit;
    font-weight: 600;
    line-height: inherit;
    text-decoration: underline;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
}

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

.gplla-tool .gplla-text-button:focus-visible {
    outline: 2px solid var(--gpl-tool-blue, #4166e1);
    outline-offset: 2px;
}

.gplla-tool .gplla-text-button:disabled {
    color: var(--gpl-tool-muted, #6b7280) !important;
    text-decoration: none;
    opacity: .6;
    cursor: default;
}

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

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

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

/* --- Loading --- */

.gplla-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    padding: 14px 16px;
    color: var(--gpl-tool-label, #374151);
    font-size: 14px;
}

.gplla-loading.hide {
    display: none;
}

.gplla-spinner {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 2px solid var(--gpl-tool-blue-line, #4166e140);
    border-top-color: var(--gpl-tool-blue, #4166e1);
    border-radius: 50%;
    animation: gplla-spin .8s linear infinite;
}

@keyframes gplla-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Results --- */

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

.gplla-results:focus {
    outline: none;
}

.gplla-source {
    margin: 6px 0 16px;
}

.gplla-source .gpl-tag {
    gap: 6px;
}

.gplla-source .gplla-source-url {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gplla-note {
    margin: 0 0 12px;
    padding: 10px 16px;
    border: 1px solid #f5c78a;
    border-radius: var(--gpl-tool-radius, 8px);
    background: #fff4e5;
    color: var(--gpl-tool-amber-text, #92400e);
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

#gplla-notes:not(:empty) {
    margin-bottom: 16px;
}

.gplla-tool .gplla-summary-hint {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.45;
}

/* Twelve cards: four per row on desktop (the theme's 5-column grid would leave a ragged last row). */
.gplla-tool .gplla-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Clickable cards are <button>s; the theme's button rules centre their content and set 14px text,
   and the card's padding, icon and radius are sized in em. Restore the shared .mt-stat-card values
   (left-aligned, 1rem) so the icon and text line up with the plain cards in every column. */
.gplla-tool .mt-stat-grid .gplla-stat-filter {
    justify-content: flex-start;
    width: 100%;
    min-height: 0;
    height: auto;
    margin: 0;
    box-shadow: none;
    color: inherit;
    font-family: inherit;
    font-size: 1rem;
    font-weight: inherit;
    line-height: inherit;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

/* !important: the theme paints every button:hover with the primary fill. */
.gplla-tool .gplla-stat-filter:hover,
.gplla-tool .gplla-stat-filter:focus {
    border-color: var(--gpl-tool-line-hover, #cbd5e1) !important;
    background: #fff !important;
    color: inherit !important;
    box-shadow: none !important;
}

.gplla-tool .gplla-stat-filter.is-selected,
.gplla-tool .gplla-stat-filter.is-selected:hover,
.gplla-tool .gplla-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;
}

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

/* --- Filter bar --- */

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

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

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

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

.gplla-tool .gplla-frange select {
    width: auto;
    min-width: 150px;
    height: 34px;
    margin: 0;
    padding: 7px 28px 7px 12px;
    border: 1px solid var(--gpl-tool-line, #eaedf2);
    border-radius: var(--gpl-tool-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;
}

.gplla-tool .gplla-frange select:hover {
    border-color: var(--gpl-tool-line-hover, #cbd5e1);
}

.gplla-tool .gplla-frange select:focus-visible {
    outline: 3px solid var(--gpl-tool-focus-ring, rgba(65, 102, 225, .28));
    outline-offset: 1px;
}

.gplla-clear {
    margin-left: auto !important;
    font-size: 13px !important;
}

/* --- Toolbar --- */

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

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

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

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

.gplla-tool .mt-dt-top .mt-dt-top-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    order: 2;
}

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

/* --- Table --- */

.gplla-table th,
.gplla-table td {
    vertical-align: middle;
}

.gplla-table .gplla-col-index {
    width: 56px;
    color: var(--gpl-tool-muted, #6b7280);
    font-variant-numeric: tabular-nums;
}

.gplla-table .gplla-col-url {
    min-width: 240px;
    max-width: 360px;
}

.gplla-table td.gplla-col-url,
.gplla-table td.gplla-col-text {
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: left !important;
}

.gplla-table .gplla-col-text {
    min-width: 180px;
    max-width: 280px;
}

.gplla-url {
    color: var(--gpl-tool-blue, #4166e1);
    font-weight: 500;
    text-decoration: none;
}

.gplla-url:hover {
    text-decoration: underline;
}

.gplla-url:focus-visible {
    outline: 2px solid var(--gpl-tool-blue, #4166e1);
    outline-offset: 2px;
}

/* "Same page" sits on its own line under the URL, with room between them. */
.gplla-table .gplla-same-page {
    display: flex;
    width: fit-content;
    margin-top: 6px;
}

.gplla-anchor--alt i {
    color: var(--gpl-tool-muted, #6b7280);
}

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

.gplla-empty {
    font-style: italic;
}

.gplla-fallback,
.gplla-alt-warn {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.35;
}

.gplla-alt-warn {
    color: var(--gpl-tool-red, #dc2626);
}

.gplla-table td.gplla-col-alt {
    min-width: 120px;
    overflow-wrap: anywhere;
}

.gplla-table .gplla-col-rel {
    min-width: 110px;
}

.gplla-table td.gplla-col-rel .gpl-tag {
    margin: 1px 0;
}

.gplla-table .gplla-col-type,
.gplla-table .gplla-col-follow,
.gplla-table .gplla-col-anchor,
.gplla-table .gplla-col-dup {
    white-space: nowrap;
}

.gplla-tool .gplla-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.gplla-tool .gplla-sort:hover,
.gplla-tool .gplla-sort:focus {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--gpl-tool-blue, #4166e1) !important;
}

.gplla-tool .gplla-sort:focus-visible {
    outline: 2px solid var(--gpl-tool-blue, #4166e1);
    outline-offset: 2px;
}

.gplla-sort i {
    color: #b0b6c0;
    font-size: 11px;
}

.gplla-sort.is-active i {
    color: inherit;
}

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

/* --- Responsive --- */

@media (max-width: 1024px) {
    .gplla-tool .gplla-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .gplla-clear {
        margin-left: 0 !important;
    }
}

@media (max-width: 640px) {
    .gplla-tool .gplla-stat-grid {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .gplla-filterbar {
        gap: 12px;
    }

    .gplla-frange {
        width: 100%;
    }

    .gplla-frange label {
        min-width: 72px;
    }

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

    .gplla-tool .gplla-table thead th,
    .gplla-tool .gplla-table tbody td {
        padding-right: 8px;
        padding-left: 8px;
    }

    .gplla-table .gplla-col-index {
        width: 36px;
    }
}

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

/* Reduced motion: the spinner stands still; the "Analyzing…" text next to it still says what is happening. */
@media (prefers-reduced-motion: reduce) {
    .gplla-spinner {
        animation: none;
    }
}

/* Standalone small buttons keep a 24 × 24 px target (WCAG 2.5.8) on touch screens too. */
.gplla-tool .gplla-sort,
.gplla-tool .gplla-clear,
.gplla-tool #gplla-sample-url {
    min-height: 24px;
}
