/**
 * Search Components Styles
 * Styling for corpus search UI and universal display renderer
 */

/* Search UI Container */
.search-ui {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Search Bar */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-color, #ffffff);
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    padding: 4px;
    transition: border-color 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color, #9370DB);
    box-shadow: 0 0 0 3px rgba(147, 112, 219, 0.1);
}

.search-input {
    flex: 1;
    border: none;
    padding: 12px 16px;
    font-size: 16px;
    outline: none;
    background: transparent;
}

.search-mode-btn,
.search-submit-btn,
.clear-btn {
    padding: 8px 16px;
    border: none;
    background: var(--primary-color, #9370DB);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.search-mode-btn:hover,
.search-submit-btn:hover {
    background: var(--primary-hover, #7d5ba6);
}

.clear-btn {
    background: var(--error-color, #dc3545);
    padding: 8px 12px;
}

.clear-btn:hover {
    background: #c82333;
}

.mode-icon {
    font-size: 18px;
}

/* Search Mode Panel */
.search-mode-panel {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 8px;
    padding: 12px;
    min-width: 300px;
}

.search-mode-panel label {
    display: block;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.search-mode-panel label:hover {
    background: var(--hover-bg, #f5f5f5);
}

.search-mode-panel input[type="radio"] {
    margin-right: 8px;
}

/* Suggestions */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: var(--hover-bg, #f5f5f5);
}

.suggestion-item strong {
    color: var(--primary-color, #9370DB);
    font-weight: 600;
}

/* Filters */
.search-filters {
    margin-bottom: 20px;
}

.filter-toggle-btn {
    padding: 10px 20px;
    border: 2px solid rgba(147, 112, 219, 0.3);
    background: rgba(147, 112, 219, 0.05);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.filter-toggle-btn:hover {
    background: rgba(147, 112, 219, 0.15);
    border-color: var(--primary-color, #9370DB);
    transform: translateY(-1px);
}

.filter-toggle-btn:active {
    transform: translateY(0);
}

.filter-count {
    background: linear-gradient(135deg, var(--primary-color, #9370DB), #b8a5d6);
    color: white;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    box-shadow: 0 2px 8px rgba(147, 112, 219, 0.3);
}

.filter-panel {
    background: white;
    border: 2px solid rgba(147, 112, 219, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    animation: slideDown 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #333);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.filter-group select,
.filter-group input[type="number"] {
    padding: 10px 12px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.filter-group select:hover,
.filter-group input[type="number"]:hover {
    border-color: rgba(147, 112, 219, 0.4);
    background: rgba(147, 112, 219, 0.02);
}

.filter-group select:focus,
.filter-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color, #9370DB);
    box-shadow: 0 0 0 3px rgba(147, 112, 219, 0.1);
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.range-inputs input {
    flex: 1;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color, #9370DB), #b8a5d6);
    color: white;
    box-shadow: 0 4px 12px rgba(147, 112, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(147, 112, 219, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary-bg, #f5f5f5);
    color: var(--text-primary, #333);
    border: 2px solid var(--border-color, #e0e0e0);
}

.btn-secondary:hover {
    background: #e0e0e0;
    border-color: rgba(147, 112, 219, 0.4);
    color: var(--primary-color, #9370DB);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Results Controls */
.results-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 20px;
}

.results-info {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.display-mode-switcher {
    display: flex;
    gap: 4px;
    background: var(--secondary-bg, #f5f5f5);
    border-radius: 6px;
    padding: 4px;
}

.display-mode-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    transition: background 0.2s;
}

.display-mode-btn:hover {
    background: rgba(147, 112, 219, 0.1);
}

.display-mode-btn.active {
    background: var(--primary-color, #9370DB);
    color: white;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-controls label {
    font-size: 14px;
    font-weight: 500;
}

.sort-controls select {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    font-size: 14px;
}

/* Search Results */
.search-results {
    min-height: 400px;
}

.search-placeholder,
.no-results,
.search-loading,
.search-error {
    text-align: center;
    padding: 60px 20px;
}

.placeholder-icon,
.no-results-icon,
.error-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-placeholder p,
.no-results p {
    font-size: 18px;
    color: var(--text-secondary, #666);
    margin-bottom: 24px;
}

.no-results-hint {
    font-size: 14px !important;
    color: var(--text-tertiary, #999) !important;
}

.search-examples {
    margin-top: 24px;
}

.search-examples p {
    font-size: 14px;
    margin-bottom: 12px;
}

.example-query {
    padding: 8px 16px;
    margin: 4px;
    border: 1px solid var(--border-color, #e0e0e0);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.example-query:hover {
    background: var(--primary-color, #9370DB);
    color: white;
    border-color: var(--primary-color, #9370DB);
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid var(--border-color, #e0e0e0);
    border-top-color: var(--primary-color, #9370DB);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Universal Display Renderer Styles */

/* Grid Display - Fixed 4 columns on desktop */
.entity-grid.universal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 20px 0;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

/* Tablet: 3 columns */
@media (max-width: 1200px) {
    .entity-grid.universal-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet portrait: 2 columns */
@media (max-width: 900px) {
    .entity-grid.universal-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column */
@media (max-width: 480px) {
    .entity-grid.universal-grid {
        grid-template-columns: 1fr;
    }
}

.entity-card.grid-card {
    position: relative;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.entity-card.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary-color, #9370DB);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.card-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.card-title a {
    color: var(--text-primary, #333);
    text-decoration: none;
    transition: color 0.2s;
}

.card-title a:hover {
    color: var(--primary-color, #9370DB);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #666);
    text-align: center;
    margin-bottom: 12px;
}

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.stat-item {
    display: flex;
    justify-content: space-between;
}

.stat-label {
    color: var(--text-secondary, #666);
}

.stat-value {
    font-weight: 500;
    color: var(--text-primary, #333);
}

.hover-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.hover-quick {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-bottom: 8px;
}

.hover-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hoverable-term {
    display: inline-block;
    padding: 4px 10px;
    background: var(--secondary-bg, #f5f5f5);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-primary, #333);
    text-decoration: none;
    transition: all 0.2s;
}

.hoverable-term:hover {
    background: var(--primary-color, #9370DB);
    color: white;
}

/* Table Display */
.entity-table-container {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
}

.entity-table {
    width: 100%;
    border-collapse: collapse;
}

.entity-table thead {
    background: var(--secondary-bg, #f5f5f5);
}

.entity-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #333);
    cursor: pointer;
}

.entity-table th.sortable:hover {
    background: #e0e0e0;
}

.entity-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #e0e0e0);
    font-size: 14px;
}

.entity-table tbody tr:hover {
    background: var(--hover-bg, #f5f5f5);
}

/* List Display */
.entity-list.universal-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.entity-list-item {
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.list-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.list-item-main:hover {
    background: var(--hover-bg, #f5f5f5);
}

.list-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
}

.list-primary {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin-bottom: 4px;
}

.list-secondary {
    font-size: 14px;
    color: var(--text-secondary, #666);
    margin-bottom: 4px;
}

.list-meta {
    font-size: 12px;
    color: var(--text-tertiary, #999);
}

.expand-indicator {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    transition: transform 0.2s;
}

.entity-list-item.expanded .expand-indicator {
    transform: rotate(180deg);
}

.list-item-expanded {
    padding: 0 16px 16px 52px;
    display: none;
    font-size: 14px;
    color: var(--text-secondary, #666);
    line-height: 1.6;
}

.entity-list-item.expanded .list-item-expanded {
    display: block;
}

/* Panel Display */
.entity-panels {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.entity-panel {
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
}

.panel-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    display: flex;
    align-items: center;
    gap: 16px;
}

.panel-icon {
    font-size: 48px;
}

.panel-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.panel-subtitle {
    font-size: 16px;
    color: var(--text-secondary, #666);
    margin: 4px 0 0 0;
}

.panel-body {
    padding: 24px;
}

.panel-section {
    margin-bottom: 24px;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.attributes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.attribute-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.attribute-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.attribute-value {
    font-size: 14px;
    color: var(--text-primary, #333);
}

.section-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary, #666);
}

.section-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.section-list li:last-child {
    border-bottom: none;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.grid-item {
    padding: 12px;
    background: var(--secondary-bg, #f5f5f5);
    border-radius: 6px;
    font-size: 14px;
}

.panel-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: var(--secondary-bg, #f5f5f5);
}

.related-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.related-link {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-primary, #333);
    transition: all 0.2s;
}

.related-link:hover {
    background: var(--primary-color, #9370DB);
    color: white;
    border-color: var(--primary-color, #9370DB);
}

/* Inline Display */
.entity-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--secondary-bg, #f5f5f5);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary, #333);
    font-size: 14px;
    transition: all 0.2s;
}

.entity-inline:hover {
    background: var(--primary-color, #9370DB);
    color: white;
}

.inline-icon {
    font-size: 16px;
}

.inline-name {
    font-weight: 500;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
    .results-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .display-mode-switcher {
        justify-content: center;
    }

    .filter-panel {
        grid-template-columns: 1fr;
    }
}
