/* Enhanced styles for networked knowledge base - Mind & Digital Era Theme */

/* Enhanced Figma Design System Integration */
:root {
    /* Map existing variables to Figma tokens for consistency */
    --primary-color: var(--figma-primary);
    --secondary-color: var(--figma-secondary);
    --accent-color: var(--figma-accent);
    --text-primary: var(--figma-gray-900);
    --text-secondary: var(--figma-gray-600);
    --background-primary: #ffffff;
    --background-secondary: var(--figma-gray-50);
    --background-accent: var(--figma-gray-100);
    --border-color: var(--figma-gray-200);
    --shadow-light: var(--figma-shadow-sm);
    --shadow-medium: var(--figma-shadow-md);
    --shadow-large: var(--figma-shadow-lg);
    --gradient-primary: linear-gradient(135deg, var(--figma-primary), var(--figma-secondary));
    --gradient-accent: linear-gradient(135deg, var(--figma-accent), var(--figma-primary));
    
    /* Additional Figma-inspired enhancements */
    --transition-fast: var(--figma-transition-fast);
    --transition-normal: var(--figma-transition-normal);
    --border-radius-sm: var(--figma-radius-sm);
    --border-radius-md: var(--figma-radius-md);
    --border-radius-lg: var(--figma-radius-lg);
}

/* Figma Design System Typography */
body {
    font-family: var(--figma-font-primary);
    font-size: var(--figma-text-base);
    line-height: 1.6;
    color: var(--text-primary);
    font-weight: var(--figma-font-normal);
}

h1 {
    font-size: var(--figma-text-4xl);
    font-weight: var(--figma-font-bold);
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: var(--figma-space-6);
}

h2 {
    font-size: var(--figma-text-3xl);
    font-weight: var(--figma-font-semibold);
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: var(--figma-space-5);
}

h3 {
    font-size: var(--figma-text-2xl);
    font-weight: var(--figma-font-semibold);
    line-height: 1.4;
    color: var(--figma-gray-800);
    margin-bottom: var(--figma-space-4);
}

h4, h5, h6 {
    font-size: var(--figma-text-xl);
    font-weight: var(--figma-font-medium);
    line-height: 1.4;
    color: var(--figma-gray-800);
    margin-bottom: var(--figma-space-3);
}

/* Figma Design System Header */
.figma-header {
    background: var(--gradient-primary);
    color: white;
    padding: var(--figma-space-4) 0;
    box-shadow: var(--figma-shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.figma-nav-brand {
    font-size: var(--figma-text-xl);
    font-weight: var(--figma-font-bold);
    text-decoration: none;
    color: white;
    transition: all var(--figma-transition-normal);
}

.figma-nav-brand:hover {
    transform: translateY(-1px);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Figma Design System Navigation */
.figma-nav {
    display: flex;
    gap: var(--figma-space-6);
    align-items: center;
    justify-content: space-between;
}

.figma-nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--figma-space-6);
}

.figma-nav-link {
    color: white;
    text-decoration: none;
    font-weight: var(--figma-font-medium);
    font-size: var(--figma-text-sm);
    padding: var(--figma-space-2) var(--figma-space-4);
    border-radius: var(--figma-radius-md);
    transition: all var(--figma-transition-normal);
    position: relative;
}

.figma-nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.figma-nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--figma-accent);
    transition: all var(--figma-transition-normal);
    transform: translateX(-50%);
}

.figma-nav-link:hover::after {
    width: 80%;
}

/* Figma Design System Cards */
.card {
    background: var(--background-primary);
    border-radius: var(--figma-radius-lg);
    padding: var(--figma-space-6);
    box-shadow: var(--figma-shadow-sm);
    border: 1px solid var(--figma-gray-200);
    transition: all var(--figma-transition-normal);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--figma-shadow-md);
    transform: translateY(-2px);
    border-color: var(--figma-gray-300);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

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

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

/* Modern button styling */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-light);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-secondary {
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background-accent);
    border-color: var(--primary-color);
}

/* Enhanced search styling */

/* Enhanced search styling */
.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-large);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.search-result {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    margin: 0.25rem;
}

.search-result:hover {
    background: var(--background-accent);
    transform: translateX(4px);
}

.search-result h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.search-result .snippet {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.search-result .meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-result .tag {
    background: var(--gradient-accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.search-result .date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.no-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Enhanced internal links */
.internal-link {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 2px dotted var(--primary-color);
    transition: all 0.3s ease;
    position: relative;
}

.internal-link:hover {
    color: var(--secondary-color);
    border-bottom-style: solid;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transform: translateY(-1px);
}

.broken-link {
    color: #ef4444;
    text-decoration: line-through;
    opacity: 0.7;
}

/* Enhanced knowledge graph */
.knowledge-graph {
    margin: 2rem 0;
    padding: 2rem;
    background: var(--background-secondary);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.knowledge-graph::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.knowledge-graph h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

#graph-container {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--background-primary);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Mind & Digital Era Theme Enhancements */
.mind-digital-theme {
    position: relative;
}

.mind-digital-theme::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    border-radius: 1rem;
    z-index: -1;
    opacity: 0.1;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.2; }
}

/* Cognitive-inspired floating elements */
.cognitive-float {
    position: relative;
    overflow: hidden;
}

.cognitive-float::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.3; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.1; }
}

/* Digital connectivity indicators */
.digital-connection {
    position: relative;
}

.digital-connection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-accent);
    transform: scaleX(0);
    animation: connect 2s ease-in-out infinite;
}

@keyframes connect {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

/* Enhanced content cards with neural network inspiration */
.neural-card {
    background: var(--background-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.neural-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.neural-card:hover::before {
    opacity: 1;
}

.neural-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-large);
    border-color: var(--primary-color);
}

/* MOC (Map of Content) styles */
.moc-container {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.moc-container h3 {
    margin-top: 0;
    color: #495057;
}

.moc-section {
    margin-bottom: 25px;
}

.moc-section h4 {
    color: #6c757d;
    font-size: 18px;
    margin-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
}

.moc-section h5 {
    color: #495057;
    font-size: 16px;
    margin-bottom: 10px;
}

.tag-group, .concept-group {
    margin-bottom: 20px;
}

.tag-group ul, .concept-group ul {
    list-style: none;
    padding-left: 0;
}

.tag-group li, .concept-group li {
    margin-bottom: 5px;
}

.tag-group a, .concept-group a {
    color: #007bff;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    background: white;
    border: 1px solid #e9ecef;
    display: inline-block;
    transition: all 0.2s ease;
}

.tag-group a:hover, .concept-group a:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Backlinks and related articles */
.backlinks, .related {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.backlinks h3, .related h3 {
    margin-top: 0;
    color: #495057;
}

.backlinks ul, .related ul {
    list-style: none;
    padding-left: 0;
}

.backlinks li, .related li {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.backlinks li:hover, .related li:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.backlinks a, .related a {
    color: #007bff;
    text-decoration: none;
}

.backlinks a:hover, .related a:hover {
    text-decoration: underline;
}

/* Post navigation */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin: 40px 0;
    padding: 20px 0;
    border-top: 1px solid #e9ecef;
}

.post-nav .prev, .post-nav .next {
    flex: 1;
}

.post-nav .next {
    text-align: right;
}

.post-nav a {
    color: #007bff;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.post-nav a:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Tags */
.tags {
    margin: 15px 0;
}

.tag {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 3px;
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag:hover {
    background: #007bff;
    color: white;
}

/* Table of Contents */
.toc {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.toc h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
}

.toc ul {
    margin: 0;
    padding-left: 20px;
}

.toc li {
    margin-bottom: 5px;
}

.toc a {
    color: #007bff;
    text-decoration: none;
}

.toc a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .search-input {
        max-width: 100%;
    }
    
    .knowledge-graph {
        padding: 15px;
    }
    
    #graph-container {
        height: 300px;
    }
    
    .post-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .post-nav .next {
        text-align: left;
    }
    
    .moc-container, .backlinks, .related {
        padding: 15px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-results {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .search-result {
        border-bottom-color: #4a5568;
    }
    
    .search-result:hover {
        background-color: #4a5568;
    }
    
    .search-result h4 {
        color: #e2e8f0;
    }
    
    .search-result .snippet {
        color: #a0aec0;
    }
    
    .search-result .tag {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .search-result .date {
        color: #a0aec0;
    }
    
    .knowledge-graph {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .moc-container, .backlinks, .related {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .tag-group a, .concept-group a {
        background: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .backlinks li, .related li {
        background: #4a5568;
        border-color: #4a5568;
    }
}

/* Figma Design System Search Interface */
.search-container {
    margin: var(--figma-space-4) 0;
    position: relative;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--figma-radius-lg);
    padding: var(--figma-space-4);
    backdrop-filter: blur(10px);
}

.search-box {
    max-width: 600px;
    margin: 0;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    font-size: 1.1rem;
    background: var(--background-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.search-icon {
    position: absolute;
    right: 3rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.search-clear:hover {
    background: var(--background-accent);
    color: var(--text-primary);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 1rem 1rem;
    box-shadow: var(--shadow-medium);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.suggestion-item:hover {
    background: var(--background-accent);
}

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

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: 0 0 1rem 1rem;
    box-shadow: var(--shadow-large);
    z-index: 1000;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.results-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.search-filters {
    display: flex;
    gap: 1.5rem;
}

.search-filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.search-filters input[type="checkbox"] {
    accent-color: var(--primary-color);
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-result-item {
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.search-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
}

.search-result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
    border-color: var(--primary-color);
}

.result-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.result-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.result-title a:hover {
    color: var(--primary-color);
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.result-date {
    font-weight: 500;
}

.result-tags, .result-topics {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag, .topic {
    background: var(--background-accent);
    color: var(--text-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.topic {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.result-excerpt {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.result-score {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.no-results h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.search-tips ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.search-tips li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.search-tips li:last-child {
    border-bottom: none;
}

.search-error {
    text-align: center;
    padding: 2rem;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
}

/* Highlighted search terms */
mark {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text-primary);
    padding: 0.1rem 0.2rem;
    border-radius: 0.25rem;
    font-weight: 600;
}

/* Responsive design for search */
@media (max-width: 768px) {
    .search-container {
        padding: 1rem;
    }
    
    .search-results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .search-filters {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .result-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}
