/* TFNZDirectory Module Styles */
.tfnz-directory_items::-webkit-scrollbar {
    width: 10px;
}
.tfnz-directory_items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}
.tfnz-directory_items::-webkit-scrollbar-thumb {
    background: #008caa;
    border-radius: 5px;
    min-height: 48px;
}
.tfnz-directory_items::-webkit-scrollbar-thumb:hover {
    background: #006d85;
}
/* Firefox only: Chrome ignores the ::-webkit-scrollbar rules above when scrollbar-color or scrollbar-width is set */
@supports not selector(::-webkit-scrollbar) {
    .tfnz-directory_items {
        scrollbar-color: #008caa #f1f1f1;
    }
}

.tfnz-directory {
    font-family: inherit;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0 35px;
    background: #eef2f5;
    /* Carries the grey to both edges of the page; a shadow adds no width, so no sideways scroll */
    box-shadow: 0 0 0 100vmax #eef2f5;
    clip-path: inset(0 -100vmax);
}

.tfnz-directory_controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 15px 15px;
    border-radius: 6px;
}

.tfnz-directory_controls-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    align-items: flex-end;
    width: 100%;
}

.tfnz-directory_search {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.tfnz-directory_search label,
.tfnz-directory_category label,
.tfnz-directory_sort label {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: #385975;
    margin-bottom: 6px;
}

.tfnz-directory_search-input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 0.25rem;
    font-size: 16px;
    height: 38px;
    box-sizing: border-box;
}

.tfnz-directory_search-input:focus {
    outline: none;
    border-color: #008CAA;
    box-shadow: 0 0 0 2px rgba(0, 140, 170, 0.1);
}

.tfnz-directory_sort {
    min-width: 180px;
    display: flex;
    flex-direction: column;
}

.tfnz-directory_category {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
}

@media (max-width: 576px) {
    .tfnz-directory_controls-row {
        flex-wrap: wrap;
    }

    .tfnz-directory_category {
        width: 240px;
        min-width: 240px;
        max-width: 240px;
    }
}

.tfnz-directory_category-dropdown {
    position: relative;
    width: 100%;
}

.tfnz-directory_category-toggle {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 0.25rem;
    font-size: 16px;
    height: 38px;
    box-sizing: border-box;
    background-color: #fff;
    cursor: pointer;
}

.tfnz-directory_category-toggle:hover,
.tfnz-directory_category-toggle:focus {
    border-color: #008CAA;
    outline: none;
}

.tfnz-directory_category-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.tfnz-directory_category-dropdown.open .tfnz-directory_category-options {
    display: block;
}

.tfnz-directory_category-option {
    display: block;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
}

.tfnz-directory_category-option:hover {
    background: #f5f5f5;
}

.tfnz-directory_category-option input {
    margin-right: 6px;
}

.tfnz-directory_filters > label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: #385975;
}

.tfnz-directory_sort-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 0.25rem;
    font-size: 16px;
    height: 38px;
    box-sizing: border-box;
    background-color: #fff;
}

.tfnz-directory_sort-select:hover,
.tfnz-directory_sort-select:focus {
    border-color: #008CAA;
    outline: none;
}

.tfnz-directory_filters {
    width: 100%;
}

/* Items Grid */
.tfnz-directory_items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: stretch;
    max-height: 620px;
    overflow-y: auto;
    padding: 15px;
    margin: 0;
    border: 1px solid #e5e5e5;
    border-radius: 0.25rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    position: relative;
}

.tfnz-directory_item {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 0.25rem;
    overflow: hidden;
    transition: border-color 0.35s ease, background-color 0.35s ease, opacity 0.35s ease, box-shadow 0.35s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.tfnz-directory_item:hover {
    border-color: #008CAA;
}

.tfnz-directory_item-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tfnz-directory_item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.tfnz-directory_score-circle-wrap {
    flex-shrink: 0;
}

.tfnz-directory_score-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    padding-top: 2px;
    box-sizing: border-box;
}

.tfnz-directory_item-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #385975;
    text-transform: none;
}

.tfnz-directory_item-subtitle {
    margin: 0 0 2px;
    font-size: 12px;
    color: #6b8299;
    text-transform: none;
}

.tfnz-directory_item-text {
    display: flex;
    flex-direction: column;
}

.tfnz-directory_item-expand {
    display: none;
}

.tfnz-directory_expander {
    filter: drop-shadow(0 0.5rem 3rem rgba(192, 197, 206, 0.5));
    background: #fff;
    border-radius: 0.25rem;
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transition: grid-template-rows 0.5s cubic-bezier(.4,0,.2,1), opacity 0.25s cubic-bezier(.4,0,.2,1);
    position: relative;
    margin: 20px 0;
    grid-column: 1 / -1;
}

.tfnz-directory_expander.tfnz-directory_expander-closing {
    grid-template-rows: 0fr;
    opacity: 0;
}

.tfnz-directory_expander-content {
    overflow: hidden;
}

.tfnz-directory_expander-inner {
    width: 80%;
    padding: 40px 0;
    display: block;
    margin: 0 auto;
    font-size: 16px;
    color: #333;
    line-height: 1.6;
}

.tfnz-directory_expander-inner p,
.tfnz-directory_expander-inner li {
    font-size: 18px;
    color: #333;
    margin-left: 0 !important;
    line-height: 1.46;
}

.tfnz-directory_expander-inner p.tfnz-directory_expander-status {
    color: #666;
    text-align: center;
    margin: 0;
}

.tfnz-directory_pointer {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 20px;
    background: #fff;
    clip-path: polygon(0 0, 0 1px, 50% 100%, 100% 1px, 100% 0);
    z-index: 4;
}

.tfnz-directory_item-active {
    filter: drop-shadow(0 0.5rem 2rem #c0c5ce);
}

/* Desktop-only: subtly dim non-selected tiles and emphasize the selected one */
@media (min-width: 1025px) {
    .tfnz-directory_items--has-active .tfnz-directory_item {
        background: #fafbfc;
        opacity: 0.75;
    }

    .tfnz-directory_items--has-active .tfnz-directory_item.tfnz-directory_item-active {
        background: #fff;
        opacity: 1;
        border-color: transparent;
        z-index: 2;
        overflow: visible;
    }

    .tfnz-directory_item-title {
        transition: font-size 0.35s ease, line-height 0.35s ease;
    }

    .tfnz-directory_items--has-active .tfnz-directory_item.tfnz-directory_item-active .tfnz-directory_item-title {
        font-size: 1.8em;
        line-height: 42px;
    }

    /* Dim score circles on unselected tiles */
    .tfnz-directory_items--has-active .tfnz-directory_item .tfnz-directory_score-circle {
        opacity: 0.28;
        transition: opacity 0.35s ease;
    }

    .tfnz-directory_items--has-active .tfnz-directory_item.tfnz-directory_item-active .tfnz-directory_score-circle,
    .tfnz-directory_items--has-active .tfnz-directory_item:hover .tfnz-directory_score-circle {
        opacity: 1;
    }

    /* Remove keyline and use softer shadow on hover */
    .tfnz-directory_item:hover {
        border-color: transparent;
        background: #fff;
        box-shadow: 0 0.025rem 1rem rgba(0, 0, 0, 0.12);
    }

    /* Remove keyline and reduce shadow on active tile */
    .tfnz-directory_item-active {
        border-color: transparent;
        box-shadow: 0 0.025rem 1rem rgba(0, 0, 0, 0.12);
        filter: none;
    }

}

.tfnz-directory_item-admin {
    padding: 10px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.tfnz-directory_empty {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 16px;
}

.tfnz-directory_add {
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 1024px) {
    .tfnz-directory_items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tfnz-directory_controls {
        flex-direction: column;
        align-items: stretch;
    }

    .tfnz-directory_items {
        grid-template-columns: 1fr;
        gap: 0;
        max-height: 500px;
        overflow-y: auto;
    }

    .tfnz-directory_item {
        border: none;
        border-radius: 0;
        position: relative;
        padding: 20px 15px;
    }

    .tfnz-directory_item:not(:first-child)::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: #e6e7e8;
    }

    .tfnz-directory_item:hover {
        border-color: transparent;
    }

    .tfnz-directory_item-content {
        padding: 0;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .tfnz-directory_item-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .tfnz-directory_score-circle {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    .tfnz-directory_item-title {
        font-size: 18px;
    }

    .tfnz-directory_item {
        height: auto;
    }

    .tfnz-directory_item-active {
        filter: none;
    }

    /* Remove top padding when a tile is active so content
       cannot peek through above the sticky tile header */
    .tfnz-directory_items--has-active {
        padding-top: 0;
    }

    /* Mobile: light grey for unselected, white for selected */
    .tfnz-directory_items--has-active .tfnz-directory_item {
        background: #f4f5f7;
    }

    /* Sticky active tile so it pins to the top of the scroll container
       while the user scrolls through the expander content */
    .tfnz-directory_items--has-active .tfnz-directory_item.tfnz-directory_item-active {
        position: sticky;
        top: 0;
        z-index: 3;
        background: #fff;
    }

    .tfnz-directory_expander {
        filter: none;
        margin: 0;
    }

    .tfnz-directory_pointer {
        display: none;
    }

    .tfnz-directory_expander-inner {
        width: auto !important;
        padding: 20px 15px !important;
        margin: 0 !important;
    }
}
