/* Comment Attachments Styles */

.comment__attachments {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 312px;
}

.comment__attachment {
    position: relative;
    display: block;
    overflow: hidden;
    background: var(--color-bg-secondary, #f5f5f5);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.comment__attachment:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.comment__attachment picture {
    display: block;
    width: 100%;
    height: 100%;
}

.comment__attachment img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 1 image - full width, smaller */
.comment__attachments--count-1 {
    grid-template-columns: 1fr;
}

.comment__attachments--count-1 .comment__attachment {
    aspect-ratio: 16 / 9;
    max-height: 250px;
}

/* 2 images - side by side */
.comment__attachments--count-2 {
    grid-template-columns: repeat(2, 1fr);
}

.comment__attachments--count-2 .comment__attachment {
    aspect-ratio: 1 / 1;
    max-height: 200px;
}

/* 3 images - 1 сверху, 2 снизу */
.comment__attachments--count-3 {
    grid-template-columns: repeat(2, 1fr);
}

.comment__attachments--count-3 .comment__attachment:first-child {
    grid-column: 1 / 3;
    aspect-ratio: 2 / 1;
    max-height: 156px;
}

.comment__attachments--count-3 .comment__attachment:not(:first-child) {
    aspect-ratio: 1 / 1;
    max-height: 156px;
}

/* 4 images - 1 сверху, 3 снизу */
.comment__attachments--count-4 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-4 .comment__attachment:first-child {
    grid-column: 1 / 4;
    aspect-ratio: 3 / 1;
    max-height: 120px;
}

.comment__attachments--count-4 .comment__attachment:not(:first-child) {
    aspect-ratio: 1 / 1;
    max-height: 120px;
}

/* 5 images - 2 сверху, 3 снизу */
.comment__attachments--count-5 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-5 .comment__attachment:nth-child(1) {
    grid-column: 1 / 3;
    aspect-ratio: 2 / 1;
    max-height: 120px;
}

.comment__attachments--count-5 .comment__attachment:nth-child(2) {
    grid-column: 3 / 4;
    aspect-ratio: 1 / 1;
    max-height: 120px;
}

.comment__attachments--count-5 .comment__attachment:nth-child(n+3) {
    aspect-ratio: 1 / 1;
    max-height: 100px;
}

/* 6 images - 3x2 grid */
.comment__attachments--count-6 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-6 .comment__attachment {
    aspect-ratio: 1 / 1;
    max-height: 154px;
}

/* 7 images - 1 сверху, 3 снизу, 3 снизу */
.comment__attachments--count-7 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-7 .comment__attachment:first-child {
    grid-column: 1 / 4;
    aspect-ratio: 3 / 1;
    max-height: 120px;
}

.comment__attachments--count-7 .comment__attachment:not(:first-child) {
    aspect-ratio: 1 / 1;
    max-height: 100px;
}

/* 8 images - 2 сверху, 3 снизу, 3 снизу */
.comment__attachments--count-8 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-8 .comment__attachment:nth-child(1) {
    grid-column: 1 / 3;
    aspect-ratio: 2 / 1;
    max-height: 100px;
}

.comment__attachments--count-8 .comment__attachment:nth-child(2) {
    grid-column: 3 / 4;
    aspect-ratio: 1 / 1;
    max-height: 100px;
}

.comment__attachments--count-8 .comment__attachment:nth-child(n+3) {
    aspect-ratio: 1 / 1;
    max-height: 100px;
}

/* 9 images - 3x3 grid */
.comment__attachments--count-9 {
    grid-template-columns: repeat(3, 1fr);
}

.comment__attachments--count-9 .comment__attachment {
    aspect-ratio: 1 / 1;
    max-height: 100px;
}

/* 10 images - 2 сверху, 4 снизу, 4 снизу */
.comment__attachments--count-10 {
    grid-template-columns: repeat(4, 1fr);
}

.comment__attachments--count-10 .comment__attachment:nth-child(1),
.comment__attachments--count-10 .comment__attachment:nth-child(2) {
    grid-column: span 2;
    aspect-ratio: 2 / 1;
    max-height: 90px;
}

.comment__attachments--count-10 .comment__attachment:nth-child(n+3) {
    aspect-ratio: 1 / 1;
    max-height: 90px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .comment__attachments {
        max-width: 100%;
    }
    
    .comment__attachments--count-3,
    .comment__attachments--count-4,
    .comment__attachments--count-5,
    .comment__attachments--count-6,
    .comment__attachments--count-7,
    .comment__attachments--count-8,
    .comment__attachments--count-9 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .comment__attachments--count-3 .comment__attachment:first-child,
    .comment__attachments--count-4 .comment__attachment:first-child,
    .comment__attachments--count-7 .comment__attachment:first-child {
        grid-column: 1 / 3;
    }
    
    .comment__attachments--count-5 .comment__attachment:nth-child(1),
    .comment__attachments--count-5 .comment__attachment:nth-child(2),
    .comment__attachments--count-8 .comment__attachment:nth-child(1),
    .comment__attachments--count-8 .comment__attachment:nth-child(2) {
        grid-column: span 1;
    }
    
    .comment__attachments--count-10 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .comment__attachments--count-10 .comment__attachment:nth-child(1) {
        grid-column: 1 / 3;
    }
    
    .comment__attachments--count-10 .comment__attachment:nth-child(2) {
        grid-column: 3 / 4;
    }
}

@media (max-width: 480px) {
    .comment__attachments {
        gap: 4px;
    }
    
    .comment__attachments--count-10 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .comment__attachments--count-10 .comment__attachment:nth-child(1),
    .comment__attachments--count-10 .comment__attachment:nth-child(2) {
        grid-column: span 1;
    }
}

/* Comment form attachment preview */
.comment-form__attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.comment-form__attachment-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-bg-secondary, #f5f5f5);
}

.comment-form__attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-form__attachment-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: background 0.2s ease;
}

.comment-form__attachment-remove:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Attachment button in comment form */
.comment-form__input {
    position: relative;
}

.comment-form__attach-btn {
    position: absolute;
    top: 25px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary, #666);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.comment-form__attach-btn:hover {
    background: var(--color-bg-secondary, #f5f5f5);
    color: var(--color-primary, #007bff);
}

.comment-form__attach-btn svg {
    width: 20px;
    height: 20px;
}

.comment-form__attach-input {
    display: none;
}
