/* Discovery System Styles */

/* Search Widget */
.search-widget {
    position: relative;
}

.search-input-container {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.discovery-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #f8f9fa;
    color: #1a1a1a;
    font-size: 14px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.discovery-search-input:focus {
    outline: none;
    border-color: #007bff;
    background: #fff;
}

.discovery-search-input::placeholder {
    color: #666;
}

.search-submit-btn {
    padding: 10px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-submit-btn:hover {
    background: #0056b3;
}

/* Search Autocomplete */
.search-autocomplete {
    position: absolute;
    top: 100%;
    left: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.autocomplete-section {
    border-bottom: 1px solid #f0f0f0;
}

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

.autocomplete-header {
    padding: 8px 16px;
    background: #f8f9fa;
    color: #666;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f5f5f5;
}

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

.autocomplete-item:hover {
    background: #f8f9fa;
}

.autocomplete-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.autocomplete-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 50%;
    color: #666;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
}

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

.autocomplete-title {
    color: #1a1a1a;
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 2px;
}

.autocomplete-subtitle {
    color: #666;
    font-size: 11px;
}

.autocomplete-empty {
    padding: 16px;
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 13px;
}

/* Search Results */
.search-results {
    display: none;
}

.search-results-container {
    padding: 0;
}

.search-results-section {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.search-results-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.section-title {
    color: #1a1a1a;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    padding: 8px 20px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f5f5f5;
}

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

.search-result-item:hover {
    background: #f8f9fa;
}

.result-avatar {
    flex-shrink: 0;
}

.result-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

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

.result-title {
    color: #1a1a1a;
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 2px;
    line-height: 1.3;
}

.result-subtitle {
    color: #666;
    font-size: 11px;
    margin-bottom: 2px;
}

.result-description {
    color: #666;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.result-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #888;
}

.result-actions {
    flex-shrink: 0;
}

.result-actions button {
    padding: 4px 8px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background-color 0.2s ease;
}

.result-actions button:hover {
    background: #0056b3;
}

.show-more-results {
    text-align: center;
    padding: 8px 20px;
}

.show-more-btn {
    padding: 6px 12px;
    background: transparent;
    color: #007bff;
    border: 1px solid #007bff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.show-more-btn:hover {
    background: #007bff;
    color: white;
}

.search-empty,
.search-error {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
    font-size: 13px;
}

.search-error {
    color: #dc3545;
}

/* Search highlighting */
mark {
    background: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Discovery Sidebar */
.discovery-sidebar {
    width: 100%;
    max-width: 320px;
    padding: 0;
}

.discovery-widget {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.widget-title {
    font-size: 18px;
    font-weight: 600;
    padding: 16px 20px 12px;
    margin: 0;
    color: #1a1a1a;
    border-bottom: 1px solid #f0f0f0;
}

/* Trending Topics */
.trending-topics .trending-list {
    padding: 0;
}

.trending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.trending-item:hover {
    background-color: #f8f9fa;
}

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

.topic-name {
    font-weight: 500;
    color: #1a1a1a;
    font-size: 14px;
}

.topic-count {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Suggested Users */
.user-suggestions {
    padding: 0;
}

.user-suggestion {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    gap: 12px;
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.user-username {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.suggestion-reason {
    font-size: 11px;
    color: #888;
    line-height: 1.3;
}

/* The html.visual-refresh prefix is required to outrank
   `html.visual-refresh button { padding: 0; ... }` (specificity 0,1,2)
   in visual_refresh.css. */
.follow-btn, .join-btn,
html.visual-refresh button.follow-btn,
html.visual-refresh button.join-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.follow-btn:hover, .join-btn:hover,
html.visual-refresh button.follow-btn:hover,
html.visual-refresh button.join-btn:hover {
    background: #0056b3;
}

.join-btn.joined,
html.visual-refresh button.join-btn.joined {
    background: var(--CS-blue, #0c6af5);
    color: #fff;
    border: 1px solid var(--CS-blue, #0c6af5);
}

.join-btn.joined:hover,
html.visual-refresh button.join-btn.joined:hover {
    background: var(--CS-aqua, #00a3ff);
    color: #fff;
    border-color: var(--CS-aqua, #00a3ff);
}

/* Popular Channels */
.channel-suggestions {
    padding: 0;
}

.channel-suggestion {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    gap: 12px;
}

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

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-name {
    font-weight: 500;
    font-size: 14px;
    color: #1a1a1a;
    margin-bottom: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.channel-name:hover {
    color: var(--CS-blue);
    text-decoration: underline;
}

.channel-description {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 6px;
}

.channel-stats {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #888;
}

.member-count::before {
    content: "👥 ";
}

/* Discovery Main Content */
.discovery-main {
    flex: 1;
    max-width: 600px;
}

.discovery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.discovery-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
}

.discovery-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #e9ecef;
}

.filter-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Discovery Feed */
.discovery-feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.discovery-feed-item {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.discovery-feed-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Card Components */
.trending-post-card,
.topic-card,
.user-card {
    padding: 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.card-type {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trending-score {
    font-size: 11px;
    color: #888;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 8px;
}

.card-content {
    padding: 16px 20px;
}

.card-actions {
    padding: 12px 20px 16px;
    border-top: 1px solid #f0f0f0;
}

/* Post Cards */
.post-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.post-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #888;
}

.author {
    font-weight: 500;
}

.stats {
    display: flex;
    gap: 12px;
}

/* Channel Cards */
.channel-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.channel-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.channel-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #888;
}

/* Topic Cards */
.topic-name {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 12px 0;
}

.topic-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #888;
}

.topic-type {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

/* User Cards */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-card .user-avatar {
    width: 48px;
    height: 48px;
}

.user-card .user-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 4px 0;
}

.user-card .user-username {
    font-size: 14px;
    color: #666;
}

/* Action Buttons */
.view-post-btn,
.join-channel-btn,
.explore-topic-btn,
.follow-user-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
}

.view-post-btn:hover,
.join-channel-btn:hover,
.explore-topic-btn:hover,
.follow-user-btn:hover {
    background: #0056b3;
}

/* Trending Posts Widget */
.trending-post-list {
    padding: 0;
}

.trending-post-item {
    display: block;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: inherit;
    text-decoration: none;
}

.trending-post-item:hover {
    background-color: #f8f9fa;
}

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

.trending-post-item .post-title {
    font-size: 14px;
    margin-bottom: 6px;
}

.trending-post-item .post-meta {
    font-size: 11px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .discovery-sidebar {
        max-width: none;
        width: 100%;
    }
    
    .discovery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .discovery-filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    
    .filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .user-suggestion,
    .channel-suggestion {
        padding: 12px 16px;
    }
    
    .card-content,
    .card-actions {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .trending-item,
    .trending-post-item {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .discovery-widget {
        margin-bottom: 16px;
        border-radius: 8px;
    }
    
    .widget-title {
        font-size: 16px;
        padding: 12px 16px 8px;
    }
    
    .discovery-header h2 {
        font-size: 20px;
    }
    
    .post-title {
        font-size: 15px;
    }
    
    .channel-name,
    .topic-name {
        font-size: 15px;
    }
}

/* Loading States */
.discovery-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.discovery-loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty States */
.discovery-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.discovery-empty h3 {
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.discovery-empty p {
    margin: 0;
    font-size: 14px;
}