/**
 * Founder Filters Styles
 * Mobile-first, collapsible filter system
 */

/* Base Filter Container - Mobile First */
.founder-filters {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    overflow: visible;
    transition: all 0.3s ease;
    z-index: 100;
    position: relative;
    max-width: 100%;
}

/* Filter Toggle Button - Compact Mobile Design */
.filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
    user-select: none;
    min-height: 48px;
}

.filter-toggle:hover {
    background: #e9ecef;
}

.filter-toggle:active {
    transform: translateY(1px);
}

.filter-icon {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    background-image: url('../images/filter-list.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: inline-block;
}

.filter-text {
    flex: 1;
    text-align: left;
}

.filter-count {
    background: var(--yc-orange);
    color: white;
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.3rem;
    display: none;
}

.toggle-arrow {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
    margin-left: 0.5rem;
}

/* Filter Content - Mobile Optimized */
.filter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
    border-top: 1px solid #e9ecef;
}

.filter-content.open {
    max-height: 400px;
    overflow-y: auto;
}

/* Filter Header - Hidden */
.filter-header {
    display: none;
}

/* Filter Sections - Compact */
.filter-sections {
    padding: 1rem;
}

.filter-section {
    margin-bottom: 1rem;
}

.filter-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-options {
    display: grid;
    gap: 0.3rem;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 4px;
}

/* Batch Inline Filters - Mobile Optimized */
.batch-inline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.batch-filter-pill {
    display: inline-flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    user-select: none;
    min-height: 32px;
}

.batch-filter-pill:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.batch-filter-pill input[type="checkbox"] {
    display: none;
}

.batch-filter-pill.selected,
.batch-filter-pill input[type="checkbox"]:checked + .pill-content {
    background: var(--yc-orange) !important;
    color: white;
}

.batch-filter-pill.selected .pill-content,
.batch-filter-pill input[type="checkbox"]:checked + .pill-content {
    background: var(--yc-orange);
    color: white;
}

.batch-filter-pill.selected .batch-count,
.batch-filter-pill input[type="checkbox"]:checked + .pill-content .batch-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.pill-content {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    border-radius: 14px;
    padding: 0.2rem 0.5rem;
}

.batch-name {
    font-weight: 600;
}

.batch-count {
    background: #6c757d;
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    line-height: 1;
}

/* Search Filter Wrapper */
.search-filter-wrapper {
    position: relative;
}

.search-filter-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.85rem;
    background-color: #fff;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    min-height: 40px;
}

.search-filter-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
    background-color: #fefefe;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.search-result-item {
    border-bottom: 1px solid #f5f5f5;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.search-result-item:hover {
    background: #f8f9fa;
    border-left: 3px solid var(--yc-orange);
    padding-left: calc(0.8rem - 3px);
}

.search-result-item.selected-temp {
    background: #e3f2fd;
    transform: scale(0.98);
}

.search-result-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.search-result-text {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
}

.search-result-count {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

/* Filter Option */
.filter-option {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
    border: 1px solid transparent;
}

.filter-option:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.selected-items {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.selected-item {
    background: var(--yc-orange);
    color: #fff;
    padding: 3px 6px;
    border-radius: 12px;
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.selected-item .remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: 3px;
}

.initial-options {
    display: block;
}

.filter-option input[type="checkbox"] {
    display: none;
}

/* Custom Checkbox */
.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    margin-right: 0.5rem;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.filter-option input[type="checkbox"]:checked + .checkmark {
    background: var(--yc-orange);
    border-color: var(--yc-orange);
}

.filter-option input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 11px;
    font-weight: bold;
}

.option-text {
    flex: 1;
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
}

.option-count {
    font-size: 0.8rem;
    color: #6c757d;
    margin-left: 0.5rem;
}

/* Filter Actions */
.filter-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    gap: 0.75rem;
}

.apply-filters {
    flex: 0 0 75%;
    background: var(--yc-orange);
    color: white;
    border: none;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
    position: relative;
    overflow: hidden;
    min-height: 48px;
}

.clear-filters {
    flex: 0 0 20%;
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.8rem 0.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    white-space: nowrap;
}

.clear-filters:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.clear-filters:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.apply-filters::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.apply-filters:hover::before {
    left: 100%;
}

.apply-filters:hover {
    background: #e85d00;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 102, 0, 0.4);
}

.apply-filters:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 102, 0, 0.3);
}

.apply-filters:disabled {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.apply-filters:disabled::before {
    display: none;
}

/* Results Info */
.filter-results-info {
    background: #fff5f0;
    border: 1px solid #ffd0b3;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 120px; /* 60px imagen sobresaliente + 8px hover transform + espacio adicional */
    font-size: 0.9rem;
    color: var(--yc-orange);
    font-weight: 500;
}

/* Loading States */
.posts-grid.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.filter-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top: 3px solid var(--yc-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

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

/* Mobile Styles */
@media (max-width: 768px) {
    .founder-filters {
        position: relative;
        margin-bottom: 120px; /* Mantener el mismo espaciado que en desktop */
        border-radius: 8px;
    }
    
    .filter-toggle {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        min-height: 44px;
    }
    
    .filter-content {
        position: static;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    .filter-content.open {
        max-height: 350px;
        border-top: 1px solid #e9ecef;
    }
    
    /* Improve touch targets on mobile */
    .filter-toggle {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .batch-inline-filters {
        gap: 0.4rem;
    }
    
    .batch-filter-pill {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .batch-filter-pill .pill-content {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
        min-height: 28px;
    }
    
    .batch-count {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
        min-width: 16px;
    }
    
    .filter-sections {
        padding: 0.8rem;
    }
    
    .filter-header {
        padding: 0.8rem;
    }
    
    .filter-header h3 {
        font-size: 0.85rem;
    }
    
    .clear-filters {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .search-filter-input {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
        min-height: 36px;
        z-index: 1000;
    }
    
    .search-results {
        max-height: 120px;
    }
    
    .search-result-item {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .apply-filters {
        padding: 0.7rem 0.8rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    .filter-content.open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 100vh;
        z-index: 1001;
        background: white;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-content.open .filter-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 1002;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
    }
    
    .filter-content.open .filter-header h3 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 600;
        color: #333;
    }
    
    .mobile-close-btn {
        display: none;
        background: #6c757d;
        border: none;
        color: white;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 1.2rem;
        line-height: 1;
        transition: all 0.2s ease;
    }
    
    .mobile-close-btn:hover {
        background: #5a6268;
        transform: scale(1.1);
    }
    
    .filter-content.open .mobile-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Prevent body scroll when filter is open on mobile */
    body.filters-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    .filter-content.open .filter-actions {
        position: sticky;
        bottom: 0;
        background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        border-top: 2px solid #e9ecef;
    }
    
    .apply-filters {
        padding: 1.2rem 1.5rem;
        font-size: 1.1rem;
        border-radius: 16px;
    }
    
    /* Body overlay removed to fix click issues on mobile */
    
    .filter-options {
        gap: 0.4rem;
    }
    
    .filter-option {
        padding: 0.7rem 0.8rem;
    }
    
    .option-text {
        font-size: 0.95rem;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .filter-content.open {
        max-height: 70vh;
    }
    
    .filter-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
}

/* Desktop Styles */
@media (min-width: 1025px) {
    .founder-filters {
        margin-bottom: 120px;
    }
    
    .filter-content.open {
        max-height: 60vh;
    }
    
    .filter-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .filter-section {
        margin-bottom: 2rem;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .filter-options {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .founder-filters,
    .filter-toggle,
    .filter-content,
    .toggle-arrow,
    .filter-option,
    .checkmark,
    .apply-filters {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* Focus styles for accessibility */
.filter-toggle:focus,
.filter-option:focus,
.apply-filters:focus,
.clear-filters:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .founder-filters {
        border: 2px solid #000;
    }
    
    .filter-option {
        border: 1px solid #000;
    }
    
    .checkmark {
        border: 2px solid #000;
    }
}