/**
 * Search View Styles
 * Complete search interface with filters, results, and history
 */

/* Main search view container */
.search-view {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Search header */
.search-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.search-header h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--text-primary, #1a1a2e);
}

.search-description {
    font-size: 1.1rem;
    color: var(--text-secondary, #666);
    margin-bottom: 30px;
}

/* Search input */
.search-input-wrapper {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color, #9370DB);
    box-shadow: 0 6px 24px rgba(147, 112, 219, 0.25);
    transform: translateY(-2px);
}

.search-icon {
    font-size: 24px;
    color: var(--text-secondary, #666);
}

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

.search-input::placeholder {
    color: var(--text-tertiary, #999);
}

.clear-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary, #666);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.clear-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    color: var(--error-color, #dc3545);
    transform: scale(1.1);
}

.clear-btn:active {
    transform: scale(0.95);
}

.search-submit-btn {
    background: linear-gradient(135deg, var(--primary-color, #9370DB), rgba(147, 112, 219, 0.8));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.search-submit-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover, #7d5ba6), rgba(125, 91, 166, 0.8));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(147, 112, 219, 0.4);
}

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

/* Autocomplete suggestions */
.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border: 2px solid var(--primary-color, #9370DB);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(147, 112, 219, 0.2);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.suggestion-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    display: flex;
    align-items: center;
}

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

.suggestion-item:hover {
    background: linear-gradient(90deg, rgba(147, 112, 219, 0.08), transparent);
    padding-left: 24px;
}

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

/* Search content layout */
.search-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-top: 40px;
}

@media (max-width: 1024px) {
    .search-content {
        grid-template-columns: 1fr;
    }
}

/* Filters sidebar */
.search-filters {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.filter-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
}

.filter-toggle-btn:hover {
    border-color: var(--primary-color, #9370DB);
    background: var(--hover-bg, #f5f5f5);
}

.filter-count {
    background: var(--primary-color, #9370DB);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.filter-panel {
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-group {
    margin-bottom: 24px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group > label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-primary, #333);
}

.filter-group select,
.filter-group input[type="range"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input[type="range"]:focus {
    outline: none;
    border-color: var(--primary-color, #9370DB);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    transition: color 0.2s;
}

.checkbox-group label:hover {
    color: var(--primary-color, #9370DB);
}

.checkbox-group input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Search history */
.search-history {
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 16px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color, #9370DB);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.btn-text:hover {
    color: var(--primary-hover, #7d5ba6);
    text-decoration: underline;
}

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

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.history-query {
    font-size: 14px;
    color: var(--text-primary, #333);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-count {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    background: var(--secondary-bg, #f5f5f5);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Results main area */
.search-results-main {
    min-height: 500px;
}

.results-controls {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(247, 245, 255, 0.95));
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.results-info {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

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

.display-mode-btn {
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 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: 10px;
}

.sort-controls label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary, #666);
}

.sort-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color, #9370DB);
}

/* Empty states */
.search-placeholder,
.no-results,
.search-loading,
.search-error {
    text-align: center;
    padding: 80px 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(245, 245, 245, 0.5), rgba(240, 240, 245, 0.5));
}

.placeholder-icon,
.no-results-icon,
.error-icon {
    font-size: 72px;
    margin-bottom: 20px;
    opacity: 0.7;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.search-placeholder p:first-of-type,
.no-results p:first-of-type {
    font-weight: 600;
    color: var(--text-primary, #333);
}

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

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

.search-examples p {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary, #333);
}

.example-query {
    display: inline-block;
    padding: 10px 20px;
    margin: 6px;
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.example-query:hover {
    background: linear-gradient(135deg, var(--primary-color, #9370DB), rgba(147, 112, 219, 0.8));
    color: white;
    border-color: var(--primary-color, #9370DB);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(147, 112, 219, 0.4);
}

.example-query:active {
    transform: translateY(-1px);
}

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

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

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

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

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

.grid-card {
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 16px;
    padding: 24px;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.grid-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(147, 112, 219, 0.1), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.grid-card:hover::before {
    left: 100%;
}

.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color, #9370DB);
}

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

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

.card-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary, #1a1a2e);
}

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

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color, #e0e0e0);
    margin-top: auto;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

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

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

/* List view */
.universal-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.entity-list-item {
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.entity-list-item:hover {
    border-color: var(--primary-color, #9370DB);
    box-shadow: 0 4px 16px rgba(147, 112, 219, 0.15);
}

.list-item-main {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    text-decoration: none;
    transition: background 0.2s;
}

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

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

.list-content {
    flex: 1;
    min-width: 0;
}

.list-primary {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    margin-bottom: 6px;
}

.list-secondary {
    font-size: 14px;
    color: var(--text-secondary, #666);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

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

/* Table view */
.entity-table-container {
    background: white;
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
}

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

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

.entity-table th {
    padding: 16px;
    text-align: left;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary, #333);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.entity-table tbody tr {
    transition: background 0.2s;
}

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

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 32px 0;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 44px;
    height: 44px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    padding: 10px;
    color: var(--text-secondary, #666);
}

/* Responsive design */
@media (max-width: 768px) {
    .search-header h1 {
        font-size: 2rem;
    }

    .search-input-wrapper {
        flex-wrap: wrap;
    }

    .search-input {
        font-size: 16px;
    }

    .results-controls {
        flex-direction: column;
        align-items: stretch;
    }

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

    .universal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .filter-actions {
        flex-direction: column;
    }

    .filter-actions button {
        width: 100%;
    }
}

/* Mobile Portrait: 2 columns (375px-480px viewport) */
@media (max-width: 480px) {
    .universal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0.5rem;
    }

    .grid-card {
        padding: 1rem;
    }

    .card-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-subtitle {
        font-size: 0.8rem;
        min-height: auto;
    }

    .card-badge {
        padding: 2px 8px;
        font-size: 9px;
    }
}

/* Mobile Landscape: 4 columns */
@media (max-width: 896px) and (orientation: landscape) {
    .search-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .search-input-wrapper {
        padding: 0.5rem;
    }

    .search-input {
        font-size: 14px;
        padding: 0.5rem 1rem;
    }

    .results-controls {
        flex-direction: row;
        padding: 0.5rem;
    }

    .universal-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px;
    }

    /* Compact cards for search results in landscape */
    .grid-card {
        padding: 12px;
    }

    .card-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .card-title {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .card-subtitle {
        font-size: 12px;
        min-height: auto;
        margin-bottom: 8px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card-stats {
        display: none;
    }

    .card-badge {
        font-size: 9px;
        padding: 2px 8px;
        top: 8px;
        right: 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-view {
        color: #e0e0e0;
    }

    .search-header h1,
    .card-title,
    .list-primary {
        color: #ffffff;
    }

    .search-input-wrapper,
    .filter-panel,
    .search-history,
    .results-controls,
    .grid-card,
    .entity-list-item,
    .entity-table-container {
        background: #2a2a3e;
        border-color: #404050;
    }

    .search-input {
        color: #e0e0e0;
    }

    .suggestion-item:hover,
    .list-item-main:hover,
    .entity-table tbody tr:hover {
        background: #35354a;
    }
}
