/**
 * SameAs Entity Search - Stylesheet
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-form {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.search-input-wrapper {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-input-wrapper input {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input-wrapper button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.search-input-wrapper button:hover {
    background: var(--primary-hover);
}

.search-input-wrapper button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Filter Chips */
.search-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    background: var(--surface-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background: var(--border-color);
}

.chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Results Section */
.results-section {
    margin-bottom: 3rem;
}

.results-section.hidden {
    display: none;
}

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

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.results-stats {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.results-stats .separator {
    margin: 0 0.5rem;
    color: var(--border-color);
}

/* Results Grid */
.results-grid {
    display: grid;
    gap: 1.5rem;
}

.source-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border-color);
}

.source-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.source-header .badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
}

.source-results {
    padding: 0.5rem;
}

.result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.result-item:hover {
    background: var(--surface-hover);
}

.result-name {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.result-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
}

.result-type {
    padding: 0.125rem 0.5rem;
    background: var(--surface-hover);
    border-radius: 4px;
    color: var(--text-secondary);
}

.result-url {
    color: var(--success-color);
    font-family: monospace;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Copy Button */
.copy-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--surface-hover);
}

.copy-btn.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-state.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Manual Section */
.manual-section {
    margin-bottom: 2rem;
}

.manual-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

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

.manual-category {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.manual-category h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.manual-links {
    list-style: none;
}

.manual-links li {
    margin-bottom: 0.5rem;
}

.manual-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.manual-link:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

.link-icon {
    font-size: 1.25rem;
}

.link-name {
    font-size: 0.9375rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-links {
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-links .separator {
    margin: 0 0.75rem;
    color: var(--border-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .search-input-wrapper {
        flex-direction: column;
    }

    .search-input-wrapper button {
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .manual-grid {
        grid-template-columns: 1fr;
    }
}

/* Category Colors */
.source-card[data-category="knowledge"] .source-header {
    border-left: 4px solid #8b5cf6;
}

.source-card[data-category="people"] .source-header {
    border-left: 4px solid #06b6d4;
}

.source-card[data-category="places"] .source-header {
    border-left: 4px solid #10b981;
}

.source-card[data-category="companies"] .source-header {
    border-left: 4px solid #f59e0b;
}

.source-card[data-category="entertainment"] .source-header {
    border-left: 4px solid #ec4899;
}

.source-card[data-category="publications"] .source-header {
    border-left: 4px solid #6366f1;
}

.source-card[data-category="software"] .source-header {
    border-left: 4px solid #84cc16;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    background: var(--text-primary);
    color: white;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(1rem);
    transition: var(--transition);
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Search Progress */
.search-progress {
    margin-top: 1rem;
}

.progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: center;
}

/* ============================================
   Results Tabs
   ============================================ */

.results-tabs-container {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.results-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: var(--surface-hover);
    border-bottom: 2px solid var(--border-color);
    padding: 0.5rem 0.5rem 0;
}

.results-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    margin-bottom: -2px;
}

.results-tab:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

.results-tab.active {
    color: var(--primary-color);
    background: var(--surface);
    border-bottom-color: var(--primary-color);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.results-tab .tab-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    background: var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.results-tab.active .tab-count {
    background: var(--primary-color);
    color: white;
}

/* Tab Category Colors */
.results-tab[data-category="knowledge"] { border-left: 3px solid #8b5cf6; }
.results-tab[data-category="people"] { border-left: 3px solid #06b6d4; }
.results-tab[data-category="places"] { border-left: 3px solid #10b981; }
.results-tab[data-category="companies"] { border-left: 3px solid #f59e0b; }
.results-tab[data-category="entertainment"] { border-left: 3px solid #ec4899; }
.results-tab[data-category="publications"] { border-left: 3px solid #6366f1; }
.results-tab[data-category="software"] { border-left: 3px solid #84cc16; }

.results-tab-content {
    display: none;
    padding: 0;
}

.results-tab-content.active {
    display: block;
}

/* ============================================
   Category Sections & Tables
   ============================================ */

.category-section {
    background: var(--surface);
    overflow: hidden;
}

.category-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--surface-hover) 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border-color);
}

.category-count {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Category Colors */
.category-section[data-category="knowledge"] .category-title {
    border-left: 4px solid #8b5cf6;
}
.category-section[data-category="people"] .category-title {
    border-left: 4px solid #06b6d4;
}
.category-section[data-category="places"] .category-title {
    border-left: 4px solid #10b981;
}
.category-section[data-category="companies"] .category-title {
    border-left: 4px solid #f59e0b;
}
.category-section[data-category="entertainment"] .category-title {
    border-left: 4px solid #ec4899;
}
.category-section[data-category="publications"] .category-title {
    border-left: 4px solid #6366f1;
}
.category-section[data-category="software"] .category-title {
    border-left: 4px solid #84cc16;
}

/* Table Wrapper for horizontal scroll on mobile */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.results-table thead {
    background: var(--surface-hover);
    border-bottom: 2px solid var(--border-color);
}

.results-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.results-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.results-table tbody tr:hover {
    background: var(--surface-hover);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

/* Column Widths */
.col-source {
    width: 140px;
    min-width: 120px;
}

.col-name {
    width: 25%;
    min-width: 180px;
}

.col-description {
    width: 30%;
    min-width: 200px;
}

.col-sameas {
    width: 35%;
    min-width: 250px;
}

.col-action {
    width: 80px;
    min-width: 70px;
    text-align: center;
}

/* Source Badge */
.source-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    white-space: nowrap;
}

/* Result Link */
.result-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
}

.result-link:hover {
    text-decoration: underline;
}

/* sameAs Code */
.sameas-code {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    color: var(--success-color);
    word-break: break-all;
    max-width: 100%;
}

/* Responsive Table */
@media (max-width: 900px) {
    .results-table {
        font-size: 0.8125rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.625rem 0.75rem;
    }

    .col-description {
        display: none;
    }

    .results-tabs {
        padding: 0.375rem 0.375rem 0;
    }

    .results-tab {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 600px) {
    .results-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
    }

    .results-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    .results-tab .tab-count {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
    }

    .category-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem;
    }

    .col-source {
        width: auto;
        min-width: 90px;
    }

    .source-badge {
        font-size: 0.6875rem;
        padding: 0.2rem 0.4rem;
    }

    .sameas-code {
        font-size: 0.6875rem;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
