/* Gallery styles */
.gallery-section {
    width: 100%;
    margin-bottom: 20px;
    position: relative;
}

.simple-gallery {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 2px;
    margin-bottom: 10px;
}

.gallery-container {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    background-color: var(--card-bg);
    border-radius: 2px;
}

/* Portrait mode for gallery */
.gallery-container.portrait {
    aspect-ratio: 3/4;
    height: auto;
    max-height: 70vh;
}

.gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.gallery-item.active {
    opacity: 1;
    display: block;
    z-index: 2;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

/* Thumbnails directly below gallery */
.gallery-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow: visible;
    padding: 10px 0;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    justify-content: center;
    margin-top: 10px;
    position: relative;
}

.gallery-thumbnails::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.gallery-thumbnail {
    width: 30px;
    height: 60px;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    flex-shrink: 0;
    border: 1px solid transparent;
    position: relative;
}

/* Delete button under thumbnail */
.gallery-thumbnail .delete-image-btn {
    position: absolute;
    top: 0;
    /* left: 0;  Remove to allow centering */
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 20;
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    font-size: inherit;
    font-weight: normal;
    gap: 0;
}

/* Show delete button only on active thumbnail (except first) */
.gallery-thumbnail.active:not(:first-child) .delete-image-btn {
    display: flex;
}

/* Make SVG large and centered */
.gallery-thumbnail .delete-image-btn img,
.gallery-thumbnail .delete-image-btn svg {
    width: 24px;
    height: 24px;
    display: block;
    margin: 0 auto;
    pointer-events: none;
}

/* Add overlay effect when delete button is visible */
.gallery-thumbnail.active:not(:first-child) .delete-image-btn {
    background: rgba(0,0,0,0.35);
}

.gallery-thumbnail.active {
    opacity: 1;
    border-color: var(--brand-purple);
    width: 60px;
    height: 60px;
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.gallery-upload-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: var(--tg-blue, rgba(255,255,255,0.1));
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.gallery-upload-thumbnail:hover {
    background-color: var(--tg-link, rgba(255,255,255,0.2));
}

.gallery-upload-thumbnail.uploading {
    background-color: var(--brand-purple);
    pointer-events: none;
}

.gallery-upload-input {
    display: none;
}

/* Delete button moved under the selected thumbnail */
.delete-image-btn {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    font-size: 12px;
}

/* Loading state for upload button */
.gallery-upload-btn.uploading {
    background-color: var(--brand-purple);
    pointer-events: none;
}

.loading-spinner.small {
    width: 12px;
    height: 12px;
    border-width: 1px;
}

/* Fullscreen gallery improvements */
.fullscreen-gallery {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-color, rgba(0,0,0,0.95));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--tg-text);
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tg-blue, rgba(255,255,255,0.2));
    border-radius: 50%;
    z-index: 1001;
}

.fullscreen-prev,
.fullscreen-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--tg-blue, rgba(255,255,255,0.2));
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: background-color 0.2s ease;
}

.fullscreen-prev {
    left: 20px;
}

.fullscreen-next {
    right: 20px;
}

.fullscreen-prev:hover,
.fullscreen-next:hover {
    background: var(--tg-link, rgba(255,255,255,0.3));
}

.fullscreen-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--overlay-color, rgba(0,0,0,0.5));
    color: var(--tg-text);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1001;
}

/* Assistant details styling */
.detail-content {
    padding: 0 20px;
}

.assistant-name {
    font-family: 'Satoshi', Arial, sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--tg-text);
}

.assistant-description {
    font-size: 16px;
    line-height: 1.5;
    color: var(--tg-hint, var(--tg-text));
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .gallery-container {
        height: 250px;
    }
    
    .fullscreen-prev,
    .fullscreen-next {
        width: 36px;
        height: 36px;
    }
    
    .gallery-thumbnail {
        width: 25px;
        height: 50px;
    }
    
    .gallery-thumbnail.active {
        width: 50px;
        height: 50px;
    }
    
    .gallery-upload-thumbnail {
        width: 50px;
        height: 50px;
    }
}
