/* Search Page Styles */

/* Search Page Layout */
.search-page {
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Search Header */
.search-header {
    margin-bottom: 2rem;
}

.search-box-large {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-box-large input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box-large input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.search-box-large button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    white-space: nowrap;
}

.search-query-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-size: 0.95rem;
}

#search-query-display {
    font-weight: 500;
}

#results-count {
    color: #888;
}

/* Search Content Layout */
.search-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

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

/* Filters Sidebar */
.search-filters {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.filters-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.btn-text {
    background: none;
    border: none;
    color: #4a90d9;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.btn-text:hover {
    text-decoration: underline;
}

.filter-section {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

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

.filter-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    color: #555;
    font-weight: 600;
}

/* Collapsible Filter Sections */
.filter-section.collapsible .filter-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.6rem 0;
    margin: 0;
    user-select: none;
    transition: color 0.2s;
}

.filter-section.collapsible .filter-section-header:hover {
    color: #4a90d9;
}

.filter-section.collapsible .filter-section-header span:first-child {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-section.collapsible .collapse-icon {
    font-size: 0.7rem;
    color: #888;
    transition: transform 0.2s;
}

.filter-section.collapsible:not(.collapsed) .collapse-icon {
    transform: rotate(90deg);
}

.filter-section.collapsible .filter-content {
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out, padding 0.2s ease-out;
    opacity: 1;
    padding-top: 0.5rem;
}

.filter-section.collapsible.collapsed .filter-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: #444;
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4a90d9;
}

.filter-checkbox span {
    flex: 1;
}

.filter-checkbox .count {
    color: #888;
    font-size: 0.85rem;
}

.filter-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: #4a90d9;
}

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

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

/* Course Result Card */
.course-result-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.course-result-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Course Summary (always visible) */
.course-summary {
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
}

.course-summary:hover {
    background: #fafafa;
}

.course-main-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.course-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.expand-indicator {
    font-size: 0.8rem;
    color: #888;
    transition: transform 0.2s;
}

.expand-indicator.expanded {
    transform: rotate(90deg);
}

.course-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.course-code-badge {
    background: #e8f0fe;
    color: #1a73e8;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.course-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: #666;
}

.course-meta-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.course-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.course-rating {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #f5a623;
}

.course-review-count {
    font-size: 0.85rem;
    color: #888;
}

.course-reaction-count {
    font-size: 0.8rem;
    color: #aaa;
}

/* Course Expanded Content */
.course-expanded {
    border-top: 1px solid #eee;
    background: #fafafa;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.course-expanded.visible {
    max-height: 2000px;
    transition: max-height 0.5s ease-in;
}

.course-expanded-content {
    padding: 1.5rem;
}

/* Reviews Section within Course Card */
.course-reviews-section {
    margin-top: 1rem;
}

.reviews-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.reviews-header-row h4 {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.reviews-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reviews-sort-controls label {
    font-size: 0.85rem;
    color: #666;
}

.reviews-sort-controls select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
}

/* Review Item in Search Results */
.search-review-item {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e8e8e8;
}

.search-review-item:last-child {
    margin-bottom: 0;
}

.review-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.review-item-title {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.review-item-rating {
    color: #f5a623;
    font-weight: 500;
}

.review-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.review-item-content {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.5;
}

.review-item-content.truncated {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.review-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f0f0;
}

.review-reactions-mini {
    display: flex;
    gap: 0.5rem;
}

.reaction-mini {
    background: #f5f5f5;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.read-more-link {
    color: #4a90d9;
    font-size: 0.85rem;
    cursor: pointer;
}

.read-more-link:hover {
    text-decoration: underline;
}

/* No Reviews Message */
.no-reviews-message {
    text-align: center;
    padding: 2rem;
    color: #888;
    font-size: 0.9rem;
}

.no-reviews-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.no-reviews-actions .btn-discussion {
    background-color: #6c5ce7;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.no-reviews-actions .btn-discussion:hover {
    background-color: #5b4cdb;
}

/* View Course Button */
.view-course-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.6rem 1.2rem;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.view-course-btn:hover {
    background: #3a7bc8;
}

/* Load More */
.load-more-container {
    text-align: center;
    margin-top: 2rem;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.no-results h3 {
    margin: 0 0 1rem 0;
    color: #333;
}

.no-results p {
    color: #666;
    margin-bottom: 1.5rem;
}

.no-results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Loading State */
.results-list .loading {
    text-align: center;
    padding: 3rem;
    color: #888;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .search-box-large {
        flex-direction: column;
    }
    
    .search-box-large button {
        width: 100%;
    }
    
    .course-summary {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .course-stats {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 1rem;
    }
    
    .search-filters {
        position: static;
    }
    
    .filter-section {
        margin-bottom: 1rem;
    }
}

/* Filter Badge (for active filters) */
.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #e8f0fe;
    color: #1a73e8;
    padding: 0.3rem 0.6rem;
    border-radius: 16px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.filter-badge .remove-filter {
    cursor: pointer;
    font-weight: bold;
    margin-left: 0.2rem;
}

.filter-badge .remove-filter:hover {
    color: #d93025;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-text {
    height: 16px;
    width: 80%;
    margin-bottom: 0.5rem;
}

.skeleton-text.short {
    width: 40%;
}

/* Course Code Link */
.course-code-link {
    background: #e8f0fe;
    color: #1a73e8;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.course-code-link:hover {
    background: #1a73e8;
    color: #fff;
}

/* Share Buttons/Menu (Search Page) */
.search-share-btn {
    background: #eef5ff;
    border: 1px solid #bfd9fb;
    color: #245ea8;
    border-radius: 6px;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.search-share-btn:hover {
    background: #dbeafe;
    border-color: #91c2f8;
}

.search-share-btn.compact {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.share-menu {
    position: absolute;
    z-index: 2000;
    background: #ffffff;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
    min-width: 200px;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.share-menu button {
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
    text-align: left;
    cursor: pointer;
    color: #333;
    font-size: 0.9rem;
}

.share-menu button:hover {
    background: #f5f8fc;
}

.share-menu-status {
    color: #777;
    font-size: 0.78rem;
    min-height: 1rem;
    padding: 0.2rem 0.65rem 0.1rem;
}

/* Reaction Buttons */
.reaction-btn {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.reaction-btn:hover {
    background: #e8f0fe;
    border-color: #4a90d9;
}

.reaction-btn.active {
    background: #e8f0fe;
    border-color: #1a73e8;
}

.add-reaction-btn {
    background: #f5f5f5;
    border: 1px dashed #ccc;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.add-reaction-btn:hover {
    background: #e8f0fe;
    border-color: #4a90d9;
}

/* Reaction Picker Popup */
.reaction-picker-popup {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 0.25rem;
}

.reaction-picker-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.reaction-picker-btn:hover {
    background: #f0f0f0;
}

/* ============================================
   Unified Search Refresh
   ============================================ */

.search-page {
    max-width: var(--page-max-width);
    padding-top: 24px;
    padding-bottom: 32px;
}

.search-header {
    margin-bottom: 16px;
}

.search-box-large {
    width: 100%;
    gap: 8px;
    margin-bottom: 8px;
}

.search-box-large input {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border-radius: 12px;
}

.search-box-large button {
    padding-inline: 16px;
    font-size: 0.92rem;
}

.search-query-info {
    font-size: 0.82rem;
}

.search-content {
    grid-template-columns: 248px 1fr;
    gap: 16px;
}

.search-filters {
    padding: 12px;
    box-shadow: none;
    top: 16px;
}

.filters-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
}

.filters-header h3 {
    font-size: 1rem;
}

.btn-text {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.82rem;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.btn-text:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.search-share-btn,
.no-reviews-actions .btn-discussion {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    color: #fff;
}

.search-share-btn:hover,
.no-reviews-actions .btn-discussion:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.filter-section {
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-section.collapsible .filter-section-header {
    padding: 10px 0;
    font-size: 0.9rem;
}

.filter-options,
.filter-content {
    gap: 6px;
}

.filter-checkbox {
    padding: 4px 0;
    font-size: 0.86rem;
}

.filter-select {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.86rem;
    border-radius: var(--radius-md);
}

.results-list {
    gap: 12px;
}

.course-result-card {
    overflow: visible;
    box-shadow: none;
}

.course-result-card:hover {
    box-shadow: var(--shadow-sm);
}

.course-summary {
    padding: 14px 16px;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.course-title-row {
    flex-wrap: wrap;
    gap: 8px;
}

.course-title {
    font-size: 1rem;
    min-width: 0;
}

.course-title a {
    color: inherit;
    text-decoration: none;
}

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

.course-code-badge,
.course-code-link {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
}

.course-meta-row {
    gap: 8px 12px;
    font-size: 0.8rem;
}

.course-meta-item {
    color: var(--text-light);
}

.course-stats {
    gap: 4px;
}

.course-rating {
    font-size: 1rem;
}

.course-review-count,
.course-reaction-count {
    font-size: 0.78rem;
}

.course-expanded {
    border-top: 1px solid var(--border-color);
    background: transparent;
}

.course-expanded-content {
    padding: 12px 16px 16px;
}

.reviews-header-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.reviews-header-row h4 {
    font-size: 0.95rem;
}

.reviews-sort-controls {
    flex-wrap: wrap;
    gap: 8px;
}

.reviews-sort-controls label {
    font-size: 0.8rem;
}

.reviews-sort-controls select {
    min-height: 36px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
}

.search-review-item {
    padding: 12px;
    border-radius: 12px;
    background: #fff;
}

.review-item-header {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.search-review-top {
    flex: 1;
    min-width: 0;
}

.search-review-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.review-item-title {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 0.94rem;
    text-decoration: none;
}

.review-item-meta {
    gap: 10px;
    font-size: 0.78rem;
    margin-bottom: 0;
}

.review-item-content {
    color: var(--text-color);
    font-size: 0.86rem;
    line-height: 1.45;
}

.review-item-content.truncated {
    -webkit-line-clamp: 4;
    margin-bottom: 10px;
}

.search-review-rating-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.search-review-rating-chip {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: #245ea8;
    font-size: 0.78rem;
}

.search-review-rating-chip strong {
    font-weight: 700;
}

.review-item-footer {
    gap: 8px;
    margin-top: 0;
    padding-top: 10px;
}

.review-reactions-mini {
    flex-wrap: wrap;
    align-items: center;
}

.reaction-btn,
.add-reaction-btn {
    min-height: 32px;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}

.reaction-btn:hover,
.reaction-btn.active,
.add-reaction-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.no-reactions {
    color: var(--text-light);
    font-size: 0.8rem;
}

.no-reviews-message {
    padding: 24px 16px;
    border-style: solid;
}

.no-reviews-message p,
.request-review-hint {
    font-size: 0.84rem;
}

.no-reviews-actions,
.no-results-actions {
    gap: 8px;
}

.no-results {
    padding: 32px 20px;
    box-shadow: none;
}

.skeleton-card {
    padding: 16px;
    box-shadow: none;
}

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

    .search-filters {
        position: static;
        order: -1;
    }
}

@media (max-width: 600px) {
    .course-summary {
        grid-template-columns: 1fr;
    }

    .search-review-actions,
    .review-item-footer {
        justify-content: flex-start;
    }

    .reviews-sort-controls {
        width: 100%;
    }

    .reviews-sort-controls select {
        width: 100%;
    }
}

.search-reaction-tooltip {
    position: absolute;
    min-width: 220px;
    max-width: 280px;
    background: #1f2937;
    color: #f9fafb;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
    padding: 0.75rem;
    z-index: 1200;
    font-size: 0.85rem;
}

.search-reaction-tooltip.hidden {
    display: none;
}

.search-reaction-tooltip-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.search-reaction-tooltip-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-reaction-tooltip-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.35;
}

.search-reaction-tooltip-row + .search-reaction-tooltip-row {
    margin-top: 0.25rem;
}

.search-reaction-tooltip-emoji {
    width: 1.2rem;
    text-align: center;
}

.search-reaction-tooltip-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* No Reactions Text */
.no-reactions {
    color: #aaa;
    font-size: 0.8rem;
    font-style: italic;
}

/* Read More Text */
.read-more-text {
    color: #888;
    font-size: 0.8rem;
    font-style: italic;
}

/* Small Button */
.btn-small {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}

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

/* Reviews Sort Controls with Write Review Button */
.reviews-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reviews-sort-controls .btn-small {
    margin-right: 0.5rem;
}
