/* Comment System Styles */
.comment-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
}

.comment-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.comment-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-light);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.comment-modal.show {
    transform: translateY(0);
}

.comment-modal-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.comment-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comment-modal-title i {
    color: var(--accent);
    font-size: 1.25rem;
}

.comment-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.comment-modal-close:hover {
    background: var(--accent-light);
    color: white;
}

.comment-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    min-height: 300px;
}

.comment-modal-footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-light);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Comment List */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comment-item {
    background: var(--bg-light);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    padding: 0.875rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.comment-item:hover {
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.25);
}

.comment-item.spoiler-hidden {
    opacity: 0.6;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.comment-user-info {
    flex: 1;
    min-width: 0;
}

.comment-username {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.comment-username.author {
    color: var(--accent);
}

.comment-pinned-icon {
    color: #fbbf24;
    font-size: 0.875rem;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.comment-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.comment-badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.comment-badge.author-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.comment-badge.pinned-badge {
    background: #fbbf24;
    color: #78350f;
}

.comment-content {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    word-wrap: break-word;
}

/* Mention styling in comments */
.comment-mention {
    color: var(--accent);
    font-weight: 600;
    background: rgba(139, 92, 246, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.comment-mention:hover {
    background: rgba(139, 92, 246, 0.2);
}

.comment-spoiler-notice {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.comment-spoiler-notice button {
    margin-left: auto;
    padding: 0.375rem 0.75rem;
    background: #fbbf24;
    color: #78350f;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.comment-spoiler-notice button:hover {
    background: #f59e0b;
}

.comment-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.comment-action-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.comment-action-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.comment-action-btn:active::before {
    width: 100px;
    height: 100px;
}

.comment-action-btn:hover {
    background: var(--border-light);
    color: var(--text-light);
    transform: translateY(-1px);
}

.comment-action-btn:active {
    transform: translateY(0);
}

.comment-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.comment-action-btn.active {
    background: var(--accent-light);
    color: white;
    border-color: var(--accent-light);
    font-weight: 600;
}

.comment-action-btn.like-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
    animation: reactionPulse 0.3s ease;
}

.comment-action-btn.dislike-btn.active {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    animation: reactionPulse 0.3s ease;
}

@keyframes reactionPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.comment-action-btn.reply-count-btn {
    color: var(--accent);
    border-color: var(--accent-light);
}

.comment-action-btn.reply-count-btn:hover {
    background: var(--accent-light);
    color: white;
    border-color: var(--accent);
}

.comment-action-btn i {
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.comment-action-btn:active i {
    transform: scale(1.2);
}

.comment-action-btn.active i {
    transform: scale(1.1);
}

/* Comment Form */
.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.comment-input-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: var(--bg-light);
    border: 2px solid var(--border-light);
    border-radius: 24px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.comment-input-container.mention-highlight {
    animation: mentionGlow 1s ease;
}

@keyframes mentionGlow {
    0%, 100% {
        border-color: var(--border-light);
        box-shadow: none;
    }
    50% {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
    }
}

.comment-input {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-light);
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
}

.comment-input:focus {
    outline: none;
}

.comment-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.comment-submit-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.comment-submit-btn:hover:not(:disabled) {
    background: var(--accent-dark);
    transform: scale(1.05);
}

.comment-submit-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.comment-submit-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.comment-submit-btn i {
    font-size: 0.875rem;
}

/* Auto-expand textarea */
.comment-input {
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.comment-input::-webkit-scrollbar {
    width: 4px;
}

.comment-input::-webkit-scrollbar-track {
    background: transparent;
}

.comment-input::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

.comment-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Reply Section */
.comment-replies {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.comment-reply-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--border-light);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s ease;
    width: fit-content;
}

.comment-reply-count:hover {
    background: var(--accent-light);
    color: white;
}

.comment-reply-count i {
    font-size: 0.875rem;
}

/* Reply Modal (for nested comments) */
.reply-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-light);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reply-modal.show {
    transform: translateX(0);
}

.reply-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    background: var(--bg-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

.reply-back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.reply-back-btn:hover {
    background: var(--accent-light);
    color: white;
}

.reply-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-light);
}

.reply-modal-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.reply-parent-comment {
    padding: 1rem 1.5rem;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 2px solid rgba(139, 92, 246, 0.15);
    flex-shrink: 0;
}

.reply-list {
    padding: 1rem 1.5rem;
    flex: 1;
}

/* Loading States */
.comment-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.comment-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.comment-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.comment-empty i {
    font-size: 3rem;
    color: var(--accent-light);
    margin-bottom: 1rem;
}

/* Error State */
.comment-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.875rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Login Prompt */
.comment-login-prompt {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--purple-50);
    border-radius: 12px;
    margin: 1rem 0;
}

.comment-login-prompt i {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.comment-login-prompt h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.comment-login-prompt p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.comment-login-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.comment-login-btn:hover {
    background: var(--accent-dark);
}

/* Nested Reply Indicator */
.comment-item.reply {
    margin-left: 2rem;
    border-left: 3px solid var(--accent-light);
}

/* More Actions Menu */
.comment-more-menu {
    position: relative;
}

.comment-more-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.comment-more-btn:hover {
    background: var(--border-light);
}

.comment-more-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    min-width: 150px;
    display: none;
    z-index: 10;
}

.comment-more-dropdown.show {
    display: block;
}

.comment-more-dropdown button {
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: background 0.2s ease;
}

.comment-more-dropdown button:hover {
    background: var(--border-light);
}

.comment-more-dropdown button.danger {
    color: #ef4444;
}

/* Responsive */
@media (min-width: 768px) {
    .comment-modal {
        left: 50%;
        right: auto;
        transform: translate(-50%, 100%);
        max-width: 600px;
        border-radius: 20px;
        bottom: 20px;
        max-height: 80vh;
    }
    
    .comment-modal.show {
        transform: translate(-50%, 0);
    }
}

/* Custom Modal for Edit/Delete */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.custom-modal-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.custom-modal {
    background: var(--bg-light);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-light);
}

.custom-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.custom-modal-close:hover {
    background: var(--accent-light);
    color: white;
}

.custom-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.edit-comment-modal .comment-input {
    width: 100%;
    min-height: 120px;
    padding: 0.875rem;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    font-family: inherit;
    color: var(--text-light);
    background: var(--bg-light);
    resize: vertical;
    transition: border-color 0.2s ease;
}

.edit-comment-modal .comment-input:focus {
    outline: none;
    border-color: var(--accent);
}

.character-count {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.character-count.warning {
    color: #f59e0b;
}

.character-count.danger {
    color: #ef4444;
}

.delete-warning {
    text-align: center;
    padding: 1rem 0;
}

.delete-warning i {
    font-size: 3rem;
    color: #f59e0b;
    margin-bottom: 1rem;
}

.delete-warning p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-light);
    line-height: 1.6;
}

.custom-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.custom-btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    min-width: 100px;
    justify-content: center;
}

.custom-btn-secondary {
    background: var(--border-light);
    color: var(--text-light);
}

.custom-btn-secondary:hover {
    background: #d1d5db;
}

.custom-btn-primary {
    background: var(--accent);
    color: white;
}

.custom-btn-primary:hover {
    background: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.custom-btn-danger {
    background: #ef4444;
    color: white;
}

.custom-btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.custom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}
