/*
 * Frontend CSS — Equipment Archive Page
 *
 * Prefix   : .te-
 * Tokens   : mirrors te-testing-type.css :root vars
 * Layout   : sidebar + results grid, collapses to single column on mobile
 */

/* ── Shared tokens (duplicated so this file is self-contained) ───────── */
:root {
    --te-primary-blue: #004b87;
    --te-secondary-blue: #00335e;
    --te-accent-red: #cc0000;
    --te-background-light: #f8f9fa;
    --te-border-color: #dee2e6;
    --te-text-dark: #212529;
    --te-text-muted: #6c757d;
    --te-spacing-sm: 8px;
    --te-spacing-md: 16px;
    --te-spacing-lg: 32px;
    --te-border-radius: 4px;
}

/* ── Page wrapper ────────────────────────────────────────────────────── */
.te-archive-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--te-spacing-lg) var(--te-spacing-md);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--te-text-dark);
    line-height: 1.6;
}

/* ── Page header ─────────────────────────────────────────────────────── */
.te-archive-header {
    border-bottom: 2px solid var(--te-primary-blue);
    padding-bottom: var(--te-spacing-md);
    margin-bottom: var(--te-spacing-lg);
}

.te-archive-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--te-primary-blue);
    margin: 0 0 var(--te-spacing-sm) 0;
    line-height: 1.2;
}

.te-archive-description {
    color: var(--te-text-muted);
    margin: 0 0 var(--te-spacing-sm) 0;
    max-width: 680px;
}

.te-archive-clear-filters {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--te-accent-red);
    text-decoration: none;
    margin-top: var(--te-spacing-sm);
}

.te-archive-clear-filters:hover {
    text-decoration: underline;
}

/* ── Two-column layout: sidebar + results ────────────────────────────── */
.te-archive-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--te-spacing-lg);
    align-items: start;
}

@media (min-width: 960px) {
    .te-archive-layout {
        grid-template-columns: 240px 1fr;
    }

    .te-archive-layout--no-sidebar {
        grid-template-columns: 1fr;
    }

    /* Sidebar is last in DOM but visually first column */
    .te-archive-sidebar {
        order: -1;
    }
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.te-archive-sidebar {
    position: sticky;
    top: 24px;
}

/* On mobile: not sticky, stacks below results naturally */
@media (max-width: 959px) {
    .te-archive-sidebar {
        position: static;
        order: 0;
    }
}

.te-filter-group {
    margin-bottom: var(--te-spacing-lg);
}

.te-filter-group__title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--te-secondary-blue);
    margin: 0 0 var(--te-spacing-sm) 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--te-border-color);
}

/* Checkbox list */
.te-filter-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.te-filter-list--checkbox {
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--te-border-color);
    border-radius: var(--te-border-radius);
    background: #fff;
}

/* Subtle scrollbar styling */
.te-filter-list--checkbox::-webkit-scrollbar {
    width: 5px;
}

.te-filter-list--checkbox::-webkit-scrollbar-thumb {
    background: var(--te-border-color);
    border-radius: 3px;
}

.te-filter-item {
    border-bottom: 1px solid var(--te-border-color);
}

.te-filter-item:last-child {
    border-bottom: none;
}

/* Extreme specificity + !important to nuke theme button styles completely */
html body .te-archive-wrap .te-archive-layout .te-archive-sidebar .te-filter-group .te-filter-list .te-filter-item button.te-filter-link,
html body .te-archive-wrap .te-archive-layout .te-archive-sidebar button.te-filter-link,
button.te-filter-link {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    text-decoration: none !important;
    color: var(--te-text-dark) !important;
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    transition: background 0.15s ease !important;

    /* Nuclear resets for <button> */
    border: none !important;
    border-color: transparent !important;
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
    cursor: pointer !important;
    text-align: left !important;
    width: 100% !important;
    max-width: none !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    box-shadow: none !important;
    outline: none !important;
    border-radius: 0 !important;
    line-height: 1.5 !important;
    min-height: 0 !important;
    min-width: 0 !important;
    height: auto !important;
    vertical-align: middle !important;
}

html body .te-archive-wrap .te-archive-layout .te-archive-sidebar .te-filter-group .te-filter-list .te-filter-item button.te-filter-link:hover {
    background: var(--te-background-light) !important;
    color: var(--te-primary-blue) !important;
}

html body .te-archive-wrap .te-archive-layout .te-archive-sidebar .te-filter-group .te-filter-list .te-filter-item.is-active button.te-filter-link {
    color: var(--te-primary-blue) !important;
    font-weight: 600 !important;
    background: #eaf1f8 !important;
}

/* Checkbox indicator */
.te-filter-check {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    border: 2px solid var(--te-border-color);
    border-radius: 3px;
    display: inline-block;
    transition: border-color 0.15s, background 0.15s;
}

.te-filter-item.is-active .te-filter-check {
    background: var(--te-primary-blue);
    border-color: var(--te-primary-blue);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='%23fff' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px 8px;
}

.te-filter-term {
    flex: 1;
}

.te-filter-count {
    font-size: 0.75rem;
    color: var(--te-text-muted);
    margin-left: auto;
}

/* Dropdown select */
.te-filter-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--te-border-color);
    border-radius: var(--te-border-radius);
    background: #fff;
    font-size: 0.875rem;
    color: var(--te-text-dark);
    font-family: inherit;
    cursor: pointer;
    appearance: auto;
}

.te-filter-select:focus {
    outline: 2px solid var(--te-primary-blue);
    outline-offset: 1px;
}

/* ── Results area ────────────────────────────────────────────────────── */
.te-archive-result-count {
    font-size: 0.875rem;
    color: var(--te-text-muted);
    margin: 0 0 var(--te-spacing-md) 0;
}

/* Equipment card list — one item per row */
.te-equipment-grid {
    display: flex;
    flex-direction: column;
    gap: var(--te-spacing-md);
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Individual card — horizontal row */
.te-equipment-card {
    background: #fff;
    border: 1px solid var(--te-border-color);
    border-radius: var(--te-border-radius);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.te-equipment-card:hover {
    box-shadow: 0 4px 16px rgba(0, 75, 135, 0.1);
    border-color: var(--te-primary-blue);
}

.te-equipment-card article {
    display: flex;
    flex-direction: column;
    gap: var(--te-spacing-md);
    padding: var(--te-spacing-md);
}

.te-equipment-card__image-wrap {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
}

.te-equipment-card__image {
    width: 100%;
    height: 100%;
    display: block;
}

.te-equipment-card:hover .te-equipment-card__image {
    transform: none;
}

.te-equipment-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Tighter gap for better hierarchy */
}

@media (min-width: 768px) {
    .te-equipment-card article {
        flex-direction: row;
        align-items: flex-start;
        gap: var(--te-spacing-lg);
    }

    .te-equipment-card__image-wrap {
        flex: 0 0 120px;
    }
}

.te-equipment-card__header {
    margin: 0;
}

.te-equipment-card__title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.te-equipment-card__title a {
    color: var(--te-primary-blue);
    text-decoration: none;
}

.te-equipment-card__title a:hover {
    text-decoration: underline;
}

.te-equipment-card__standard {
    display: block;
    font-size: 0.8125rem;
    color: var(--te-secondary-blue);
    font-weight: 500;
    margin-top: 2px;
}

/* Badge chips */
.te-equipment-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: var(--te-spacing-sm) 0;
    padding: 0;
}

.te-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.te-badge--type {
    background: #e8f0f8;
    color: var(--te-primary-blue);
    border-color: #b8d0e8;
}

.te-badge--force {
    background: #fef3e2;
    color: #7a4f00;
    border-color: #f0d49a;
}

.te-badge--fixture {
    background: #eaf4ea;
    color: #1a5c1a;
    border-color: #b2d8b2;
}

.te-badge--material {
    background: var(--te-background-light);
    color: var(--te-text-muted);
    border-color: var(--te-border-color);
}

/* Excerpt */
.te-equipment-card__excerpt {
    font-size: 0.875rem;
    color: var(--te-text-muted);
    margin: 0;
    flex: 1;
    line-height: 1.5;
}

/* ── No results ──────────────────────────────────────────────────────── */
.te-archive-no-results {
    padding: var(--te-spacing-lg);
    text-align: center;
    background: var(--te-background-light);
    border: 1px dashed var(--te-border-color);
    border-radius: var(--te-border-radius);
}

.te-archive-no-results__message {
    font-size: 1rem;
    color: var(--te-text-muted);
    margin: 0 0 var(--te-spacing-md) 0;
}

/* Shared ghost button (no results CTA) */
.te-btn--ghost {
    display: inline-block;
    padding: 10px 20px;
    border: 2px solid var(--te-primary-blue);
    border-radius: var(--te-border-radius);
    color: var(--te-primary-blue);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s ease;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.te-btn--ghost:hover {
    background: var(--te-background-light);
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.te-archive-pagination {
    margin-top: var(--te-spacing-lg);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.te-archive-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--te-border-color);
    border-radius: var(--te-border-radius);
    text-decoration: none;
    font-size: 0.875rem;
    color: var(--te-text-dark);
    background: #fff;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.te-archive-pagination .page-numbers:hover {
    background: var(--te-background-light);
    border-color: var(--te-primary-blue);
}

.te-archive-pagination .page-numbers.current {
    background: var(--te-primary-blue);
    border-color: var(--te-primary-blue);
    color: #fff;
    font-weight: 700;
}

.te-archive-pagination .page-numbers.dots {
    border-color: transparent;
    background: transparent;
    cursor: default;
}