/* ==============================================
   COMMENTS (Combined Legacy & Unified)
   ============================================== */

/* --- LEGACY COMMENTS --- */
.comment-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.comment-author {
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.comment-content {
    color: var(--text-main);
    margin-bottom: 0.2rem;
}

.comment-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.comment-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    padding: 0.5rem 0;
}

.comment-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.comment-input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    background: var(--bg-card);
}

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

.comment-submit {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-textarea {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    background: var(--bg-card);
    color: var(--text-main);
}

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

.comment-submit-sm {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

.comment-section {
    margin-top: 2rem;
}

/* Auto-grow textareas override the default form-textarea sizing */
.comment-textarea.comment-textarea-auto {
    min-height: 2.4em;
    max-height: 50vh;
    resize: none;
    overflow-y: hidden;
    box-sizing: border-box;
    flex: none;
}

.btn-fit-end {
    height: fit-content;
    align-self: flex-end;
    /* Stability Fix */
    min-width: 44px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.copyright-conditional {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    display: none;
}

/* assets/css/components/comments.css */

/* Comment Edit Styles */
.comment-edit-box {
    margin-top: 0.5rem;
}

.comment-edit-textarea {
    min-height: 60px;
    margin-bottom: 0.5rem;
    width: 100%;
}

.comment-edit-actions {
    display: flex;
    gap: 0.5rem;
}

/* Lightbox (JS Generated) */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-90);
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.2s ease-out;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    cursor: default;
    box-shadow: 0 0 20px var(--overlay-50);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--glass-20);
    border: none;
    color: var(--text-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: var(--glass-30);
}

/* Compact Comments */
.comment-list-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.comment-card-compact {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

.comment-card-compact .comment-content {
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.comment-card-compact .comment-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comment-card-compact .comment-meta a {
    color: var(--primary-color);
    text-decoration: none;
}


/* --- UNIFIED COMMENTS (Refactored) --- */

/* Comment Item Container */
.comment-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

/* Avatar */
.comment-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.comment-avatar img,
.comment-avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.comment-avatar-placeholder {
    background: var(--bg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Body */
.comment-body {
    flex: 1;
    min-width: 0;
    /* Prevents flex overflow */
}

/* Header (Name, Date, Actions) */
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.25rem;
}

/* comment-meta defined above mostly reused, augmenting if needed */
.comment-meta {
    font-size: 0.9rem;
    line-height: 1.3;
    display: flex;
    align-items: baseline;
    /* Ensure all inline elements align to text baseline */
    flex-wrap: wrap;
    gap: 0.25rem;
}

.comment-author {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
}

.comment-author:hover {
    text-decoration: underline;
}

.comment-date {
    display: inline;
    /* Changed from inline-block for better baseline alignment */
    margin-left: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Actions (Like, Delete) */
.comment-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-comment-action {
    background: none;
    border: none;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.btn-comment-action:hover {
    background: var(--bg-surface-2);
    color: var(--text-main);
}

.btn-comment-action.liked {
    color: var(--primary-color);
}

.btn-comment-action.liked:hover {
    background: var(--primary-light);
}

.btn-comment-action.delete {
    color: var(--danger-color);
}

.btn-comment-action.delete:hover {
    background: color-mix(in srgb, var(--color-coral), transparent 80%);
    transform: scale(1.05);
}

/* Readonly-Variante für eigene Kommentare (Like-Counter ohne Klick) */
.btn-comment-action--readonly {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}



/* Content */
.comment-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
}

/* Image Attachment */
.comment-image-wrapper {
    margin-top: 0.5rem;
    max-width: 300px;
    border-radius: var(--radius-md);
    overflow: hidden;
    /* border: 1px solid var(--border-color); REMOVED: Fixes white space issue */
    cursor: pointer;
    position: relative;
    /* Ensure wrapper tightly fits content if possible, or just removed border */
}

.comment-image-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    max-height: 400px;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
    /* MOVED HERE */
    border-radius: var(--radius-md);
}

.comment-image-wrapper:hover img {
    transform: scale(1.02);
}

/* Delete Button on Comment Image (Neo-Brutalist) */
.comment-image-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger-color);
    color: var(--text-light);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 3px 3px 0 var(--brutal-shadow);
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.1s, box-shadow 0.1s;
}

.comment-image-delete-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 var(--brutal-shadow);
}

.comment-image-delete-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--brutal-shadow);
}

.comment-image-delete-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 3px 3px 0 var(--brutal-shadow);
}

/* Unified Comment Form Styles */
.comment-form-unified {
    margin-top: 1.5rem;
}

.comment-form-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.comment-form-input-col {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comment-form-note {
    max-width: min(100%, 40rem);
}

.comment-submit-btn {
    flex: 0 0 auto;
}

.comment-file-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    margin-top: 0.5rem;
    width: fit-content;
}

.comment-file-label:hover {
    background: var(--bg-surface-2);
    border-color: var(--border-color-dark);
}

.comment-image-preview-container {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.comment-image-preview-img {
    max-width: 80px;
    max-height: 80px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    object-fit: cover;
}

.btn-remove-image {
    background: var(--status-error-bg);
    color: var(--status-error-text);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.btn-remove-image:hover {
    background: var(--status-error-light);
}

/* Cleanup Helpers */

/* ==============================================
   MOBILE RESPONSIVE COMMENTS
   ============================================== */
@media (max-width: 600px) {

    /* Reduce padding on mobile */
    .comment-item {
        padding: 0.75rem 0.5rem;
        gap: 0.5rem;
    }

    /* Smaller avatar on mobile */
    .comment-avatar {
        width: 28px;
        height: 28px;
    }

    .comment-avatar-placeholder {
        font-size: 1rem;
    }

    /* Stack header vertically: meta on top, actions below */
    .comment-header {
        flex-direction: row;
        /* Keep inline on mobile too */
        flex-wrap: wrap;
        /* Allow wrapping if needed */
        align-items: center;
        gap: 0.25rem 0.5rem;
    }

    /* Meta (Author + Date) inline, smaller font */
    .comment-meta {
        font-size: 0.8rem;
        display: flex;
        align-items: baseline;
        gap: 0.25rem;
    }

    .comment-date {
        font-size: 0.7rem;
        margin-left: 0.35rem;
    }

    /* Actions: inline, right after date */
    .comment-actions {
        gap: 0.25rem;
        margin-left: auto;
        /* Push to end if space allows */
    }

    .btn-comment-action {
        padding: 2px 4px;
        font-size: 0.75rem;
    }

    /* Comment text slightly smaller */
    .comment-text {
        font-size: 0.9rem;
    }

    /* Form: keep textarea + button in one row on mobile */
    .comment-form-row {
        flex-direction: row;
        gap: 0.5rem;
    }

    .comment-submit-btn {
        min-width: 48px;
        min-height: 48px;
    }

    /* Smaller image preview */
    .comment-image-wrapper {
        max-width: 100%;
    }
}
