:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafbfc;
    --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --header-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --text-primary: #2c3e50;
    --text-secondary: #5a6c7d;
    --text-meta: #8b9dc3;
    --border-color: #e1e8ed;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --input-focus: #2c3e50;
    --button-bg: #e74c3c;
    --button-hover: #c0392b;
    --accent-primary: #2c3e50;
    --accent-secondary: #34495e;
}

[data-theme="dark"] {
    --bg-primary: #1a1d23;
    --bg-secondary: #242831;
    --bg-gradient: linear-gradient(135deg, #1a1d23 0%, #242831 100%);
    --header-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --text-primary: #f8f9fa;
    --text-secondary: #d1d5db;
    --text-meta: #9ca3af;
    --border-color: #374151;
    --card-bg: #242831;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
    --card-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
    --input-bg: #374151;
    --input-focus: #6b7280;
    --button-bg: #e74c3c;
    --button-hover: #c0392b;
    --accent-primary: #6b7280;
    --accent-secondary: #9ca3af;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 400;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

header {
    background: var(--header-gradient);
    color: white;
    padding: 40px 48px;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

.header-text {
    text-align: center;
    flex: 1;
}

.theme-toggle {
    display: flex;
    align-items: center;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 32px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toggle-icon {
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.toggle-switch input:checked + .slider {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
}


.search-section {
    padding: 64px 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
    max-width: 600px;
    width: 100%;
}

#searchInput {
    flex: 1;
    padding: 24px 28px;
    border: 3px solid var(--border-color);
    border-radius: 20px;
    font-size: 18px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-align: center;
}

#searchInput:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.1), 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

#searchInput::placeholder {
    color: var(--text-meta);
    font-weight: 400;
}

#clearSearch {
    padding: 24px 36px;
    background: var(--button-bg);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    min-width: 100px;
}

#clearSearch:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

.filters {
    display: flex;
    gap: 32px;
    justify-content: center;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    padding: 12px 24px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filters label:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #2c3e50;
}

.filters input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.results-section {
    padding: 48px;
    min-height: 400px;
}

.loading {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 50px;
    transition: color 0.3s ease;
}

.results-count {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-align: center;
    transition: color 0.3s ease;
}

.results {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

@media (max-width: 480px) {
    .results {
        grid-template-columns: 1fr;
    }
}

.result-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    border-color: #2c3e50;
}

.result-item:hover::before {
    opacity: 1;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.result-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 200px;
    line-height: 1.4;
}

.price-tag {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1.125rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    letter-spacing: 0.025em;
}

.price-tag.private {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.price-tag.pending {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.price-tag.tbc {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.result-details {
    color: var(--text-secondary);
    margin-bottom: 16px;
    transition: color 0.3s ease;
    font-weight: 500;
    font-size: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.result-meta {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--text-meta);
    flex-wrap: wrap;
    transition: color 0.3s ease;
}

.source-badge {
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-badge.public {
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    color: #2c3e50;
    border-color: #cbd5e0;
}

.source-badge.private {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    color: #4a5568;
    border-color: #a0aec0;
}

.generator-change-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f56500 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3);
    white-space: nowrap;
    flex-shrink: 0;
}

.new-implant-badge {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
    white-space: nowrap;
    flex-shrink: 0;
}

.hidden {
    display: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-meta);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.modal-detail-row:last-child {
    border-bottom: none;
}

.modal-detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.modal-detail-value {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: right;
    flex: 1;
    min-width: 120px;
}

.modal-price {
    font-size: 2rem;
    font-weight: 700;
    color: #10b981;
    text-align: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 16px;
    margin-bottom: 24px;
}

.modal-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .modal {
        padding: 16px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 24px 24px 20px;
    }
    
    .modal-body {
        padding: 24px;
    }
    
    .modal-detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .modal-detail-value {
        text-align: left;
        min-width: auto;
    }
}

.no-results {
    text-align: center;
    padding: 50px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    
    header {
        padding: 32px 24px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 20px;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    .search-section {
        padding: 48px 24px;
    }
    
    .search-bar {
        flex-direction: column;
        gap: 16px;
        max-width: 100%;
    }
    
    #searchInput {
        padding: 20px 24px;
        font-size: 16px;
    }
    
    #clearSearch {
        padding: 20px 28px;
    }
    
    .filters {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .filters label {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
    
    .results-section {
        padding: 32px 24px;
    }
    
    .result-item {
        padding: 24px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .result-title {
        font-size: 1.125rem;
    }
    
    .result-meta {
        flex-direction: column;
        gap: 12px;
    }
    
    .result-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .generator-change-badge,
    .new-implant-badge {
        margin: 0;
    }
}