/* Discussion Board Styles */

/* No reviews buttons container */
.no-reviews-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Discussion Section */
#discussion-section {
    padding: 2rem 0;
}

/* Discussion Overlay (for search page) */
.discussion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 900;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow-y: auto;
}

.discussion-overlay.hidden {
    display: none;
}

.discussion-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Small button style for inline use */
.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small.btn-discussion {
    background-color: #6c5ce7;
    color: white;
    border: none;
    margin-right: 0.5rem;
}

.btn-small.btn-discussion:hover {
    background-color: #5b4cdb;
}

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

.btn-small.btn-primary:hover {
    background-color: #357abd;
}

/* Discussion Header */
.discussion-course-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.discussion-course-info h2 {
    font-size: 1.5rem;
    color: var(--text-color);
    margin: 0;
}

.discussion-subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
    margin: 0.25rem 0 0 0;
}

/* Discussion Tabs */
.discussion-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.discussion-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.discussion-tab:hover {
    color: var(--primary-color);
    background-color: var(--bg-light);
}

.discussion-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.discussion-tab .tab-icon {
    margin-right: 0.5rem;
}

/* Discussion Controls */
.discussion-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.discussion-sort label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.discussion-sort select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
    cursor: pointer;
}

.btn-new-thread {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-new-thread:hover {
    background-color: #357abd;
}

/* Thread Cards */
.discussion-threads-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.discussion-thread-card {
    display: flex;
    gap: 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.discussion-thread-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

/* Vote Section */
.thread-vote-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.thread-vote-section-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
}

.upvote-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
}

.upvote-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: #e8f4fc;
}

.upvote-btn.upvoted {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.upvote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upvote-btn.small {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
}

.upvote-arrow {
    font-size: 0.9rem;
}

.upvote-count {
    font-weight: bold;
    color: var(--text-color);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Thread Content */
.thread-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.thread-title {
    font-size: 1.1rem;
    color: var(--text-color);
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

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

.thread-body-preview {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 0.75rem 0;
}

.discussion-reactions {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
}

.discussion-reactions .reaction-badge {
    font-size: 0.82rem;
}

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

.discussion-reactions .reaction-picker {
    top: calc(100% + 0.5rem);
    bottom: auto;
}

.thread-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.thread-author {
    color: var(--primary-color);
}

.thread-replies {
    color: var(--text-light);
}

.thread-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.thread-share-btn {
    background: #eef5ff;
    border: 1px solid #bfd9fb;
    color: #245ea8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.3rem 0.45rem;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.thread-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.3rem;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s;
}

.thread-delete-btn:hover {
    opacity: 1;
    background-color: #fee;
}

/* Discussion Empty State */
.discussion-empty {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.discussion-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.discussion-empty p {
    color: var(--text-light);
    font-size: 1.1rem;
    margin: 0;
}

.discussion-empty-actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* Thread Detail View */
.thread-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.thread-share-btn-detail {
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
}

.thread-detail-content {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.thread-detail-main {
    display: flex;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.thread-detail-body {
    flex: 1;
}

.thread-detail-body h2 {
    font-size: 1.5rem;
    color: var(--text-color);
    margin: 0 0 0.75rem 0;
}

.thread-detail-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.thread-detail-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    white-space: pre-wrap;
}

/* Replies Section */
.thread-replies-section h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin: 0 0 1rem 0;
}

.thread-replies-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.no-replies {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-style: italic;
}

/* Reply Items */
.reply-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 6px;
    border-left: 3px solid var(--border-color);
}

.reply-item.depth-1 { margin-left: 2rem; }
.reply-item.depth-2 { margin-left: 4rem; }
.reply-item.depth-3 { margin-left: 6rem; }
.reply-item.depth-4 { margin-left: 8rem; }
.reply-item.depth-5 { margin-left: 10rem; }

.reply-vote-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
}

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

.reply-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.reply-author {
    color: var(--primary-color);
    font-weight: 500;
}

.reply-time {
    color: var(--text-light);
}

.reply-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
}

.reply-content .discussion-reactions {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
}

.reply-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.reply-action-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.reply-action-btn:hover {
    color: var(--primary-color);
    background-color: white;
}

.reply-action-btn.delete:hover {
    color: var(--danger-color);
    background-color: #fee;
}

.reply-children {
    margin-top: 0.5rem;
}

/* Nested Reply Form */
.nested-reply-form {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.nested-reply-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.nested-reply-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.nested-reply-actions button {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

/* Reply Form Container */
.reply-form-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.reply-form-container h4 {
    font-size: 1rem;
    color: var(--text-color);
    margin: 0 0 0.75rem 0;
}

#reply-form textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

#reply-form button {
    float: right;
}

.login-to-reply {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 4px;
    margin-top: 1.5rem;
}

.login-to-reply a {
    color: var(--primary-color);
    text-decoration: none;
}

.login-to-reply a:hover {
    text-decoration: underline;
}

/* New Thread Modal */
#new-thread-modal .modal-content {
    max-width: 600px;
}

#new-thread-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#new-thread-form label {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

#new-thread-form input[type="text"] {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

#new-thread-form textarea {
    min-height: 150px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    resize: vertical;
}

#new-thread-form button[type="submit"] {
    align-self: flex-end;
    padding: 0.75rem 1.5rem;
}

/* Discussion Button on Course Detail */
.btn-discussion {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background-color: #6c5ce7;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 0.75rem;
}

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

/* Responsive Styles */
@media (max-width: 768px) {
    .discussion-course-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .discussion-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .discussion-sort {
        justify-content: space-between;
    }
    
    .btn-new-thread {
        width: 100%;
        justify-content: center;
    }
    
    .discussion-tabs {
        overflow-x: auto;
    }
    
    .discussion-tab {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    .thread-detail-main {
        flex-direction: column;
        gap: 1rem;
    }
    
    .thread-vote-section-large {
        flex-direction: row;
        gap: 0.75rem;
        padding-right: 0;
        padding-bottom: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .reply-item.depth-1,
    .reply-item.depth-2,
    .reply-item.depth-3,
    .reply-item.depth-4,
    .reply-item.depth-5 {
        margin-left: 1rem;
    }
    
    .thread-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .discussion-thread-card {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .thread-vote-section {
        flex-direction: row;
        gap: 0.5rem;
        min-width: auto;
    }
    
    .upvote-count {
        margin-top: 0;
    }
    
    .reply-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .reply-vote-section {
        flex-direction: row;
        gap: 0.5rem;
        min-width: auto;
    }
}

/* ============================================
   Unified Discussion Refresh
   ============================================ */

#discussion-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 0 24px;
}

.discussion-overlay {
    padding: 16px;
    background-color: rgba(22, 28, 37, 0.38);
}

.discussion-container {
    max-width: 960px;
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.btn-small {
    min-height: 36px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.84rem;
    font-weight: 600;
}

.btn-small.btn-discussion,
.btn-discussion,
.btn-new-thread,
.thread-share-btn,
.thread-share-btn-detail {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    color: #fff;
}

.btn-small.btn-discussion:hover,
.btn-discussion:hover,
.btn-new-thread:hover,
.thread-share-btn:hover,
.thread-share-btn-detail:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-discussion {
    min-height: 40px;
    padding: 9px 14px;
    margin-left: 0;
}

.discussion-course-header {
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

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

.discussion-course-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.discussion-course-info h2 {
    font-size: 1.2rem;
}

.discussion-subtitle {
    font-size: 0.82rem;
}

.discussion-tabs {
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: none;
}

.discussion-tab {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: #fff;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.discussion-tab:hover,
.discussion-tab.active {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.discussion-controls {
    gap: 12px;
    margin-bottom: 12px;
}

.discussion-sort select {
    min-height: 38px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
}

.discussion-threads-list {
    gap: 12px;
}

.discussion-thread-card {
    padding: 14px;
    gap: 12px;
    border-radius: 12px;
    box-shadow: none;
}

.discussion-thread-card:hover {
    box-shadow: var(--shadow-sm);
}

.thread-vote-section {
    min-width: 42px;
}

.upvote-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.upvote-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

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

.thread-title {
    font-size: 1rem;
    margin-bottom: 6px;
}

.thread-body-preview {
    font-size: 0.86rem;
    margin-bottom: 8px;
}

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

.thread-actions {
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
}

.thread-share-btn,
.thread-delete-btn,
.reply-action-btn {
    min-height: 34px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
}

.discussion-empty {
    padding: 28px 16px;
}

.discussion-empty p,
.no-replies,
.reply-text,
.thread-detail-text {
    font-size: 0.88rem;
    line-height: 1.5;
}

.thread-detail-header {
    margin-bottom: 12px;
}

.thread-detail-content {
    padding: 16px;
}

.thread-detail-main {
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.thread-vote-section-large {
    min-width: 52px;
    padding-right: 12px;
}

.thread-detail-body h2 {
    font-size: 1.2rem;
}

.thread-replies-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.reply-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border-left-width: 2px;
}

.reply-actions {
    gap: 8px;
}

.nested-reply-form,
.reply-form-container {
    margin-top: 12px;
    padding-top: 12px;
}

.nested-reply-form {
    padding: 12px;
    border-radius: var(--radius-md);
}

#reply-form textarea,
.nested-reply-form textarea {
    min-height: 88px;
}

@media (max-width: 768px) {
    #discussion-section {
        padding-top: 12px;
    }

    .discussion-course-header,
    .discussion-controls,
    .thread-detail-main,
    .thread-detail-header {
        align-items: flex-start;
    }

    .discussion-tabs {
        flex-wrap: wrap;
    }

    .discussion-tab {
        flex: 1 1 auto;
        justify-content: center;
    }

    .thread-actions {
        width: 100%;
    }
}
