/* ========================================
   KNOWLEDGE PLATFORM STYLES
   Styles for the enhanced knowledge platform
   ======================================== */

/* ---------- Symptom Explorer ---------- */

.symptom-explorer {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin: 2rem 0;
}

.symptom-explorer-header {
    margin-bottom: 1.5rem;
}

.symptom-explorer-header h2 {
    font-size: 1.8rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.symptom-explorer-header p {
    color: var(--text);
}

.symptom-search-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.symptom-search-wrapper input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.symptom-search-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
}

.symptom-search-wrapper svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
}

.symptom-categories {
    margin-bottom: 1.5rem;
}

.symptom-category {
    margin-bottom: 1.5rem;
}

.symptom-category h4 {
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-100);
}

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

.symptom-checkbox {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.symptom-checkbox:hover {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.symptom-checkbox input {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.symptom-checkbox input:checked ~ .symptom-name {
    color: var(--primary);
    font-weight: 500;
}

.symptom-checkbox input:checked ~ .symptom-count {
    background: var(--primary);
    color: white;
}

.symptom-name {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text);
}

.symptom-count {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--gray-200);
    border-radius: 50px;
    color: var(--text);
    font-weight: 500;
}

.symptom-results {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--gray-100);
}

.symptom-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.symptom-results-header h3 {
    font-size: 1.3rem;
    color: var(--dark);
}

.selected-count {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
}

.results-placeholder {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.results-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.condition-result-card {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
}

.condition-result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.result-header h4 {
    font-size: 1.1rem;
    color: var(--dark);
    margin: 0;
}

.match-score {
    position: relative;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    background: rgba(67, 97, 238, 0.1);
    border-radius: 50px;
}

.match-score::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--score-percent, 0%);
    background: rgba(67, 97, 238, 0.2);
    border-radius: 50px;
    transition: width 0.5s ease;
}

.result-description {
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.matched-symptoms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.symptom-tag {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    background: var(--primary-light);
    color: white;
    border-radius: 50px;
}

/* ---------- Condition Connections ---------- */

.condition-connections {
    margin: 2rem 0;
    padding: 2rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.connections-map {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.connection-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.condition-node {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow);
    text-align: center;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.condition-node.current {
    background: var(--primary);
    color: white;
    width: 120px;
    height: 120px;
}

.condition-node.related {
    position: absolute;
    width: 80px;
    height: 80px;
    font-size: 0.85rem;
}

.condition-node.related:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

/* Orbit positioning */
.connection-orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
}

.connection-orbit .condition-node {
    --orbit-radius: 180px;
    top: calc(50% - 40px);
    left: calc(50% - 40px);
    transform: 
        rotate(var(--orbit-angle))
        translateX(var(--orbit-radius))
        rotate(calc(var(--orbit-angle) * -1));
}

.condition-node.related[data-overlap="true"] {
    border: 3px solid var(--accent);
}

.overlap-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid white;
}

.node-label {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.5rem;
}

.condition-node.current .node-label {
    font-size: 0.9rem;
}

.connections-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
}

.legend-item .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.current { background: var(--primary); }
.dot.overlap { border: 3px solid var(--accent); background: white; }
.dot.related { background: var(--gray-300); }

/* Related conditions list view */
.related-conditions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.related-condition-card {
    display: block;
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.related-condition-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.related-condition-card.overlap {
    border-left: 4px solid var(--accent);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.card-header h4 {
    font-size: 1.1rem;
    color: var(--dark);
    margin: 0;
}

.overlap-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    color: white;
    border-radius: 50px;
    font-weight: 600;
}

.card-symptoms {
    margin: 1rem 0;
}

.symptom-preview {
    font-size: 0.85rem;
    color: var(--text);
}

.card-link {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 500;
}

/* ---------- Global Search ---------- */

.global-search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.global-search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s;
}

.global-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.global-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
}

.global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.global-search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    transition: background 0.2s;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--gray-50);
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-icon {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.result-content {
    flex: 1;
}

.result-title {
    display: block;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.result-title mark {
    background: rgba(67, 97, 238, 0.2);
    color: var(--primary);
    padding: 0 2px;
    border-radius: 2px;
}

.result-description {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.search-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

.search-no-results svg {
    margin-bottom: 0.5rem;
}

/* ---------- Evidence Labels ---------- */

.evidence-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

.evidence-label.established {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
}

.evidence-label.emerging {
    background: rgba(255, 152, 0, 0.1);
    color: #ef6c00;
}

.evidence-label.uncertain {
    background: rgba(158, 158, 158, 0.1);
    color: #616161;
}

.research-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.research-status-badge.established {
    background: #e8f5e9;
    color: #2e7d32;
}

.research-status-badge.emerging {
    background: #fff3e0;
    color: #ef6c00;
}

.research-status-badge.uncertain,
.research-status-badge.limited {
    background: #f5f5f5;
    color: #616161;
}

/* ---------- Research Cards ---------- */

.research-evidence {
    margin: 2rem 0;
}

.research-evidence h3 {
    font-size: 1.4rem;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

.evidence-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid;
}

.evidence-card.established {
    border-left-color: #4caf50;
}

.evidence-card.emerging {
    border-left-color: #ff9800;
}

.evidence-card.uncertain {
    border-left-color: #9e9e9e;
}

.evidence-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.evidence-card-header h4 {
    font-size: 1.1rem;
    color: var(--dark);
    margin: 0;
    flex: 1;
}

.evidence-card p {
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.evidence-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.evidence-meta {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ---------- Community Insights ---------- */

.community-insights-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 2rem 0;
}

.community-insights-section h3 {
    font-size: 1.4rem;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

.insights-summary {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.insights-summary p {
    font-size: 1.05rem;
    color: var(--text);
    line-height: 1.6;
}

.reddit-discussions {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.reddit-discussions h4 {
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 1rem;
}

.discussion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    transition: background 0.2s;
}

.discussion-item:last-child {
    border-bottom: none;
}

.discussion-item:hover {
    background: var(--gray-50);
}

.discussion-icon {
    color: #ff4500;
    flex-shrink: 0;
}

.discussion-content {
    flex: 1;
}

.discussion-title {
    display: block;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.discussion-meta {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.insight-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.insight-theme-tag {
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    color: white;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ---------- Products Reference ---------- */

.products-reference {
    padding: 2rem 0;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: all 0.3s;
}

.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.product-card-header h4 {
    font-size: 1.1rem;
    color: var(--dark);
    margin: 0;
}

.product-type-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--gray-100);
    color: var(--text);
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-description {
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.product-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.condition-tag {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    background: var(--gray-100);
    color: var(--text);
    border-radius: 50px;
}

.product-evidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rating-stars {
    color: #ffc107;
}

.rating-value {
    font-weight: 600;
    color: var(--dark);
}

.product-disclaimer {
    font-size: 0.75rem;
    color: var(--gray-500);
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 8px;
    margin-top: 1rem;
}

/* ---------- Filter and Sort ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.filter-group select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .symptom-explorer {
        padding: 1.5rem;
    }
    
    .symptom-grid {
        grid-template-columns: 1fr;
    }
    
    .connections-map {
        aspect-ratio: auto;
        height: auto;
        min-height: 300px;
    }
    
    .connection-orbit .condition-node {
        --orbit-radius: 120px;
    }
    
    .condition-node {
        width: 70px;
        height: 70px;
    }
    
    .condition-node.current {
        width: 90px;
        height: 90px;
    }
    
    .node-label {
        font-size: 0.65rem;
    }
    
    .connections-legend {
        flex-direction: column;
        align-items: center;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        justify-content: space-between;
    }
}

/* ---------- Animation Utilities ---------- */

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

.animate-fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* ---------- Loading States ---------- */

.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.loading-skeleton-title {
    height: 1.5rem;
    margin-bottom: 1rem;
    width: 60%;
}

.loading-skeleton-card {
    height: 150px;
    margin-bottom: 1rem;
}

.suggest-condition-cta {
    margin: 1.75rem 0 2rem;
    padding: 1.5rem 1.75rem;
    border: 1px solid #d9e0ea;
    border-radius: 16px;
    background: #f7f9fc;
    text-align: center;
}

.suggest-condition-cta h2 {
    margin-bottom: 0.5rem;
}

.suggest-condition-cta p {
    max-width: 40rem;
    margin: 0 auto 1rem;
}

.condition-card.listed-without-guide-card .research-status-badge {
    display: inline-block;
    margin: 0.75rem 0;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: #eef3ff;
    color: #2f4ad0;
    font-size: 0.8rem;
    font-weight: 600;
}