/**
 * Comments System Styles
 * Styles for both modal comments and inline task comments
 */

/* ==========================================
   MODAL COMMENTS (Comments Sidebar)
   ========================================== */

/* Note: Base sidebar styles in taskModal.css, these are enhancements */
.comments-sidebar {
    min-height: 0; /* Important for flexbox overflow */
}

.comments-sidebar.open {
    min-height: 0; /* Ensure proper flexbox behavior */
}

.comments-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comments-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.comments-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.comments-close-btn:hover {
    color: #1a1a1a;
}

.comments-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flexbox overflow */
}

.comments-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    min-height: 0; /* Important for proper scrolling */
}

/* No comments message */
.no-comments-message {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.no-comments-message i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-comments-message p {
    margin: 0;
    font-size: 14px;
}

/* Comment Item */
.comment-item {
    margin-bottom: 2px;
    animation: slideIn 0.3s ease;
    flex-shrink: 0; /* ✅ Prevent shrinking */
    min-height: auto; /* ✅ Maintain natural height */
    max-height: none; /* ✅ Allow expansion when editing */
    overflow: visible; /* ✅ Don't clip content */
}

.comment-item:last-child {
    margin-bottom: 0;
}

/* When editing, ensure the comment can expand */
.comment-item.editing {
    overflow: visible;
    height: auto;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    min-height: 32px; /* Ensure header has minimum height */
}

.comment-author-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.comment-avatar {
    font-size: 32px;
    color: #d1d5da;
    flex-shrink: 0;
}

.comment-author-details {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    color: #24292e;
    font-size: 14px;
}

.comment-date {
    font-size: 12px;
    color: #6a737d;
}

.comment-date::before {
    content: '•';
    margin-right: 6px;
    color: #d1d5da;
}

.comment-edited {
    font-size: 11px;
    color: #6a737d;
    font-style: italic;
}

.comment-actions {
    display: flex !important; /* Force display */
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
    align-items: center;
}

.comment-item:hover .comment-actions {
    opacity: 1;
}

.comment-action-btn {
    background: none;
    border: none;
    padding: 4px 7px;
    cursor: pointer;
    color: #6a737d;
    font-size: 13px;
    border-radius: 3px;
    transition: all 0.15s;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
}

.comment-action-btn:hover {
    background: #f1f3f5;
    color: #4A6CF7;
}

.delete-comment-btn:hover {
    color: #d73a49;
    background: #ffeef0;
}

.comment-body {
    padding-left: 42px;
    margin-top: 4px;
    min-height: 20px; /* Ensure minimum height */
    overflow: visible; /* Allow expansion when editing */
}

.comment-text {
    margin: 0;
    color: #24292e;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 20px; /* Prevent collapsing */
}

/* Edit comment - inline compact mode */
.edit-comment-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #4A6CF7;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    min-height: 36px;
    max-height: 100px;
    overflow-y: auto;
}

.edit-comment-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
}

.edit-comment-actions button {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-save-edit {
    color: #28a745;
}

.btn-save-edit:hover {
    background: #e6f4ea;
}

.btn-cancel-edit {
    color: #666;
}

.btn-cancel-edit:hover {
    background: #f0f0f0;
}

/* Comment Input Area */
.comment-input-area {
    border-top: 1px solid #e0e0e0;
    padding: 16px;
    background: #fafafa;
}

.comment-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.status-comment-textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s;
}

.status-comment-textarea:focus {
    outline: none;
    border-color: #4A6CF7;
}

.comment-submit-btn {
    padding: 10px 16px;
    background: #4A6CF7;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    height: 40px;
}

.comment-submit-btn:hover {
    background: #3a5ce7;
}

.comment-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ==========================================
   INLINE COMMENTS (Below Task Items)
   ========================================== */

.inline-comments-section {
    background: linear-gradient(to bottom, #fafbfc 0%, #ffffff 100%);
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
    position: relative;
    width: clamp(500px, 32.5vw, 650px); /* Match task item width */
    margin: 0;
}

/* Alignment based on task author */
.inline-comments-section.align-left {
    align-self: flex-start;
}

.inline-comments-section.align-right {
    align-self: flex-end;
}

.inline-comments-section.open {
    max-height: 500px;
    opacity: 1;
    padding: 18px;
    margin-top: -4px; /* Slight visual connection */
    margin-bottom: 20px;
}

.inline-comments-section.align-left.open {
    margin-left: 0; /* Align with left-aligned task items */
}

.inline-comments-section.align-right.open {
    /* margin-left: auto is set via JavaScript to match task item alignment */
    margin-right: 0;
}

.inline-comments-content {
    max-width: 100%;
}

.inline-comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eaecef;
}

.inline-comments-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #586069;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inline-comments-header i {
    color: #4A6CF7;
    font-size: 13px;
}

.close-inline-comments {
    background: none;
    border: none;
    font-size: 16px;
    color: #959da5;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    transition: all 0.2s;
    opacity: 0.7;
}

.close-inline-comments:hover {
    background: #f3f4f6;
    color: #24292e;
    opacity: 1;
}

.inline-comments-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 14px;
    padding-right: 4px;
}

.loading-comments,
.no-inline-comments {
    text-align: center;
    padding: 24px 16px;
    color: #6a737d;
    font-size: 13px;
}

.no-inline-comments {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.no-inline-comments i {
    font-size: 28px;
    margin-bottom: 4px;
    opacity: 0.3;
    color: #959da5;
}

.no-inline-comments p {
    margin: 0;
    color: #6a737d;
}

/* Inline Comment Item */
.inline-comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inline-comment-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.inline-comment-avatar i {
    font-size: 32px;
    color: #d1d5da;
}

.inline-comment-content {
    flex: 1;
    background: #ffffff;
    border-radius: 6px;
    padding: 10px 14px;
    border: 1px solid #e1e4e8;
    position: relative;
}

.inline-comment-content::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 6px 6px 0;
    border-color: transparent #e1e4e8 transparent transparent;
}

.inline-comment-content::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 6px 6px 0;
    border-color: transparent #ffffff transparent transparent;
}

.inline-comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.inline-comment-header-left {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
}

.inline-comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #24292e;
}

.inline-comment-date {
    font-size: 11px;
    color: #6a737d;
    font-weight: 400;
}

.inline-comment-date::before {
    content: '•';
    margin-right: 6px;
    color: #d1d5da;
}

.inline-comment-edited {
    font-size: 10px;
    color: #6a737d;
    font-style: italic;
}

.inline-comment-text {
    color: #24292e;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.inline-comment-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.inline-comment-item:hover .inline-comment-actions {
    opacity: 1;
}

.inline-comment-edit,
.inline-comment-delete {
    background: none;
    border: none;
    padding: 4px 7px;
    cursor: pointer;
    color: #6a737d;
    font-size: 11px;
    border-radius: 3px;
    transition: all 0.15s;
    font-weight: 500;
}

.inline-comment-edit:hover {
    background: #f1f3f5;
    color: #4A6CF7;
}

.inline-comment-delete:hover {
    background: #ffeef0;
    color: #d73a49;
}

/* Inline edit */
.inline-edit-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #4A6CF7;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 50px;
    margin-bottom: 8px;
}

.inline-edit-actions {
    display: flex;
    gap: 6px;
}

.inline-edit-actions button {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.inline-edit-save {
    background: #4A6CF7;
    color: white;
}

.inline-edit-save:hover {
    background: #3a5ce7;
}

.inline-edit-cancel {
    background: #f0f0f0;
    color: #666;
}

.inline-edit-cancel:hover {
    background: #e0e0e0;
}

/* Inline Comments Input */
.inline-comments-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid #eaecef;
}

.inline-comments-input textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5da;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    transition: all 0.15s ease;
    background: #fafbfc;
}

.inline-comments-input textarea:focus {
    outline: none;
    border-color: #4A6CF7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
}

.inline-comments-input textarea::placeholder {
    color: #6a737d;
    font-size: 13px;
}

.send-inline-comment {
    padding: 8px 14px;
    background: #4A6CF7;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
    height: 38px;
}

.send-inline-comment:hover {
    background: #3a5ce7;
    box-shadow: 0 2px 4px rgba(74, 108, 247, 0.2);
}

.send-inline-comment:active {
    transform: translateY(1px);
}

.send-inline-comment:disabled {
    background: #d1d5da;
    cursor: not-allowed;
    box-shadow: none;
}

/* Scrollbar styles - subtle and professional */
.comments-list::-webkit-scrollbar,
.inline-comments-list::-webkit-scrollbar {
    width: 5px;
}

.comments-list::-webkit-scrollbar-track,
.inline-comments-list::-webkit-scrollbar-track {
    background: transparent;
}

.comments-list::-webkit-scrollbar-thumb,
.inline-comments-list::-webkit-scrollbar-thumb {
    background: #d1d5da;
    border-radius: 10px;
}

.comments-list::-webkit-scrollbar-thumb:hover,
.inline-comments-list::-webkit-scrollbar-thumb:hover {
    background: #959da5;
}

/* Responsive */
@media (max-width: 768px) {
    .comments-sidebar {
        width: 100%;
    }

    .inline-comments-section.open {
        max-height: 400px;
    }

    .inline-comment-avatar i {
        font-size: 24px;
    }
}

