/**
 * Basis Tables – Frontend Styles
 *
 * Styles for the [basis_table] shortcode output:
 * filter bar, card grid, and pagination.
 *
 * @package BasisTables
 */

/* =========================================================================
   WRAPPER – uses --bt-cols (set inline from PHP, default 3)
   ====================================================================== */

.bt-wrapper {
    --bt-cols: 3;
    --bt-primary-color: #2271b1;
    --bt-primary-hover: #da7c09; /* default orange hover */
    --bt-badge-bg-color: #e2e8f0;
    --bt-badge-text-color: #475569;
    max-width: 1200px;
    margin: 2rem auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* =========================================================================
   FILTERS
   ====================================================================== */

.bt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
}

/* --- Search with icon --- */
.bt-filter-search {
    flex: 1;
    min-width: 200px;
}

.bt-wrapper .bt-search-input,
.bt-wrapper .bt-tag-filter,
.bt-wrapper .bt-year-filter,
.bt-wrapper .bt-extra-filter {
    height: 42px !important;
    max-height: 42px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    border: 1px solid #d0d5dd !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    line-height: 40px !important;
    background-color: #fff !important;
    box-sizing: border-box !important;
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bt-wrapper .bt-search-input {
    width: 100%;
}

.bt-search-input:focus,
.bt-tag-filter:focus,
.bt-year-filter:focus,
.bt-extra-filter:focus {
    outline: none;
    border-color: var(--bt-primary-color);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

/* --- Select dropdowns --- */
.bt-filter-select-wrap {
    position: relative;
}

.bt-wrapper .bt-tag-filter,
.bt-wrapper .bt-year-filter,
.bt-wrapper .bt-extra-filter {
    min-width: 160px;
    padding-right: 40px !important;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 12px 8px !important;
}

/* --- Reset button --- */
.bt-filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: #667085;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.bt-filter-reset:hover {
    background: #fef3f2;
    color: #d63638;
    border-color: #d63638;
}

/* =========================================================================
   HEADER ACTIONS & COUNT
   ====================================================================== */

.bt-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
    flex-wrap: wrap;
    gap: 10px;
}

.bt-count {
    font-size: 14px;
    color: #667085;
}

.bt-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--bt-primary-color);
    background: #f0f6fc;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.bt-btn-download:hover {
    background: var(--bt-primary-color);
    color: #fff;
    text-decoration: none;
}

.bt-count-number {
    font-weight: 700;
    color: #344054;
}

/* =========================================================================
   GRID – column count driven by --bt-cols CSS variable
   ====================================================================== */

.bt-grid {
    display: grid;
    grid-template-columns: repeat(var(--bt-cols, 3), 1fr);
    gap: 20px;
}

/* =========================================================================
   CARD – can be an <a> or <div>
   ====================================================================== */

.bt-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    text-decoration: none !important;
    color: inherit;
    word-break: break-word;
    overflow-wrap: break-word;
    cursor: default;
    content-visibility: auto;
    contain-intrinsic-size: 180px;
}

.bt-card:hover {
    text-decoration: none;
    color: inherit;
}

.bt-card-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #667085;
    margin-bottom: 8px;
}

.bt-card-date-icon {
    font-size: 14px;
    line-height: 1;
}

.bt-card-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 6px;
    color: var(--bt-title-color) !important;
    text-decoration: none !important;
}

.bt-card:hover .bt-card-title,
.bt-card:focus .bt-card-title {
    color: var(--bt-title-color) !important;
    text-decoration: none !important;
}

.bt-card-primary-topic {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bt-primary-color);
    margin-bottom: 12px;
}

.bt-card-source {
    font-size: 0.85em;
    color: #64748b;
    margin-bottom: 12px;
}

.bt-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.bt-card-badge {
    background: var(--bt-badge-bg-color);
    color: var(--bt-badge-text-color);
    font-size: 0.75em;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.bt-card-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--bt-text-color);
    margin: 0 0 16px;
    max-height: 4.8em; /* 3 lines of 1.6 line-height. Prevents text reveal on sibling stretch */

    /* Clamp to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.bt-card-desc.bt-expanded {
    display: block !important;
    -webkit-line-clamp: none !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Link label at bottom – no underline, no arrow */
.bt-card-link {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: var(--bt-primary-color);
    text-decoration: none !important;
    margin-top: auto;
    padding: 8px 0 0;
    transition: color 0.15s;
}

.bt-card-link:hover {
    color: var(--bt-primary-hover, #da7c09) !important;
    text-decoration: none !important;
}

/* Hidden card (filtered out) */
.bt-card.bt-hidden {
    display: none;
}

/* =========================================================================
   PAGINATION
   ====================================================================== */

.bt-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.bt-page-info {
    font-size: 14px;
    color: #667085;
    margin-right: 10px;
}

.bt-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 500;
    color: #344054;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    box-sizing: border-box;
}

.bt-page-btn:hover:not([disabled]):not(.bt-page-active) {
    background: #f3f4f6;
    border-color: #98a2b3;
}

.bt-page-btn.bt-page-active {
    background: var(--bt-primary-color);
    border-color: var(--bt-primary-color);
    color: #fff;
    font-weight: 700;
    cursor: default;
}

.bt-page-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.bt-page-prev,
.bt-page-next {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.bt-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 38px;
    font-size: 14px;
    color: #98a2b3;
}

/* =========================================================================
   NO RESULTS MESSAGE
   ====================================================================== */

.bt-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #667085;
    font-size: 15px;
}

/* =========================================================================
   RESPONSIVE – tablet: min(2, cols), mobile: always 1
   ====================================================================== */

@media screen and (max-width: 600px) {
    .bt-wrapper {
        --bt-cols: 1 !important;
    }

    .bt-grid {
        gap: 14px;
    }

    .bt-filters {
        flex-direction: column;
        padding: 12px;
    }

    .bt-filter-search {
        min-width: auto;
        width: 100%;
    }

    .bt-tag-filter,
    .bt-year-filter {
        min-width: auto;
        width: 100%;
    }

    .bt-card {
        padding: 18px;
    }

    .bt-pagination {
        gap: 4px;
    }

    .bt-page-info {
        width: 100%;
        text-align: center;
        margin-right: 0;
        margin-bottom: 6px;
    }

    .bt-page-btn {
        min-width: 34px;
        height: 34px;
        font-size: 13px;
    }
}

@media screen and (min-width: 601px) and (max-width: 900px) {
    .bt-wrapper {
        --bt-cols: 2 !important;
    }
}


/* =========================================================================
   DESCRIPTION EXPANDER TOGGLE LINK
   ====================================================================== */

.bt-desc-toggle {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--bt-primary-color);
    text-decoration: none !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: -10px 0 16px 0 !important;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s;
}

.bt-desc-toggle:hover {
    color: var(--bt-primary-hover, #da7c09) !important;
}


