/* Controles da galeria */
.gallery-controls {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.gallery-controls .form-label {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.gallery-controls .form-label i {
    margin-right: 6px;
    font-size: 14px;
}

.gallery-controls .form-label small {
    color: #495057;
    font-weight: 600;
}

.gallery-controls .form-control {
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: none;
}

.gallery-controls .form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
    outline: none;
}

.gallery-controls .input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
}

.gallery-controls .input-group-append .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid #ced4da;
    padding: 10px 12px;
}

.gallery-controls .btn {
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.gallery-controls .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-controls .btn-outline-secondary {
    color: #6c757d;
    border-color: #ced4da;
    background-color: #f8f9fa;
}

.gallery-controls .btn-outline-secondary:hover {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

/* Botão de limpar pesquisa específico */
.btn-search-clear {
    padding: 10px 12px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    transition: all 0.2s ease;
}

.btn-search-clear:hover {
    background-color: #e9ecef;
    color: #495057;
    transform: none;
}

.gallery-controls .btn-outline-success {
    color: #198754;
    border-color: #198754;
}

.gallery-controls .btn-outline-success:hover {
    background-color: #198754;
    color: white;
}



/* Items da galeria */
.img-gallery-item {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border: 3px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    height: 200px;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    aspect-ratio: 210 / 297;
}

.img-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.img-gallery-item.selected {
    border-color: #007bff;
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
    transform: translateY(-3px);
}

.img-gallery-item.selected::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 20;
    border: 2px solid white;
}

.img-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay com informações */
.img-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0.9) 100%);
    color: white;
    padding: 30px 12px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.img-gallery-item:hover .img-overlay {
    opacity: 1;
}

.img-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.img-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.img-id {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 400;
}

/* Informações da galeria */
.gallery-info {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
    margin-bottom: 20px;
}

/* Container da galeria */
#gallery-container {
    max-height: 420px;
    overflow-y: auto;
    padding: 5px;
    display: block !important;
    margin-left: 0;
    margin-right: 0;
}

#gallery-container>[class*="col-"] {
    padding-left: 5px;
    padding-right: 5px;
}

#gallery-container::-webkit-scrollbar {
    width: 6px;
}

#gallery-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

#gallery-container::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 3px;
}

#gallery-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Container do Preview */
.preview-container {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    min-height: 600px;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.preview-title {
    color: #495057;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
}

/* Estado sem seleção */
.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    height: 320px;
    transition: all 0.3s ease;
}

.placeholder-content h6 {
    margin-bottom: 8px;
}

.placeholder-content p {
    margin-bottom: 0;
    line-height: 1.4;
}

/* Preview da imagem */
#image-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-image-container {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    overflow: visible;
    position: relative;
    transition: all 0.3s ease;
}

.preview-image {
    max-width: 100%;
    height: 300px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: block;
    transition: all 0.3s ease;
}

.preview-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
}

/* Detalhes da imagem */
.preview-details {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #f8f9fa;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item strong {
    color: #495057;
    font-size: 12px;
}

.detail-item span {
    color: #6c757d;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}

/* Ações do preview */
.preview-actions {
    margin-top: 10px;
}

.preview-actions .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* Estados especiais */
.gallery-item-hidden {
    display: none !important;
}

#no-results {
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

#selected-images-info {
    border-radius: 6px;
    border: 1px solid #d4edda;
}

/* Responsividade melhorada */
@media (max-width: 768px) {
    .img-gallery-item {
        height: 180px;
        aspect-ratio: 210 / 297;
    }

    .preview-container {
        margin-top: 20px;
        height: auto;
        min-height: 450px;
        padding: 15px;
    }

    .preview-title {
        margin-bottom: 10px;
        padding-bottom: 6px;
        font-size: 13px;
    }

    .preview-image-container {
        padding: 15px;
        overflow: visible;
    }

    .preview-image {
        height: 250px;
    }

    .preview-image:hover {
        transform: none;
    }

    .preview-details {
        padding: 10px;
        margin-top: 8px;
    }

    .preview-actions {
        margin-top: 8px;
    }

    .preview-placeholder {
        height: 280px;
        padding: 15px;
    }

    .placeholder-content {
        padding: 20px 15px;
    }

    .placeholder-content .fa-3x {
        font-size: 2rem !important;
    }
}

@media (max-width: 576px) {
    .gallery-controls {
        padding: 15px;
    }

    .gallery-controls .form-control,
    .gallery-controls .btn {
        font-size: 13px;
        padding: 8px 10px;
    }

    .gallery-controls .form-label small {
        font-size: 12px;
    }

    .gallery-controls .form-label i {
        font-size: 12px;
    }

    .img-gallery-item {
        height: 160px;
        aspect-ratio: 210 / 297;
    }


}

.preview-container {
    height: auto;
    min-height: 400px;
    padding: 15px;
    overflow: visible;
}

.preview-title {
    margin-bottom: 8px;
    padding-bottom: 4px;
    font-size: 12px;
}

.preview-image-container {
    padding: 10px;
}

.preview-details {
    padding: 8px;
    margin-top: 6px;
}

.detail-item {
    padding: 2px 0;
}

.detail-item strong,
.detail-item span {
    font-size: 11px;
}

.preview-actions {
    margin-top: 6px;
}

.preview-actions .btn {
    font-size: 11px;
    padding: 4px 8px;
}

.placeholder-content {
    padding: 15px 10px;
}

.placeholder-content .fa-3x {
    font-size: 1.5rem !important;
    margin-bottom: 10px !important;
}

.placeholder-content h6 {
    font-size: 13px;
    margin-bottom: 6px;
}

.placeholder-content p {
    font-size: 11px;
}

/* Loading state */
#loading-gallery {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loading-gallery .spinner-border {
    width: 3rem;
    height: 3rem;
}