/* Members Section Styling */
.members-section {
    background-color: #f8f9fa;
    padding: 40px 0;
    min-height: 100vh;
}

/* Page Header */
.members-header {
    text-align: center;
    margin-bottom: 3rem;
}

.members-title {
    color: #698EE9;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.members-subtitle {
    color: #6c757d;
    font-size: 1.2rem;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

/* Search and Sort Controls */
.member-tile.search-hidden {
    display: none !important;
}

.members-controls {
    position: relative;
    z-index: 1000;
    margin-bottom: 2rem;
}

/* Search container with integrated clear button */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box {
    position: relative;
    flex-grow: 1;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 5;
}

.search-box input {
    padding-left: 2.5rem;
    padding-right: 3rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
    width: 100%;
}

.search-box input:focus {
    border-color: #999999;
    box-shadow: 0 0 0 0.2rem rgba(153, 153, 153, 0.25);
}

/* Clear button - fixed visibility and positioning */
.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    color: #6c757d;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.clear-search-btn.show {
    display: flex !important;
}

.clear-search-btn i:hover {
    color: #C3020D;
    transform: scale(1.5);
}

.clear-search-btn i {
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

/* Filter Button Styling - Similar to Sort Button */
.filter-icon-container {
    position: relative;
    display: flex;
    justify-content: flex-end;
    z-index: 1002;
    isolation: isolate;
    margin-right: 0.5rem;
}

.filter-icon {
    background: none;
    color: #6c757d;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 2px 4px rgba(153, 153, 153, 0.25);
}

.filter-icon:hover {
    background: #999999;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(153, 153, 153, 0.25);
}

.filter-icon.has-active-filters {
    background: #8CC63E;
    color: white;
    box-shadow: 0 2px 8px rgba(43, 116, 1, 0.3);
}

.filter-icon.has-active-filters:hover {
    background: #6f9e32;
}

.filter-icon i {
    font-size: 1.1rem;
}

/* Filter Section Styling - Full width with proper animations */
.filters-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 0; /* No margin when hidden */
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid #e9ecef;
    
    /* Animation properties */
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    visibility: hidden;
    transition: all 0.3s ease;
    
    /* Height animation */
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

.filters-section.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
    margin-bottom: 2rem;
    max-height: 500px; /* Large enough to fit content */
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.filters-content {
    max-height: none;
    overflow: visible;
    padding-top: 0;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: white;
    color: #495057;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: #698EE9;
    box-shadow: 0 0 0 0.2rem rgba(105, 142, 233, 0.25);
}

.filter-select:hover {
    border-color: #698EE9;
}

/* Clear Filters Button */
.clear-filters-container {
    margin-top: 1rem;
    text-align: right;
}

.clear-filters-btn {
    background: #ffeff0;
    border: 1px solid #C3020D;
    color: #C3020D;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: none;
}

.clear-filters-btn.show {
    display: inline-block;
}

.clear-filters-btn:hover {
    background: #ffd7da;
    color: #C3020D;
}

/* Active Filter Indicator */
.filter-select.has-filter {
    border-color: #698EE9;
    background: #f0f4ff;
}

/* Sort Icon and Popup Styling */
.sort-icon-container {
    position: relative;
    display: flex;
    justify-content: flex-end;
    z-index: 1001;
    isolation: isolate;
}

.sort-icon {
    background: none;
    color: #6c757d;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 2px 4px rgba(153, 153, 153, 0.25);
}

.sort-icon:hover {
    background: #999999;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(153, 153, 153, 0.25);
}

.sort-icon i {
    font-size: 1.1rem;
}

.sort-icon.has-active-sort {
    background: #8CC63E;
    color: white;
    box-shadow: 0 2px 8px rgba(43, 116, 1, 0.3);
}

.sort-icon.has-active-sort:hover {
    background: #6f9e32;
}

/* Sort popup styling */
.sort-popup {
    position: absolute !important;
    top: 55px;
    right: auto;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 9999 !important;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.sort-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Enhanced Sort Popup Header with Direction Toggle */
.sort-popup-header {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sort-popup-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Simple Direction Arrow */
.direction-arrow {
    color: #6c757d;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: 20px;
    text-align: center;
}

.direction-arrow:hover {
    color: #495057;
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.direction-arrow:active {
    transform: scale(0.95);
}

/* Animation for direction change */
.direction-arrow.changing {
    /* transform: scale(1.2) rotate(180deg); */
}

/* Grayed out arrow when on default sort */
.direction-arrow.disabled {
    color: #dee2e6;
    cursor: not-allowed;
}

.direction-arrow.disabled:hover {
    color: #dee2e6;
    background: none;
    transform: none;
}

/* Divider between reset and sort options */
.sort-option-divider {
    border-top: 1px solid #e9ecef;
    margin: 0.5rem 0;
}

/* Special styling for reset option */
.sort-option.reset-option {
    color: #6c757d;
    font-style: italic;
    padding: 0.5rem 1rem;
}

.sort-options {
    padding: 0.5rem 0;
}

.sort-option {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sort-option:hover {
    background-color: #f8f9fa;
}

.sort-option.active {
    background-color: #e3f2fd;
    color: #698EE9;
}

.sort-option i {
    margin-right: 0.75rem;
    width: 16px;
    color: #6c757d;
}

.sort-option.active i {
    color: #698EE9;
}

.sort-option-text {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Backdrop for closing popup */
.sort-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    display: none;
}

.sort-backdrop.show {
    display: block;
}

/* Member Tiles */
.member-tiles {
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.member-tile {
    background: white;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    overflow: hidden;
}

.member-tile.active {
    border: 2px solid #698EE9;
}

.member-tile.inactive {
    border: 2px solid #999999;
    opacity: 0.85;
    background-color: rgb(247 247 247);
}

.member-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.member-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
}

.member-header:hover {
    background-color: rgba(105, 142, 233, 0.03);
}

.expand-arrow {
    color: #6c757d;
    margin-right: 0.75rem;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    width: 15px;
    text-align: center;
}

.member-tile.expanded .expand-arrow {
    transform: rotate(90deg);
}

.member-avatar {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    margin-right: 0.75rem;
    overflow: hidden;
    border: 2px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.avatar-placeholder {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
}

.member-name {
    font-weight: 700;
    color: #212529;
    font-size: 1.1rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between; 
    gap: 0.75rem;
    /* flex-grow: 1; */
}

.member-name-text {
    flex-grow: 1;
}

.director-tag {
    background: #FFF9E6;
    border: 1.5px solid #EDAA03;
    color: #B8820A;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto; 
    white-space: nowrap;
}

.member-position {
    color: #6c757d;
    font-style: italic;
    font-size: 0.95rem;
    margin-left: auto;
    white-space: nowrap;
}

.member-details {
    border-top: 1px solid #e9ecef;
    padding: 0 1.25rem;
    background: #f8f9fa;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s ease;
}

.member-tile.expanded .member-details {
    max-height: 700px;
    padding: 1.25rem;
}

/* Member Description Section */
.member-description {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.member-description .detail-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    display: block;
}

.description-text {
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: justify;
}

/* Member Education in Grid */
.education-value {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.education-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.4;
}

.education-icon {
    color: #698EE9;
    font-size: 0.8rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.education-text {
    color: #212529;
    font-size: 0.9rem;
    line-height: 1.4;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem 2rem;
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    color: #212529;
    font-size: 0.95rem;
    line-height: 1.4;
}

.detail-value a {
    color: #698EE9;
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

.status-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fiwi-link {
    color: #698EE9;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.fiwi-link:hover {
    text-decoration: underline;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-active {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-inactive {
    background: #e3e3e3;
    color: #495057;
    border: 1px solid #b0b0b0;
}

/* Stats Cards */
.members-stats {
    margin-top: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #698EE9;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

/* Filter Animations */
.member-tile.filtered-out {
    opacity: 0;
    transform: scale(0.95);
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.member-tile.filtered-in {
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s ease;
}

/* No Results Message */
.no-results {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.no-results p {
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .members-title {
        font-size: 2.5rem;
    }
    
    .members-subtitle {
        font-size: 1.1rem;
    }
    
    .filters-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 992px) {
    .members-section {
        padding: 60px 0;
    }
    
    .members-title {
        font-size: 2.25rem;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .status-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .filter-popup {
        min-width: 280px;
    }
    
    .filter-icon {
        width: 40px;
        height: 40px;
    }
    
    .filter-icon i {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .members-section {
        padding: 40px 0;
    }
    
    .members-title {
        font-size: 2rem;
    }
    
    .members-subtitle {
        font-size: 1rem;
    }

    .description-text {
        font-size: 0.9rem;
        text-align: left; /* Left align on mobile for better readability */
    }

    .education-text {
        font-size: 0.8rem;
    }

    .education-icon {
        font-size: 0.7rem;
    }
    
    .member-header {
        padding: 0.5rem 0.75rem;
    }
    
    .member-name {
        font-size: 1rem;
    }
    
    .member-position {
        font-size: 0.85rem;
    }
    
    .member-avatar {
        width: 35px;
        height: 35px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .sort-icon {
        width: 40px;
        height: 40px;
    }
    
    .sort-icon i {
        font-size: 1rem;
    }
    
    .clear-search-btn {
        width: 28px;
        height: 28px;
    }
    
    .clear-search-btn i {
        font-size: 0.7rem;
    }
    
    .sort-popup {
        min-width: 180px;
    }
    
    .sort-popup-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .direction-toggle {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .direction-text {
        display: none; /* Hide text on mobile, just show icon */
    }

    /* .director-tag{
        display: none;
    } */
    
    .filter-popup {
        min-width: 250px;
    }
    
    .filters-content {
        max-height: 400px;
    }
    
    .filters-section.expanded .filters-content {
        max-height: 400px;
    }

    .stat-card {
        width: 60%;
        justify-self: center;
    }
}

@media (max-width: 576px) {
    .members-controls .row {
        --bs-gutter-x: 0.75rem;
    }
    
    .members-controls .col-lg-4,
    .members-controls .col-lg-2 {
        margin-bottom: 0.5rem;
    }

    .description-text {
        font-size: 0.85rem;
    }

    .education-text {
        font-size: 0.75rem;
    }

    .education-icon {
        font-size: 0.65rem;
    }
    
    .director-tag {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
        /* display: none; */
    }

    .detail-value {
        font-size: 0.85rem;
    }
    
    .sort-popup {
        min-width: 160px;
    }
    
    .sort-option {
        padding: 0.5rem 0.75rem;
    }
    
    .sort-option-text {
        font-size: 0.85rem;
    }
    
    .filters-content {
        max-height: 400px;
    }
    
    .filters-section.expanded .filters-content {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .member-header {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }
    
    /* Top row: expand arrow, avatar, and name with director tag */
    .expand-arrow,
    .member-avatar,
    .member-name {
        order: 1;
    }
    
    /* Bottom row: position spans full width but with left margin to align with name */
    .member-position {
        order: 2;
        /* margin-left: calc(15px + 0.75rem + 32px + 0.5rem);  */
        margin-top: 0.5rem;
        white-space: normal;
        color: #6c757d;
        font-style: italic;
        font-size: 0.85rem;
        width: auto;
        text-align: left;
        flex-basis: 100%; /* Forces it to a new line */
    }
    
    /* Adjust sizes for mobile */
    .member-avatar {
        width: 32px;
        height: 32px;
        margin-right: 0.5rem;
    }
    
    .member-name {
        font-size: 1rem;
        flex-grow: 1;
    }
    
    .director-tag {
        font-size: 0.6rem;
        padding: 0.15rem 0.3rem;
    }

}