/**
 * Members Directory - Premium UI/UX Styles
 * Colors: #169d53 (Primary Green), #000 (Black), #fff (White)
 */

/* ========================================
   RESET & BASE STYLES
   ======================================== */

.md-directory-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.md-directory-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
}

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

.md-filters-bar {
    background: #fff;
    border: 2px solid #f0f0f0;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.md-filters-bar:hover {
    box-shadow: 0 4px 20px rgba(22, 157, 83, 0.1);
    border-color: #169d53;
}

/* Search Box */
.md-search-box {
    position: relative;
    margin-bottom: 20px;
}

.md-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
    transition: color 0.3s ease;
}

.md-search-input {
    width: 100% !important;
    padding: 16px 50px 16px 48px !important;
    border: 2px solid #e5e5e5 !important;
    border-radius: 12px !important;
    font-size: 16px !important;
    color: #000 !important;
    background: #fafafa !important;
    transition: all 0.3s ease !important;
    outline: none !important;
}

.md-search-input:focus {
    border-color: #169d53;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(22, 157, 83, 0.1);
}

.md-search-input:focus + .md-search-icon {
    color: #169d53;
}

.md-clear-search {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: #999;
}

.md-clear-search:hover {
    background: #f5f5f5;
    color: #000;
}

.md-clear-search svg {
    display: block;
}

/* Role Filters */
.md-role-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.md-filter-btn {
    padding: 12px 24px;
    border: 2px solid #e5e5e5;
    background: #fff;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    outline: none;
    position: relative;
    overflow: hidden;
}

.md-filter-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(22, 157, 83, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.md-filter-btn:hover::before {
    width: 200%;
    height: 200%;
}

.md-filter-btn:hover {
    border-color: #169d53;
    color: #169d53;
    transform: translateY(-2px);
}

.md-filter-btn.active {
    background: #169d53;
    border-color: #169d53;
    color: #fff;
    box-shadow: 0 4px 12px rgba(22, 157, 83, 0.3);
}

.md-filter-btn.active:hover {
    background: #128a44;
    transform: translateY(-2px);
}

/* ========================================
   LOADING OVERLAY
   ======================================== */

.md-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    border-radius: 16px;
    backdrop-filter: blur(4px);
}

.md-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top-color: #169d53;
    border-radius: 50%;
    animation: md-spin 0.8s linear infinite;
}

@keyframes md-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   RESULTS INFO
   ======================================== */

.md-results-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 24px;
    padding: 0 4px;
    font-size: 15px;
    color: #666;
}

.md-count {
    font-size: 24px;
    font-weight: 700;
    color: #169d53;
}

.md-count-label {
    font-weight: 500;
}

/* ========================================
   MEMBERS GRID
   ======================================== */

.md-members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    animation: md-fade-in 0.5s ease;
}

@keyframes md-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid columns based on attribute */
.md-directory-wrapper[data-columns="2"] .md-members-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

.md-directory-wrapper[data-columns="4"] .md-members-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

/* ========================================
   MEMBER CARD
   ======================================== */

.md-member-card {
    background: #fff;
    border: 2px solid #f0f0f0;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: md-card-appear 0.5s ease backwards;
    position: relative;
}

@keyframes md-card-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.md-member-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #169d53, #128a44);
    transform: scaleX(0);
    transition: transform 0.4s ease;
}

.md-member-card:hover::before {
    transform: scaleX(1);
}

.md-member-card:hover {
    border-color: #169d53;
    box-shadow: 0 12px 32px rgba(22, 157, 83, 0.15);
    transform: translateY(-8px);
}

/* Card delay animation */
.md-member-card:nth-child(1) { animation-delay: 0.05s; }
.md-member-card:nth-child(2) { animation-delay: 0.1s; }
.md-member-card:nth-child(3) { animation-delay: 0.15s; }
.md-member-card:nth-child(4) { animation-delay: 0.2s; }
.md-member-card:nth-child(5) { animation-delay: 0.25s; }
.md-member-card:nth-child(6) { animation-delay: 0.3s; }

/* ========================================
   CARD HEADER (Avatar)
   ======================================== */

.md-card-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: center;
}

.md-avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
}

.md-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #f5f5f5;
    transition: all 0.3s ease;
}

.md-member-card:hover .md-avatar {
    border-color: #169d53;
    box-shadow: 0 8px 24px rgba(22, 157, 83, 0.2);
}

.md-status-dot {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #169d53;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(22, 157, 83, 0.4);
    animation: md-pulse 2s ease infinite;
}

@keyframes md-pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(22, 157, 83, 0.4);
    }
    50% {
        box-shadow: 0 2px 8px rgba(22, 157, 83, 0.4), 0 0 0 6px rgba(22, 157, 83, 0.2);
    }
}

/* ========================================
   CARD BODY (Info)
   ======================================== */

.md-card-body {
    padding: 20px 24px;
    text-align: center;
}

.md-member-name {
    font-size: 20px;
    font-weight: 700;
    color: #000;
    margin-bottom: 12px;
    line-height: 1.3;
}

.md-role-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.md-badge-student {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.md-badge-collaborator {
    background: rgba(241, 196, 15, 0.1);
    color: #f1c40f;
}

.md-badge-effective {
    background: rgba(22, 157, 83, 0.1);
    color: #169d53;
}

.md-badge-default {
    background: rgba(149, 165, 166, 0.1);
    color: #95a5a6;
}

.md-member-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

.md-member-info svg {
    flex-shrink: 0;
    color: #999;
}

.md-member-info:last-child {
    margin-bottom: 0;
}

/* ========================================
   CARD FOOTER (Actions)
   ======================================== */

.md-card-footer {
    padding: 0 24px 24px;
    display: flex;
    gap: 10px;
}

.md-contact-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.md-contact-btn svg {
    flex-shrink: 0;
}

.md-contact-btn span {
    display: none;
}

.md-email-btn:hover {
    background: #000;
    border-color: #000;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.md-whatsapp-btn:hover {
    background: #25d366;
    border-color: #25d366;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

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

.md-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #999;
}

.md-no-results svg {
    margin-bottom: 20px;
    opacity: 0.3;
}

.md-no-results p {
    font-size: 20px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.md-no-results small {
    font-size: 14px;
    color: #999;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */

@media (max-width: 1024px) {
    .md-members-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .md-directory-wrapper[data-columns="2"] .md-members-grid,
    .md-directory-wrapper[data-columns="4"] .md-members-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .md-directory-wrapper {
        padding: 24px 16px;
    }
    
    .md-filters-bar {
        padding: 20px;
        border-radius: 12px;
        margin-bottom: 24px;
    }
    
    .md-search-box {
        margin-bottom: 16px;
    }
    
    .md-search-input {
        padding: 14px 45px 14px 45px;
        font-size: 15px;
    }
    
    .md-role-filters {
        gap: 10px;
    }
    
    .md-filter-btn {
        padding: 10px 18px;
        font-size: 14px;
        flex: 1;
        min-width: calc(50% - 5px);
        text-align: center;
    }
    
    .md-results-info {
        margin-bottom: 20px;
    }
    
    .md-count {
        font-size: 20px;
    }
    
    .md-count-label {
        font-size: 14px;
    }
    
    .md-members-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .md-member-card {
        border-radius: 12px;
    }
    
    .md-card-header {
        padding: 20px 20px 0;
    }
    
    .md-avatar-wrapper {
        width: 100px;
        height: 100px;
    }
    
    .md-status-dot {
        width: 18px;
        height: 18px;
        bottom: 6px;
        right: 6px;
    }
    
    .md-card-body {
        padding: 16px 20px;
    }
    
    .md-member-name {
        font-size: 18px;
    }
    
    .md-role-badge {
        padding: 5px 14px;
        font-size: 12px;
        margin-bottom: 14px;
    }
    
    .md-member-info {
        font-size: 13px;
        margin-bottom: 8px;
    }
    
    .md-card-footer {
        padding: 0 20px 20px;
        gap: 8px;
    }
    
    .md-contact-btn {
        padding: 12px;
    }
    
    .md-contact-btn span {
        display: inline;
    }
    
    .md-no-results {
        padding: 60px 20px;
    }
    
    .md-no-results svg {
        width: 48px;
        height: 48px;
    }
    
    .md-no-results p {
        font-size: 18px;
    }
}

/* ========================================
   RESPONSIVE - SMALL MOBILE
   ======================================== */

@media (max-width: 480px) {
    .md-directory-wrapper {
        padding: 20px 12px;
    }
    
    .md-filters-bar {
        padding: 16px;
    }
    
    .md-filter-btn {
        width: 100%;
        min-width: 100%;
    }
    
    .md-member-name {
        font-size: 17px;
    }
    
    .md-contact-btn span {
        font-size: 13px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.md-filter-btn:focus,
.md-search-input:focus,
.md-contact-btn:focus,
.md-clear-search:focus {
    outline: 3px solid rgba(22, 157, 83, 0.5);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .md-filters-bar,
    .md-card-footer {
        display: none;
    }
    
    .md-member-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
