/**
 * Business Members Directory Styles
 *
 * Clean directory design: logo + company name cards.
 *
 * Color Scheme:
 * - Primary Green: #69b654
 * - Dark: #303133
 * - Accent Pink: #d7367d
 * - Blue: #005AEE
 *
 * @package BusinessWest
 * @since 2.0.0
 */

:root {
    --bw-primary: #69b654;
    --bw-primary-dark: #5a9f47;
    --bw-dark: #303133;
    --bw-accent: #d7367d;
    --bw-blue: #005AEE;
    --bw-light-gray: #f8f9fa;
    --bw-border: #e2e5e9;
    --bw-radius: 12px;
    --bw-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --bw-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Main Container
======================================== */
.bw-members-directory {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 20px;
    box-sizing: border-box;
    width: 100%;
}

/* ========================================
   Public Category Tabs
======================================== */
.bw-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bw-border);
}

.bw-category-tab {
    padding: 8px 22px;
    border: 2px solid var(--bw-border);
    border-radius: 24px;
    background: #fff;
    color: var(--bw-dark);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.bw-category-tab:hover {
    border-color: var(--bw-primary);
    color: var(--bw-primary);
    background: rgba(105, 182, 84, 0.04);
}

.bw-category-tab.active {
    background: var(--bw-primary);
    border-color: var(--bw-primary);
    color: #fff;
}

/* ========================================
   Category Dropdown (mobile only)
======================================== */
.bw-category-dropdown-wrap {
    display: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bw-category-dropdown {
    width: 100%;
    max-width: 100%;
    padding: 0 15px;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    color: var(--bw-dark);
    background-color: #fff;
    border: 2px solid var(--bw-border);
    border-radius: 10px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.bw-category-dropdown:focus {
    outline: none;
    border-color: var(--bw-primary);
    box-shadow: 0 0 0 3px rgba(105, 182, 84, 0.15);
}

/* Subcategory dropdown (mobile only) */
.bw-subcategory-dropdown-wrap {
    display: none;
    margin-top: 10px;
}

/* ========================================
   Selected Category Label
======================================== */
.bw-selected-category {
    margin-top: 16px;
    margin-bottom: 4px;
}

.bw-selected-category-label {
    display: inline-block;
    padding: 8px 22px;
    background: var(--bw-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: 24px;
    line-height: 1.4;
}

/* ========================================
   Subcategory Pills
======================================== */
.bw-subcategory-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    margin-bottom: 18px;
    padding: 0;
}

.bw-subcategory-tab {
    padding: 5px 16px;
    border: 1px solid var(--bw-border);
    border-radius: 20px;
    background: var(--bw-light-gray);
    color: #666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.bw-subcategory-tab:hover {
    border-color: var(--bw-blue) !important;
    color: var(--bw-blue) !important;
    background: rgba(47, 109, 181, 0.04) !important;
}

.bw-subcategory-tab.active {
    background: var(--bw-blue) !important;
    border-color: var(--bw-blue) !important;
    color: #fff !important;
    font-weight: 600;
}

/* ========================================
   Filters / Search Bar
======================================== */
.bw-members-filters {
    background: #fff;
    padding: 16px 20px;
    margin-top: 20px;
    margin-bottom: 28px;
    border-radius: var(--bw-radius);
    border: 1px solid var(--bw-border);
}

.bw-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
}

/* Search Box */
.bw-search-box {
    position: relative;
    flex: 1 1 280px;
    min-width: 220px;
}

.bw-search-input {
    width: 100%;
    padding: 10px 42px 10px 38px;
    border: 1px solid var(--bw-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--bw-dark);
    background: var(--bw-light-gray);
    transition: all 0.2s ease;
    line-height: 1.4;
}

.bw-search-input::placeholder {
    color: #aab0b8;
}

.bw-search-input:focus {
    outline: none;
    border-color: var(--bw-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(105, 182, 84, 0.12);
}

.bw-search-icon {
    position: absolute;
    left: 12px;
    top: 9px;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aab0b8;
    pointer-events: none;
}

.bw-search-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.bw-search-clear {
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #aab0b8;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    border-radius: 50%;
    transition: color 0.2s;
}

.bw-search-clear:hover {
    color: var(--bw-dark);
}

.bw-search-clear.visible {
    display: flex !important;
}

/* Industry Filter */
.bw-industry-filter {
    flex: 0 1 220px;
}

.bw-filter-select {
    width: 100%;
    padding: 10px 32px 10px 12px;
    border: 1px solid var(--bw-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--bw-dark);
    background: var(--bw-light-gray);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    line-height: 1.4;
}

.bw-filter-select:focus {
    outline: none;
    border-color: var(--bw-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(105, 182, 84, 0.12);
}

/* ConnectHer Toggle */
.bw-connecther-filter {
    display: flex;
    align-items: stretch;
}

.bw-connecther-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    background: var(--bw-light-gray);
    border: 1px solid var(--bw-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
    line-height: 1.4;
}

.bw-connecther-filter-label {
    height: 41.59px;
    margin-top: 9px;
    margin-bottom: 0;
}

.bw-connecther-filter-label:hover {
    border-color: #8b5cf6;
    color: #6b3fa0;
}

.bw-connecther-filter-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8b5cf6;
    cursor: pointer;
    margin: 0;
}

.bw-connecther-filter-label input[type="checkbox"]:checked ~ span {
    color: #6b3fa0;
    font-weight: 600;
}

.bw-connecther-filter-label svg {
    color: #8b5cf6;
    flex-shrink: 0;
}

/* Results Count */
.bw-results-count {
    margin-top: 9px;
    margin-left: auto;
    color: #888;
    font-size: 13px;
    white-space: nowrap;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.bw-results-count strong {
    color: var(--bw-dark);
    font-weight: 600;
}

/* Active Filters Bar */
.bw-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--bw-border);
}

.bw-active-filters:empty {
    display: none;
}

.bw-active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(105, 182, 84, 0.08);
    border: 1px solid rgba(105, 182, 84, 0.25);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--bw-primary-dark);
    line-height: 1;
}

.bw-active-filter-tag .bw-filter-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--bw-primary-dark);
    font-size: 14px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.bw-active-filter-tag .bw-filter-remove:hover {
    opacity: 1;
}

/* Subcategory filter tags use blue to visually distinguish from green parent tags */
.bw-active-filter-tag[data-filter-type="subcategory"] {
    background: rgba(47, 109, 181, 0.08) !important;
    border: 1px solid rgba(47, 109, 181, 0.25) !important;
    color: var(--bw-blue) !important;
}

.bw-clear-all-filters {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #888;
    text-decoration: underline;
    padding: 4px 6px;
    transition: color 0.15s;
}

.bw-clear-all-filters:hover {
    color: var(--bw-dark);
}

/* ========================================
   Members Grid — Logo Cards
======================================== */
.bw-members-grid-container {
    position: relative;
    min-height: 200px;
}

.bw-members-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

/* ── Member Card ───────────────────────────────── */
.bw-member-card {
    background: #fff;
    border-radius: var(--bw-radius);
    overflow: hidden;
    border: 1px solid var(--bw-border);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
}

.bw-member-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bw-shadow-hover);
    border-color: var(--bw-primary);
}

/* Entire card is a link */
.bw-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 16px 22px;
    text-decoration: none !important;
    color: inherit;
    height: 100%;
}

.bw-card-link:hover {
    text-decoration: none !important;
    color: inherit;
}

/* ── Logo — rounded square to prevent cropping ── */
.bw-member-logo {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bw-logo-image {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--bw-border);
    padding: 6px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.bw-member-card:hover .bw-logo-image {
    border-color: var(--bw-primary);
    box-shadow: 0 2px 8px rgba(105, 182, 84, 0.15);
}

/* ── Business Name ──────────────────────────────── */
.bw-member-name {
    margin: 0;
    font-size: 20px !important;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: var(--bw-dark);
    word-break: break-word;
    transition: color 0.2s ease;
}

.bw-member-card:hover .bw-member-name {
    color: var(--bw-primary);
}

/* ── Badges ─────────────────────────────────────── */
.bw-card-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    min-height: 0;
}

.bw-connecther-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: linear-gradient(135deg, #f0e6f6 0%, #e8f4fd 100%);
    border: 1px solid #d4b8e8;
    border-radius: 10px;
    color: #6b3fa0;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

.bw-connecther-badge svg {
    color: #8b5cf6;
    flex-shrink: 0;
}

.bw-member-label-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: linear-gradient(135deg, #e6f4ea 0%, #dff0fc 100%);
    border: 1px solid #a8d5ba;
    border-radius: 10px;
    color: #1a7a3a;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

/* ── Industry text ──────────────────────────────── */
.bw-member-industry-text {
    margin-top: 6px;
    font-size: 11px;
    color: #aaa;
    text-align: center;
    line-height: 1.35;
}

/* ========================================
   Loading & No Results
======================================== */
.bw-grid-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--bw-radius);
    z-index: 10;
}

.bw-grid-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e5e9;
    border-top: 3px solid var(--bw-primary);
    border-radius: 50%;
    animation: bw-spin 0.8s linear infinite;
    display: inline-block;
    margin-bottom: 8px;
}

.bw-grid-loading p {
    color: #888;
    font-size: 13px;
    margin: 0;
}

@keyframes bw-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bw-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--bw-light-gray);
    border-radius: var(--bw-radius);
}

.bw-no-results p {
    color: #666;
    font-size: 15px;
    margin: 0;
}

/* ========================================
   Pagination — Number-based
======================================== */
.bw-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    margin-top: 32px;
}

.bw-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: #fff;
    color: var(--bw-dark);
    border: 1px solid var(--bw-border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
}

.bw-page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--bw-primary);
    color: var(--bw-primary);
    background: rgba(105, 182, 84, 0.04);
}

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

.bw-page-btn:disabled {
    color: #ccc;
    border-color: #eee;
    cursor: not-allowed;
    background: #fafafa;
}

.bw-page-btn svg {
    width: 16px;
    height: 16px;
}

.bw-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #aaa;
    font-size: 14px;
    user-select: none;
}

/* Pagination info text */
.bw-page-summary {
    color: #888;
    font-size: 13px;
    margin-left: 12px;
    white-space: nowrap;
}

/* ========================================
   Responsive Design
======================================== */

/* Tablet */
@media (max-width: 960px) {
    .bw-members-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .bw-members-directory {
        padding: 0 20px 15px;
    }

    /* Hide tab buttons, show dropdowns on mobile */
    .bw-category-tabs {
        display: none !important;
    }
    .bw-category-dropdown-wrap {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin-bottom: 0;
    }

    /* Hide pill-based subcategories and selected label on mobile */
    .bw-subcategory-tabs {
        display: none !important;
    }
    .bw-selected-category {
        display: none !important;
    }

    /* Show subcategory dropdown on mobile when a category is selected */
    .bw-subcategory-dropdown-wrap.bw-mobile-visible {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Force the entire directory to stack vertically and stay within bounds */
    .bw-members-directory {
        display: block !important;
        overflow-x: hidden !important;
    }

    .bw-members-directory *,
    .bw-members-directory *::before,
    .bw-members-directory *::after {
        box-sizing: border-box;
    }

    .bw-members-filters {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        padding: 12px 14px;
        overflow: hidden;
    }

    .bw-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }

    .bw-search-box {
        flex: none !important;
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .bw-industry-filter {
        flex: none !important;
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .bw-search-input {
        width: 100% !important;
        max-width: 100% !important;
    }

    .bw-results-count {
        margin-left: 0;
        margin-top: 0;
        text-align: left;
    }

    .bw-members-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .bw-card-link {
        padding: 20px 12px 18px;
    }

    .bw-member-logo {
        width: 72px;
        height: 72px;
        margin-bottom: 10px;
    }

    .bw-logo-image {
        border-radius: 12px;
        padding: 4px;
    }

    .bw-member-name {
        font-size: 13px !important;
    }

    .bw-page-summary {
        display: none;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .bw-members-directory {
        padding: 0 16px 10px;
    }

    .bw-members-filters {
        padding: 10px 12px;
    }

    .bw-members-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .bw-card-link {
        padding: 18px 10px 16px;
    }

    .bw-member-logo {
        width: 64px;
        height: 64px;
        margin-bottom: 8px;
    }

    .bw-member-name {
        font-size: 12px !important;
    }

    .bw-card-badges {
        margin-top: 6px;
    }

    .bw-connecther-badge,
    .bw-member-label-badge {
        font-size: 9px;
        padding: 2px 6px;
    }

    .bw-pagination {
        gap: 3px;
        margin-top: 24px;
    }

    .bw-page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
        padding: 0 8px;
    }
}

/* ========================================
   Accessibility
======================================== */
.bw-member-card:focus-within {
    outline: 2px solid var(--bw-primary);
    outline-offset: 2px;
}

/* ========================================
   Print Styles
======================================== */
@media print {
    .bw-members-filters,
    .bw-pagination,
    .bw-category-tabs,
    .bw-subcategory-tabs {
        display: none !important;
    }

    .bw-members-grid {
        display: block;
    }

    .bw-member-card {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* ========================================
   Homepage Members — Cards Design Grid
======================================== */
.bw-hp-cards-grid {
    display: grid;
    gap: 20px;
}

.bw-hp-cards-grid.bw-hp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.bw-hp-cards-grid.bw-hp-cols-3 { grid-template-columns: repeat(3, 1fr); }
.bw-hp-cards-grid.bw-hp-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .bw-hp-cards-grid.bw-hp-cols-3,
    .bw-hp-cards-grid.bw-hp-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .bw-hp-cards-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* "See more" button */
.bw-hp-see-more {
    text-align: center;
    margin-top: 28px;
}
.bw-hp-see-more-btn {
    display: inline-block;
    padding: 12px 36px;
    background: var(--bw-primary, #69b654);
    color: #fff !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.2s ease;
}
.bw-hp-see-more-btn:hover {
    background: var(--bw-primary-dark, #5a9f47);
    transform: translateY(-1px);
}
