/* Comments Module Styles */

/* Panel mode - glassmorphism style matching flow/memo sidebars */
.comments-panel {
    position: absolute;
    right: 12px;
    top: 12px;
    bottom: 12px;
    width: 500px;
    min-width: 240px;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--soft-shadow);
    background: var(--card);
    display: none;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    max-height: calc(100vh - 140px);
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.comments-panel.active {
    display: flex;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Memo editor and Flow editor have different positioning */
.drawer-body-fullscreen .comments-panel,
.flow-editor-main .comments-panel {
    right: 20px;
    top: 20px;
    bottom: 20px;
    width: 460px;
    min-width: 460px;
}

.comments-panel .comments-panel-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.comments-panel .comments-panel-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    color: var(--foreground);
    letter-spacing: -0.01em;
}

.comments-panel .comments-panel-close {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-foreground);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.comments-panel .comments-panel-close:hover {
    background: var(--muted);
    color: var(--foreground);
}

/* Drawer mode - traditional side drawer */
.comments-drawer {
    width: 400px;
    background: var(--background);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 11000; /* Above flow editor (10000) */
}

/* Ensure it stacks correctly when multiple drawers are open */
#commentsDrawer {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.flow-editor-active .drawer-overlay.open {
    z-index: 10500;
}

.comments-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Panel mode has tighter spacing */
.comments-panel .comments-timeline {
    padding: 12px;
    gap: 12px;
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
}

.comment-item {
    position: relative;
    padding-left: 16px;
    border-left: 2px solid var(--border);
    transition: background-color 0.15s ease, opacity 0.15s ease;
    margin-bottom: var(--space-4);
    
    /* Optimization for long timelines */
    content-visibility: auto;
    contain-intrinsic-size: 0 100px;
}

/* Item Drawer specialized comment items */
.item-drawer-comment {
    padding: 12px var(--drawer-padding-x) !important;
    border-bottom: 1px solid var(--border);
    border-left: none !important;
}

/* Disable timeline circles for panel mode - we use SVG icons instead */
.comments-panel .comment-item::before {
    display: none;
}

/* Remove timeline border for panel mode */
.comments-panel .comment-item {
    border-left: none;
    padding-left: 0;
}

.comment-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--background);
    border: 2px solid var(--primary);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.comment-user,
.comment-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--foreground);
}

.comment-date {
    font-size: 11px;
    color: var(--muted-foreground);
}

.comment-message,
.comment-content {
    font-size: 14px;
    color: var(--foreground);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.comment-footer {
    margin-top: 6px;
    display: flex;
    gap: 8px;
}

.comment-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--muted);
    color: var(--muted-foreground);
    text-transform: uppercase;
}

/* Public comment badge */
.comment-badge.public,
.comment-public-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 600;
}

.dark .comment-public-badge {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
}

/* Private annotation badge */
.comment-badge.private,
.comment-private-badge,
.comment-annotation-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--muted);
    color: var(--muted-foreground);
    text-transform: uppercase;
    font-weight: 600;
}

.comment-form {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--background);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Panel mode has tighter spacing */
.comments-panel .comment-form {
    padding: 12px;
    gap: 8px;
    background: var(--card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex !important;
}

.comment-input-wrapper {
    position: relative;
}

.comment-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--foreground);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    transition: border-color 0.2s;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.comment-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.private-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted-foreground);
    cursor: pointer;
}

.private-toggle input {
    cursor: pointer;
}

/* Button in Item Drawer */
.comments-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    margin-top: 16px;
    width: 100%;
    background: var(--accent);
    color: var(--accent-foreground);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.comments-trigger-btn:hover {
    background: var(--accent-hover, #f4f4f5);
}

/* Empty State */
.comments-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted-foreground);
    text-align: center;
    padding: 0 40px;
}

.comments-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Comment Actions */
.comment-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.comment-item:hover .comment-actions {
    opacity: 1;
}

.comment-action-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-foreground);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.comment-action-btn:hover {
    background: var(--muted);
    color: var(--foreground);
}

.comment-action-btn.delete:hover {
    color: #ef4444;
    background: #fee2e2;
}

/* Inline Edit */
.comment-edit-form {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}


.comment-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.comment-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.comment-edit-btn {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--background);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.comment-edit-btn:hover {
    background: var(--muted);
}

.comment-edit-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.comment-edit-btn.primary:hover {
    opacity: 0.9;
}
